Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Aug 2023 07:56:00 GMT
From:      Gleb Popov <arrowd@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 12b84b980b45 - main - sysutils/polkit: Adapt to ConsoleKit changes.
Message-ID:  <202308310756.37V7u0Ti083068@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by arrowd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=12b84b980b45573c93be5382a274dbe872a1eb73

commit 12b84b980b45573c93be5382a274dbe872a1eb73
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2023-08-31 07:55:34 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2023-08-31 07:55:34 +0000

    sysutils/polkit: Adapt to ConsoleKit changes.
    
    Sponsored by:   Serenity Cybersecurity, LLC
---
 UPDATING                                           |  8 ++++
 sysutils/polkit/Makefile                           |  1 +
 .../files/patch-src_polkit_polkitunixsession.c     | 53 ++++++++++++++++++++++
 ...src_polkitbackend_polkitbackendsessionmonitor.c | 45 ++++++++++++++++++
 4 files changed, 107 insertions(+)

diff --git a/UPDATING b/UPDATING
index 428c7169615b..7ded41161f91 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,14 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20230822:
+  AUTHOR: arrowd@FreeBSD.org
+  AFFECTS: users of sysutils/polkit together with sysutils/consolekit2
+
+  ConsoleKit2 has grown some logind1 compatibility which resulted in breaking
+  changes in its API. One of its consumers, Polkit, is patched to handle it,
+  so make sure to update both ports simultaneously.
+
 20230822:
   AUTHOR: leres@FreeBSD.org
   AFFECTS: users of security/zeek
diff --git a/sysutils/polkit/Makefile b/sysutils/polkit/Makefile
index ef09a86ecf56..5c8cb59f7691 100644
--- a/sysutils/polkit/Makefile
+++ b/sysutils/polkit/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	polkit
 DISTVERSION=	123
+PORTREVISION=	1
 CATEGORIES=	sysutils gnome
 
 MAINTAINER=	desktop@FreeBSD.org
diff --git a/sysutils/polkit/files/patch-src_polkit_polkitunixsession.c b/sysutils/polkit/files/patch-src_polkit_polkitunixsession.c
new file mode 100644
index 000000000000..6367e0e5c6b6
--- /dev/null
+++ b/sysutils/polkit/files/patch-src_polkit_polkitunixsession.c
@@ -0,0 +1,53 @@
+FreeBSD ConsoleKit is patched to return proper IDs instead D-Bus paths, so
+adapt Polkit to this case.
+
+--- src/polkit/polkitunixsession.c.orig	2023-07-28 12:34:38 UTC
++++ src/polkit/polkitunixsession.c
+@@ -364,6 +364,7 @@ polkit_unix_session_exists_sync (PolkitSubject   *subj
+   PolkitUnixSession *session = POLKIT_UNIX_SESSION (subject);
+   GDBusConnection *connection;
+   GVariant *result;
++  const gchar* session_path = NULL;
+   gboolean ret;
+ 
+   ret = FALSE;
+@@ -372,9 +373,12 @@ polkit_unix_session_exists_sync (PolkitSubject   *subj
+   if (connection == NULL)
+     goto out;
+ 
++  if (strncmp (session->session_id, "/org/freedesktop/ConsoleKit", strlen ("/org/freedesktop/ConsoleKit") ))
++    session_path = g_build_path("/", "/org/freedesktop/ConsoleKit", session->session_id, NULL);
++
+   result = g_dbus_connection_call_sync (connection,
+                                         "org.freedesktop.ConsoleKit",           /* name */
+-                                        session->session_id,                    /* object path */
++                                        session_path ? session_path : session->session_id,                    /* object path */
+                                         "org.freedesktop.ConsoleKit.Session",   /* interface name */
+                                         "GetUser",                              /* method */
+                                         NULL, /* parameters */
+@@ -383,6 +387,7 @@ polkit_unix_session_exists_sync (PolkitSubject   *subj
+                                         -1,
+                                         cancellable,
+                                         error);
++  g_free (session_path);
+   if (result == NULL)
+     goto out;
+ 
+@@ -472,6 +477,7 @@ polkit_unix_session_initable_init (GInitable     *init
+   PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable);
+   GDBusConnection *connection;
+   GVariant *result;
++  const gchar* session_path;
+   gboolean ret;
+ 
+   connection = NULL;
+@@ -502,7 +508,8 @@ polkit_unix_session_initable_init (GInitable     *init
+   if (result == NULL)
+     goto out;
+ 
+-  g_variant_get (result, "(o)", &session->session_id);
++  g_variant_get (result, "(&o)", &session_path);
++  session->session_id = g_path_get_basename (session_path);
+   g_variant_unref (result);
+ 
+   ret = TRUE;
diff --git a/sysutils/polkit/files/patch-src_polkitbackend_polkitbackendsessionmonitor.c b/sysutils/polkit/files/patch-src_polkitbackend_polkitbackendsessionmonitor.c
new file mode 100644
index 000000000000..216f00b94e58
--- /dev/null
+++ b/sysutils/polkit/files/patch-src_polkitbackend_polkitbackendsessionmonitor.c
@@ -0,0 +1,45 @@
+FreeBSD ConsoleKit is patched to return proper IDs instead D-Bus paths, so
+adapt Polkit to this case.
+
+--- src/polkitbackend/polkitbackendsessionmonitor.c.orig	2023-07-28 12:34:38 UTC
++++ src/polkitbackend/polkitbackendsessionmonitor.c
+@@ -385,7 +385,7 @@ polkit_backend_session_monitor_get_session_for_subject
+ 
+   if (POLKIT_IS_UNIX_PROCESS (subject))
+     {
+-      const gchar *session_id;
++      const gchar *session_path, *session_id;
+       GVariant *result;
+       result = g_dbus_connection_call_sync (monitor->system_bus,
+                                             "org.freedesktop.ConsoleKit",
+@@ -400,14 +400,16 @@ polkit_backend_session_monitor_get_session_for_subject
+                                             error);
+       if (result == NULL)
+         goto out;
+-      g_variant_get (result, "(&o)", &session_id);
++      g_variant_get (result, "(&o)", &session_path);
++      session_id = g_path_get_basename (session_path);
+       session = polkit_unix_session_new (session_id);
++      g_free (session_id);
+       g_variant_unref (result);
+     }
+   else if (POLKIT_IS_SYSTEM_BUS_NAME (subject))
+     {
+       guint32 pid;
+-      const gchar *session_id;
++      const gchar *session_path, *session_id;
+       GVariant *result;
+ 
+       result = g_dbus_connection_call_sync (monitor->system_bus,
+@@ -439,8 +441,10 @@ polkit_backend_session_monitor_get_session_for_subject
+                                             error);
+       if (result == NULL)
+         goto out;
+-      g_variant_get (result, "(&o)", &session_id);
++      g_variant_get (result, "(&o)", &session_path);
++      session_id = g_path_get_basename (session_path);
+       session = polkit_unix_session_new (session_id);
++      g_free (session_id);
+       g_variant_unref (result);
+     }
+   else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308310756.37V7u0Ti083068>