diff --git a/change-js-authority-to-mozjs-91.patch b/change-js-authority-to-mozjs-91.patch new file mode 100644 index 0000000000000000000000000000000000000000..2e26b47a05e974a32b6391b432f45ffeae5fa699 --- /dev/null +++ b/change-js-authority-to-mozjs-91.patch @@ -0,0 +1,143 @@ +From a6bedfd09b7bba753de7a107dc471da0db801858 Mon Sep 17 00:00:00 2001 +From: Xi Ruoyao +Date: Thu, 27 Jan 2022 10:16:32 +0000 +Subject: [PATCH] jsauthority: port to mozjs-91 + +--- + Makefile.am | 2 ++ + configure | 18 +++++++++--------- + configure.ac | 2 +- + meson.build | 2 +- + src/polkitbackend/polkitbackendjsauthority.cpp | 9 +++++++-- + 5 files changed, 20 insertions(+), 13 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index 199576a..9d5e1c9 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -22,6 +22,8 @@ DISTCHECK_CONFIGURE_FLAGS= \ + --disable-introspection \ + --enable-gtk-doc \ + --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) \ ++ --enable-libsystemd-login=yes \ ++ --enable-libelogind=no \ + $(NULL) + + sign : dist +diff --git a/configure b/configure +index f6829c0..bb1e688 100755 +--- a/configure ++++ b/configure +@@ -19742,12 +19742,12 @@ if test -n "$LIBJS_CFLAGS"; then + pkg_cv_LIBJS_CFLAGS="$LIBJS_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ +- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-78\""; } >&5 +- ($PKG_CONFIG --exists --print-errors "mozjs-78") 2>&5 ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-91\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "mozjs-91") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then +- pkg_cv_LIBJS_CFLAGS=`$PKG_CONFIG --cflags "mozjs-78" 2>/dev/null` ++ pkg_cv_LIBJS_CFLAGS=`$PKG_CONFIG --cflags "mozjs-91" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes + else + pkg_failed=yes +@@ -19759,12 +19759,12 @@ if test -n "$LIBJS_LIBS"; then + pkg_cv_LIBJS_LIBS="$LIBJS_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ +- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-78\""; } >&5 +- ($PKG_CONFIG --exists --print-errors "mozjs-78") 2>&5 ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"mozjs-91\""; } >&5 ++ ($PKG_CONFIG --exists --print-errors "mozjs-91") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then +- pkg_cv_LIBJS_LIBS=`$PKG_CONFIG --libs "mozjs-78" 2>/dev/null` ++ pkg_cv_LIBJS_LIBS=`$PKG_CONFIG --libs "mozjs-91" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes + else + pkg_failed=yes +@@ -19785,14 +19785,14 @@ else + _pkg_short_errors_supported=no + fi + if test $_pkg_short_errors_supported = yes; then +- LIBJS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "mozjs-78" 2>&1` ++ LIBJS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "mozjs-91" 2>&1` + else +- LIBJS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "mozjs-78" 2>&1` ++ LIBJS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "mozjs-91" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBJS_PKG_ERRORS" >&5 + +- as_fn_error $? "Package requirements (mozjs-78) were not met: ++ as_fn_error $? "Package requirements (mozjs-91) were not met: + + $LIBJS_PKG_ERRORS + +diff --git a/configure.ac b/configure.ac +index e434ca2..6783ee7 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -80,7 +80,7 @@ PKG_CHECK_MODULES(GLIB, [gmodule-2.0 gio-unix-2.0 >= 2.30.0]) + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) + +-PKG_CHECK_MODULES(LIBJS, [mozjs-78]) ++PKG_CHECK_MODULES(LIBJS, [mozjs-91]) + + AC_SUBST(LIBJS_CFLAGS) + AC_SUBST(LIBJS_CXXFLAGS) +diff --git a/meson.build b/meson.build +index 858078d..09cce0f 100644 +--- a/meson.build ++++ b/meson.build +@@ -133,7 +133,7 @@ expat_dep = dependency('expat') + assert(cc.has_header('expat.h', dependencies: expat_dep), 'Can\'t find expat.h. Please install expat.') + assert(cc.has_function('XML_ParserCreate', dependencies: expat_dep), 'Can\'t find expat library. Please install expat.') + +-mozjs_dep = dependency('mozjs-78') ++mozjs_dep = dependency('mozjs-91') + + dbus_dep = dependency('dbus-1', required: false) + dbus_policydir = pk_prefix / pk_datadir / 'dbus-1/system.d' +diff --git a/src/polkitbackend/polkitbackendjsauthority.cpp b/src/polkitbackend/polkitbackendjsauthority.cpp +index ca17108..b22c34e 100644 +--- a/src/polkitbackend/polkitbackendjsauthority.cpp ++++ b/src/polkitbackend/polkitbackendjsauthority.cpp +@@ -75,6 +75,13 @@ + + /* ---------------------------------------------------------------------------------------------------- */ + ++static class JsInitHelperType ++{ ++public: ++ JsInitHelperType() { JS_Init(); } ++ ~JsInitHelperType() { JS_ShutDown(); } ++} JsInitHelper; ++ + struct _PolkitBackendJsAuthorityPrivate + { + gchar **rules_dirs; +@@ -589,7 +596,6 @@ polkit_backend_js_authority_finalize (GObject *object) + delete authority->priv->js_polkit; + + JS_DestroyContext (authority->priv->cx); +- /* JS_ShutDown (); */ + + G_OBJECT_CLASS (polkit_backend_js_authority_parent_class)->finalize (object); + } +@@ -666,7 +672,6 @@ polkit_backend_js_authority_class_init (PolkitBackendJsAuthorityClass *klass) + + g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate)); + +- JS_Init (); + } + + /* ---------------------------------------------------------------------------------------------------- */ +-- +2.27.0 + diff --git a/polkit.spec b/polkit.spec index fdf5e1363ed2ccd770aab97c70fe2e2baa557938..352cc2357ed34df14361ededf306395acf67451a 100644 --- a/polkit.spec +++ b/polkit.spec @@ -1,6 +1,6 @@ Name: polkit Version: 0.120 -Release: 2 +Release: 3 Summary: Define and Handle authorizations tool License: LGPLv2+ URL: http://www.freedesktop.org/wiki/Software/polkit @@ -9,9 +9,10 @@ Source1: http://www.freedesktop.org/software/polkit/releases/%{name}-%{ Patch0: modify-admin-authorization-from-wheel-group-to-root.patch Patch1: backport-CVE-2021-4034.patch +Patch6000: change-js-authority-to-mozjs-91.patch BuildRequires: gcc-c++ glib2-devel >= 2.30.0 expat-devel pam-devel gtk-doc intltool -BuildRequires: gobject-introspection-devel systemd systemd-devel pkgconfig(mozjs-78) +BuildRequires: gobject-introspection-devel systemd systemd-devel pkgconfig(mozjs-91) BuildRequires: libxslt autoconf automake libtool Requires: dbus polkit-pkla-compat Requires: %{name}-libs%{?_isa} = %{version}-%{release} @@ -58,7 +59,7 @@ export LDFLAGS='-pie -Wl,-z,now -Wl,-z,relro' --disable-static \ --enable-introspection \ --disable-examples \ - --enable-libsystemd-login=yes --with-mozjs=mozjs-17.0 + --enable-libsystemd-login=yes %make_build sed -i 's/=\"ientry-idm[0-9]\{5,32\}\"/=\"ientry-idm123456789123456\"/g' docs/polkit/html/polit-index.html @@ -125,6 +126,9 @@ exit 0 %{_datadir}/man/man8/* %changelog +* Wed Mar 02 2022 liuyumeng - 0.120-3 +- change js authority to mozjs 91 + * Wed Jan 26 2022 panxiaohe - 0.120-2 - Fix CVE-2021-4034