git: 2e8ea81a0df6 - main - sysutils/polkit: update to 122 release (+)

From: Dima Panov <fluffy_at_FreeBSD.org>
Date: Fri, 06 Jan 2023 14:01:35 UTC
The branch main has been updated by fluffy:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2e8ea81a0df6d412f98828f4e19fb8160da122f0

commit 2e8ea81a0df6d412f98828f4e19fb8160da122f0
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2023-01-06 13:55:33 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2023-01-06 14:01:25 +0000

    sysutils/polkit: update to 122 release (+)
    
    Add DUKTAPE (set by default) and SPIDERMONKEY options
    Add support of procctl(2) in pkexec program
    
    Differential Revision:  https://reviews.freebsd.org/D37137
    
    With hat:       desktop
---
 sysutils/polkit/Makefile                           | 31 ++++++++++++--------
 sysutils/polkit/distinfo                           | 10 ++-----
 sysutils/polkit/files/patch-meson.build            | 16 +++++------
 .../files/patch-src_polkitbackend_meson.build      | 19 +++++++++++++
 ...-src_polkitbackend_polkitbackendjsauthority.cpp | 33 ----------------------
 sysutils/polkit/files/patch-src_programs_pkexec.c  | 33 ++++++++++++++++++++++
 sysutils/polkit/pkg-plist                          |  3 ++
 7 files changed, 85 insertions(+), 60 deletions(-)

diff --git a/sysutils/polkit/Makefile b/sysutils/polkit/Makefile
index 4252c990f7f2..60185ef5d60e 100644
--- a/sysutils/polkit/Makefile
+++ b/sysutils/polkit/Makefile
@@ -1,12 +1,8 @@
 PORTNAME=	polkit
-PORTVERSION=	0.120
-PORTREVISION=	2
+PORTVERSION=	122
 CATEGORIES=	sysutils gnome
-MASTER_SITES=	https://www.freedesktop.org/software/polkit/releases/
-
-PATCH_SITES=	https://gitlab.freedesktop.org/${PORTNAME}/${PORTNAME}/-/commit/
-PATCHFILES+=	e7f3d9e8341d.patch:-p1 # https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/99
-PATCHFILES+=	a2bf5c9c83b6.patch:-p1 # https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/104 (CVE-2021-4034)
+MASTER_SITES=	https://www.freedesktop.org/software/polkit/releases/ \
+		https://gitlab.freedesktop.org/${PORTNAME}/${PORTNAME}/-/archive/${PORTVERSION}/
 
 MAINTAINER=	desktop@FreeBSD.org
 COMMENT=	Framework for controlling access to system-wide components
@@ -16,13 +12,12 @@ LICENSE=	GPLv2
 LICENSE_FILE=	${WRKSRC}/COPYING
 
 LIB_DEPENDS=	libexpat.so:textproc/expat2 \
-		libdbus-1.so:devel/dbus \
-		libmozjs-91.so:lang/spidermonkey91
+		libdbus-1.so:devel/dbus
 
 USERS=		polkitd
 GROUPS=		polkitd
 
-USES=		compiler:c++11-lib cpe gettext gnome libtool localbase meson \
+USES=		compiler:c++17-lang cpe gettext gnome libtool localbase meson \
 		pathfix pkgconfig shebangfix
 USE_GNOME=	glib20 intltool introspection:build
 SHEBANG_FILES=	${WRKSRC}/src/polkitbackend/toarray.pl
@@ -38,9 +33,21 @@ MESON_ARGS=	-Dpam_include=system \
 		-Dlocalstatedir=/var \
 		-Dgtk_doc=false
 
-INSTALL_TARGET=	install-strip
-
 OPTIONS_DEFINE=		MANPAGES
+OPTIONS_DEFAULT=	DUKTAPE
+
+OPTIONS_SINGLE=		JS
+OPTIONS_SINGLE_JS=	DUKTAPE SPIDERMONKEY
+
+JS_DESC=		JavaScript engines
+DUKTAPE_DESC=		Duktape JavaScript backend
+SPIDERMONKEY_DESC=	SpiderMonkey JavaScript backend
+
+DUKTAPE_LIB_DEPENDS=	libduktape.so:lang/duktape-lib
+DUKTAPE_MESON_ON=	-Djs_engine='duktape'
+
+SPIDERMONKEY_LIB_DEPENDS=	libmozjs-102.so:lang/spidermonkey102
+SPIDERMONKEY_MESON_ON=		-Djs_engine='mozjs'
 
 MANPAGES_BUILD_DEPENDS=	docbook-sgml>=4.5:textproc/docbook-sgml \
 			docbook-xsl>=1.76:textproc/docbook-xsl
diff --git a/sysutils/polkit/distinfo b/sysutils/polkit/distinfo
index 839b6c439a75..66975b24dc9b 100644
--- a/sysutils/polkit/distinfo
+++ b/sysutils/polkit/distinfo
@@ -1,7 +1,3 @@
-TIMESTAMP = 1656189343
-SHA256 (polkit-0.120.tar.gz) = ee7a599a853117bf273548725719fa92fabd2f136915c7a4906cee98567aee03
-SIZE (polkit-0.120.tar.gz) = 1626659
-SHA256 (e7f3d9e8341d.patch) = 9a84b59d38b3f86c70c5fc3a28cbfe8d7a22cf190eb20ff433f7f53f5ff73a9a
-SIZE (e7f3d9e8341d.patch) = 1201
-SHA256 (a2bf5c9c83b6.patch) = 5930a48bf4262a7c89f8737a1a5a648bd41cfdb6476dcca1140cba6555b67d2c
-SIZE (a2bf5c9c83b6.patch) = 2070
+TIMESTAMP = 1666804675
+SHA256 (polkit-122.tar.gz) = 0d69656d60800835c3d7d1f0a8362b32e1ae3ace2875a35bb624296fc52d5dc4
+SIZE (polkit-122.tar.gz) = 744767
diff --git a/sysutils/polkit/files/patch-meson.build b/sysutils/polkit/files/patch-meson.build
index 260fe5aafd82..74e14902a24e 100644
--- a/sysutils/polkit/files/patch-meson.build
+++ b/sysutils/polkit/files/patch-meson.build
@@ -1,11 +1,11 @@
---- meson.build.orig	2021-09-29 19:16:29 UTC
+--- meson.build.orig	2022-10-26 12:12:24 UTC
 +++ meson.build
-@@ -133,10 +133,10 @@ assert(cc.has_function('XML_ParserCreate', dependencie
- 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')
+@@ -154,10 +154,11 @@ if js_engine == 'duktape'
+   config_h.set('HAVE_' + func.to_upper(), cc.has_function(func, prefix : '#include <pthread.h>'))
+ elif js_engine == 'mozjs'
+   js_dep = dependency('mozjs-102')
++  config_h.set('__BSD_VISIBLE', 1)
+ endif
  
  dbus_dep = dependency('dbus-1', required: false)
 -dbus_policydir = pk_prefix / pk_datadir / 'dbus-1/system.d'
@@ -13,7 +13,7 @@
  if dbus_dep.found()
    dbus_system_bus_services_dir = dbus_dep.get_pkgconfig_variable('system_bus_services_dir', define_variable: ['datadir', pk_prefix / pk_datadir])
  else
-@@ -329,15 +329,6 @@ configure_file(
+@@ -358,15 +359,6 @@ endif
  configure_file(
    output: 'config.h',
    configuration: config_h,
diff --git a/sysutils/polkit/files/patch-src_polkitbackend_meson.build b/sysutils/polkit/files/patch-src_polkitbackend_meson.build
new file mode 100644
index 000000000000..7190e505d15c
--- /dev/null
+++ b/sysutils/polkit/files/patch-src_polkitbackend_meson.build
@@ -0,0 +1,19 @@
+--- src/polkitbackend/meson.build.orig	2022-10-26 12:12:24 UTC
++++ src/polkitbackend/meson.build
+@@ -30,7 +30,6 @@ c_flags = [
+   '-DPACKAGE_DATA_DIR="@0@"'.format(pk_prefix / pk_datadir),
+   '-DPACKAGE_SYSCONF_DIR="@0@"'.format(pk_prefix / pk_sysconfdir),
+   '-D_XOPEN_SOURCE=700',
+-  '-D_GNU_SOURCE=1',
+ ]
+ 
+ if js_engine == 'duktape'
+@@ -61,7 +60,7 @@ libpolkit_backend = static_library(
+ 
+ install_data(
+   '50-default.rules',
+-  install_dir: pk_pkgdatadir / 'rules.d',
++  install_dir: pk_pkgsysconfdir / 'rules.d',
+ )
+ 
+ program = 'polkitd'
diff --git a/sysutils/polkit/files/patch-src_polkitbackend_polkitbackendjsauthority.cpp b/sysutils/polkit/files/patch-src_polkitbackend_polkitbackendjsauthority.cpp
deleted file mode 100644
index a8f47c895e8f..000000000000
--- a/sysutils/polkit/files/patch-src_polkitbackend_polkitbackendjsauthority.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
---- src/polkitbackend/polkitbackendjsauthority.cpp.orig	2022-06-25 20:41:05 UTC
-+++ 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);
- }
-@@ -665,8 +671,6 @@ polkit_backend_js_authority_class_init (PolkitBackendJ
- 
- 
-   g_type_class_add_private (klass, sizeof (PolkitBackendJsAuthorityPrivate));
--
--  JS_Init ();
- }
- 
- /* ---------------------------------------------------------------------------------------------------- */
diff --git a/sysutils/polkit/files/patch-src_programs_pkexec.c b/sysutils/polkit/files/patch-src_programs_pkexec.c
new file mode 100644
index 000000000000..47fed9033d8a
--- /dev/null
+++ b/sysutils/polkit/files/patch-src_programs_pkexec.c
@@ -0,0 +1,33 @@
+--- src/programs/pkexec.c.orig	2022-07-11 08:46:06 UTC
++++ src/programs/pkexec.c
+@@ -37,6 +37,11 @@
+ #include <sys/prctl.h>
+ #endif
+ 
++#ifdef __FreeBSD__
++#include <signal.h>
++#include <sys/procctl.h>
++#endif
++
+ #include <glib/gi18n.h>
+ 
+ #ifdef POLKIT_AUTHFW_PAM
+@@ -729,10 +734,17 @@ main (int argc, char *argv[])
+     }
+ 
+   /* make sure we are nuked if the parent process dies */
+-#ifdef __linux__
++#if defined(__linux__)
+   if (prctl (PR_SET_PDEATHSIG, SIGTERM) != 0)
+     {
+       g_printerr ("prctl(PR_SET_PDEATHSIG, SIGTERM) failed: %s\n", g_strerror (errno));
++      goto out;
++    }
++#elif defined(__FreeBSD__)
++  int _sig = SIGTERM;
++  if (procctl (P_PID, 0, PROC_PDEATHSIG_CTL, &_sig) != 0)
++    {
++      g_printerr ("procctl(2) failed: %s\n", g_strerror (errno));
+       goto out;
+     }
+ #else
diff --git a/sysutils/polkit/pkg-plist b/sysutils/polkit/pkg-plist
index f6ad72a65d8e..c1a23766792f 100644
--- a/sysutils/polkit/pkg-plist
+++ b/sysutils/polkit/pkg-plist
@@ -63,6 +63,8 @@ share/locale/hr/LC_MESSAGES/polkit-1.mo
 share/locale/hu/LC_MESSAGES/polkit-1.mo
 share/locale/id/LC_MESSAGES/polkit-1.mo
 share/locale/it/LC_MESSAGES/polkit-1.mo
+share/locale/ka/LC_MESSAGES/polkit-1.mo
+share/locale/nl/LC_MESSAGES/polkit-1.mo
 share/locale/nn/LC_MESSAGES/polkit-1.mo
 share/locale/pl/LC_MESSAGES/polkit-1.mo
 share/locale/pt/LC_MESSAGES/polkit-1.mo
@@ -75,6 +77,7 @@ share/locale/uk/LC_MESSAGES/polkit-1.mo
 share/locale/zh_CN/LC_MESSAGES/polkit-1.mo
 share/locale/zh_TW/LC_MESSAGES/polkit-1.mo
 share/polkit-1/actions/org.freedesktop.policykit.policy
+share/polkit-1/policyconfig-1.dtd
 @dir(polkitd,,700) etc/polkit-1/rules.d
 @dir(polkitd,,700) share/polkit-1/rules.d
 @dir etc/polkit-1/localauthority/90-mandatory.d