summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-extended/polkit/polkit/0002-jsauthority-port-to-mozjs-91.patch38
-rw-r--r--meta-oe/recipes-extended/polkit/polkit/0003-jsauthority-ensure-to-call-JS_Init-and-JS_ShutDown-e.patch63
-rw-r--r--meta-oe/recipes-extended/polkit/polkit_0.119.bb19
3 files changed, 117 insertions, 3 deletions
diff --git a/meta-oe/recipes-extended/polkit/polkit/0002-jsauthority-port-to-mozjs-91.patch b/meta-oe/recipes-extended/polkit/polkit/0002-jsauthority-port-to-mozjs-91.patch
new file mode 100644
index 0000000000..5b3660da2f
--- /dev/null
+++ b/meta-oe/recipes-extended/polkit/polkit/0002-jsauthority-port-to-mozjs-91.patch
@@ -0,0 +1,38 @@
1From 4ce27b66bb07b72cb96d3d43a75108a5a6e7e156 Mon Sep 17 00:00:00 2001
2From: Xi Ruoyao <xry111@mengyan1223.wang>
3Date: Tue, 10 Aug 2021 19:09:42 +0800
4Subject: [PATCH] jsauthority: port to mozjs-91
5
6Upstream-Status: Submitted [https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/92]
7Signed-off-by: Alexander Kanavin <alex@linutronix.de>
8---
9 configure.ac | 2 +-
10 meson.build | 2 +-
11 2 files changed, 2 insertions(+), 2 deletions(-)
12
13diff --git a/configure.ac b/configure.ac
14index d807086..5a7fc11 100644
15--- a/configure.ac
16+++ b/configure.ac
17@@ -80,7 +80,7 @@ PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0])
18 AC_SUBST(GLIB_CFLAGS)
19 AC_SUBST(GLIB_LIBS)
20
21-PKG_CHECK_MODULES(LIBJS, [mozjs-78])
22+PKG_CHECK_MODULES(LIBJS, [mozjs-91])
23
24 AC_SUBST(LIBJS_CFLAGS)
25 AC_SUBST(LIBJS_CXXFLAGS)
26diff --git a/meson.build b/meson.build
27index b3702be..733bbff 100644
28--- a/meson.build
29+++ b/meson.build
30@@ -126,7 +126,7 @@ expat_dep = dependency('expat')
31 assert(cc.has_header('expat.h', dependencies: expat_dep), 'Can\'t find expat.h. Please install expat.')
32 assert(cc.has_function('XML_ParserCreate', dependencies: expat_dep), 'Can\'t find expat library. Please install expat.')
33
34-mozjs_dep = dependency('mozjs-78')
35+mozjs_dep = dependency('mozjs-91')
36
37 dbus_dep = dependency('dbus-1')
38 dbus_confdir = dbus_dep.get_pkgconfig_variable('datadir', define_variable: ['datadir', pk_prefix / pk_datadir]) #changed from sysconfdir with respect to commit#8eada3836465838
diff --git a/meta-oe/recipes-extended/polkit/polkit/0003-jsauthority-ensure-to-call-JS_Init-and-JS_ShutDown-e.patch b/meta-oe/recipes-extended/polkit/polkit/0003-jsauthority-ensure-to-call-JS_Init-and-JS_ShutDown-e.patch
new file mode 100644
index 0000000000..9e9755e44f
--- /dev/null
+++ b/meta-oe/recipes-extended/polkit/polkit/0003-jsauthority-ensure-to-call-JS_Init-and-JS_ShutDown-e.patch
@@ -0,0 +1,63 @@
1From 7799441b9aa55324160deefbc65f9d918b8c94c1 Mon Sep 17 00:00:00 2001
2From: Xi Ruoyao <xry111@mengyan1223.wang>
3Date: Tue, 10 Aug 2021 18:52:56 +0800
4Subject: [PATCH] jsauthority: ensure to call JS_Init() and JS_ShutDown()
5 exactly once
6
7Before this commit, we were calling JS_Init() in
8polkit_backend_js_authority_class_init and never called JS_ShutDown.
9This is actually a misusage of SpiderMonkey API. Quote from a comment
10in js/Initialization.h (both mozjs-78 and mozjs-91):
11
12 It is currently not possible to initialize SpiderMonkey multiple
13 times (that is, calling JS_Init/JSAPI methods/JS_ShutDown in that
14 order, then doing so again).
15
16This misusage does not cause severe issues with mozjs-78. However, when
17we eventually port jsauthority to use mozjs-91, bad thing will happen:
18see the test failure mentioned in #150.
19
20This commit is tested with both mozjs-78 and mozjs-91, all tests pass
21with it.
22
23Upstream-Status: Submitted [https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/91]
24Signed-off-by: Alexander Kanavin <alex@linutronix.de>
25---
26 src/polkitbackend/polkitbackendjsauthority.cpp | 10 +++++++---
27 1 file changed, 7 insertions(+), 3 deletions(-)
28
29diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp
30index 41d8d5c..38dc001 100644
31--- a/src/polkitbackend/polkitbackendjsauthority.cpp
32+++ b/src/polkitbackend/polkitbackendjsauthority.cpp
33@@ -75,6 +75,13 @@
34
35 /* ---------------------------------------------------------------------------------------------------- */
36
37+static class JsInitHelperType
38+{
39+public:
40+ JsInitHelperType() { JS_Init(); }
41+ ~JsInitHelperType() { JS_ShutDown(); }
42+} JsInitHelper;
43+
44 struct _PolkitBackendJsAuthorityPrivate
45 {
46 gchar **rules_dirs;
47@@ -589,7 +596,6 @@ polkit_backend_js_authority_finalize (GObject *object)
48 delete authority->priv->js_polkit;
49
50 JS_DestroyContext (authority->priv->cx);
51- /* JS_ShutDown (); */
52
53 G_OBJECT_CLASS (polkit_backend_js_authority_parent_class)->finalize (object);
54 }
55@@ -665,8 +671,6 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass)
56
57
58 g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate));
59-
60- JS_Init ();
61 }
62
63 /* ---------------------------------------------------------------------------------------------------- */
diff --git a/meta-oe/recipes-extended/polkit/polkit_0.119.bb b/meta-oe/recipes-extended/polkit/polkit_0.119.bb
index 66bbf735f0..bf160053d9 100644
--- a/meta-oe/recipes-extended/polkit/polkit_0.119.bb
+++ b/meta-oe/recipes-extended/polkit/polkit_0.119.bb
@@ -5,7 +5,7 @@ LICENSE = "LGPL-2.0-or-later"
5LIC_FILES_CHKSUM = "file://COPYING;md5=155db86cdbafa7532b41f390409283eb \ 5LIC_FILES_CHKSUM = "file://COPYING;md5=155db86cdbafa7532b41f390409283eb \
6 file://src/polkit/polkit.h;beginline=1;endline=20;md5=0a8630b0133176d0504c87a0ded39db4" 6 file://src/polkit/polkit.h;beginline=1;endline=20;md5=0a8630b0133176d0504c87a0ded39db4"
7 7
8DEPENDS = "expat glib-2.0 intltool-native duktape" 8DEPENDS = "expat glib-2.0 intltool-native"
9 9
10inherit autotools gtk-doc pkgconfig useradd systemd gobject-introspection features_check 10inherit autotools gtk-doc pkgconfig useradd systemd gobject-introspection features_check
11 11
@@ -14,6 +14,7 @@ REQUIRED_DISTRO_FEATURES = "polkit"
14PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \ 14PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
15 ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', \ 15 ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', \
16 bb.utils.contains('DISTRO_FEATURES', 'x11', 'consolekit', '', d), d)} \ 16 bb.utils.contains('DISTRO_FEATURES', 'x11', 'consolekit', '', d), d)} \
17 mozjs \
17 " 18 "
18 19
19PACKAGECONFIG[pam] = "--with-authfw=pam,--with-authfw=shadow,libpam,libpam" 20PACKAGECONFIG[pam] = "--with-authfw=pam,--with-authfw=shadow,libpam,libpam"
@@ -21,20 +22,32 @@ PACKAGECONFIG[systemd] = "--enable-libsystemd-login=yes --with-systemdsystemunit
21# there is no --enable/--disable option for consolekit and it's not picked by shlibs, so add it to RDEPENDS 22# there is no --enable/--disable option for consolekit and it's not picked by shlibs, so add it to RDEPENDS
22PACKAGECONFIG[consolekit] = ",,,consolekit" 23PACKAGECONFIG[consolekit] = ",,,consolekit"
23 24
25# Default to mozjs javascript library
26PACKAGECONFIG[mozjs] = ",,mozjs-91,,,duktape"
27# duktape javascript engine is much smaller and faster but is not compatible with
28# same javascript standards as mozjs. For example array.includes() function is not
29# supported. Test rule compatibility when switching to duktape.
30PACKAGECONFIG[duktape] = "--with-duktape,,duktape,,,mozjs"
31
32MOZJS_PATCHES = "\
33 file://0002-jsauthority-port-to-mozjs-91.patch \
34 file://0003-jsauthority-ensure-to-call-JS_Init-and-JS_ShutDown-e.patch \
35"
36DUKTAPE_PATCHES = "file://0003-Added-support-for-duktape-as-JS-engine.patch"
24PAM_SRC_URI = "file://polkit-1_pam.patch" 37PAM_SRC_URI = "file://polkit-1_pam.patch"
25SRC_URI = "http://www.freedesktop.org/software/polkit/releases/polkit-${PV}.tar.gz \ 38SRC_URI = "http://www.freedesktop.org/software/polkit/releases/polkit-${PV}.tar.gz \
26 ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \ 39 ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \
40 ${@bb.utils.contains('PACKAGECONFIG', 'mozjs', '${MOZJS_PATCHES}', '', d)} \
41 ${@bb.utils.contains('PACKAGECONFIG', 'duktape', '${DUKTAPE_PATCHES}', '', d)} \
27 file://0003-make-netgroup-support-optional.patch \ 42 file://0003-make-netgroup-support-optional.patch \
28 file://0001-pkexec-local-privilege-escalation-CVE-2021-4034.patch \ 43 file://0001-pkexec-local-privilege-escalation-CVE-2021-4034.patch \
29 file://0002-CVE-2021-4115-GHSL-2021-077-fix.patch \ 44 file://0002-CVE-2021-4115-GHSL-2021-077-fix.patch \
30 file://0003-Added-support-for-duktape-as-JS-engine.patch \
31 " 45 "
32SRC_URI[sha256sum] = "c8579fdb86e94295404211285fee0722ad04893f0213e571bd75c00972fd1f5c" 46SRC_URI[sha256sum] = "c8579fdb86e94295404211285fee0722ad04893f0213e571bd75c00972fd1f5c"
33 47
34EXTRA_OECONF = "--with-os-type=moblin \ 48EXTRA_OECONF = "--with-os-type=moblin \
35 --disable-man-pages \ 49 --disable-man-pages \
36 --disable-libelogind \ 50 --disable-libelogind \
37 --with-duktape \
38 " 51 "
39 52
40do_configure:prepend () { 53do_configure:prepend () {