change jsauthority to mozjs91

This commit is contained in:
Hugel 2022-04-01 11:46:32 +08:00
parent be4e26411e
commit cb2288f909
2 changed files with 149 additions and 3 deletions

View File

@ -0,0 +1,142 @@
From a6bedfd09b7bba753de7a107dc471da0db801858 Mon Sep 17 00:00:00 2001
From: Xi Ruoyao <xry111@mengyan1223.wang>
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

View File

@ -1,6 +1,6 @@
Name: polkit
Version: 0.120
Release: 3
Release: 4
Summary: Define and Handle authorizations tool
License: LGPLv2+
URL: http://www.freedesktop.org/wiki/Software/polkit
@ -10,9 +10,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
Patch2: backport-CVE-2021-4115-GHSL-2021-077-fix.patch
Patch3: backport-jsauthority-port-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}
@ -59,7 +60,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
@ -126,6 +127,9 @@ exit 0
%{_datadir}/man/man8/*
%changelog
* Fri Apr 1 2022 Hugel <gengqihu1@h-partners.com> - 0.120-4
- change jsauthority to mozjs91
* Sat Mar 5 2022 panxiaohe <panxh.life@foxmail.com> - 0.120-3
- Fix CVE-2021-4115