change jsauthority to duktape

This commit is contained in:
Hugel 2022-05-05 11:27:18 +08:00
parent 6aa3a3bea0
commit 34eef71311
4 changed files with 3495 additions and 147 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
From b533b25208f4ea32bed1808bd824e70cfe4b6629 Mon Sep 17 00:00:00 2001
From: Daniel E <daniel.engberg.lists@pyret.net>
Date: Wed, 30 Mar 2022 14:30:42 +0000
Subject: [PATCH] build: Add fallback looking for duktape's library and header
---
meson.build | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index dd09b28..c6765fd 100644
--- a/meson.build
+++ b/meson.build
@@ -137,7 +137,11 @@ duktape_req_version = '>= 2.2.0'
js_engine = get_option('js_engine')
if js_engine == 'duktape'
- js_dep = dependency('duktape', version: duktape_req_version)
+ js_dep = dependency('duktape', version: duktape_req_version, required: false)
+ if not js_dep.found()
+ message('Falling back to looking for library and header...')
+ js_dep = cc.find_library('duktape', has_headers: ['duktape.h'], required: true)
+ endif
libm_dep = cc.find_library('m')
thread_dep = dependency('threads')
func = 'pthread_condattr_setclock'
--
1.8.3.1

View File

@ -1,142 +0,0 @@
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: 4
Release: 5
Summary: Define and Handle authorizations tool
License: LGPLv2+
URL: http://www.freedesktop.org/wiki/Software/polkit
@ -10,11 +10,12 @@ 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
Patch3: backport-Added-support-for-duktape-as-JS-engine.patch
Patch4: backport-build-Add-fallback-looking-for-duktape-s-library-and.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-91)
BuildRequires: libxslt autoconf automake libtool
BuildRequires: gobject-introspection-devel systemd systemd-devel
BuildRequires: libxslt autoconf automake libtool pkgconfig(duktape) >= 2.2.0
Requires: dbus polkit-pkla-compat
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Requires(pre): shadow-utils
@ -60,7 +61,9 @@ export LDFLAGS='-pie -Wl,-z,now -Wl,-z,relro'
--disable-static \
--enable-introspection \
--disable-examples \
--enable-libsystemd-login=yes
--enable-libsystemd-login=yes \
--with-duktape
%make_build
sed -i 's/=\"ientry-idm[0-9]\{5,32\}\"/=\"ientry-idm123456789123456\"/g' docs/polkit/html/polit-index.html
@ -127,6 +130,9 @@ exit 0
%{_datadir}/man/man8/*
%changelog
* Thu May 5 2022 Hugel <gengqihu1@h-partners.com> - 0.120-5
- change jsauthority to duktape
* Fri Apr 1 2022 Hugel <gengqihu1@h-partners.com> - 0.120-4
- change jsauthority to mozjs91