rpms/hal/F-8 hal-0.5.10-ck-acl.patch, NONE, 1.1 .cvsignore, 1.51, 1.52 hal.spec, 1.138, 1.139
Lubomir Kundrak (lkundrak)
fedora-extras-commits at redhat.com
Tue Feb 26 08:30:12 UTC 2008
Author: lkundrak
Update of /cvs/pkgs/rpms/hal/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19063/F-8
Modified Files:
.cvsignore hal.spec
Added Files:
hal-0.5.10-ck-acl.patch
Log Message:
Call ConsoleKit for session/seat enumeration in -acl-tool (#384271)
hal-0.5.10-ck-acl.patch:
--- NEW FILE hal-0.5.10-ck-acl.patch ---
diff -urp hal-0.5.10.orig/tools/hal-acl-tool.c hal-0.5.10.fixed/tools/hal-acl-tool.c
--- hal-0.5.10.orig/tools/hal-acl-tool.c 2007-09-25 21:19:25.000000000 +0200
+++ hal-0.5.10.fixed/tools/hal-acl-tool.c 2008-02-26 09:18:16.000000000 +0100
@@ -3,6 +3,8 @@
* hal-acl-tool.c : Manage ACL's on device nodes
*
* Copyright (C) 2007 David Zeuthen, <david at fubar.dk>
+ * Copyright (C) 2006 William Jon McCann <mccann at jhu.edu>
+ * Copyright (C) 2008 Lubomir Kundrak <lkundrak at redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +37,20 @@
#include <libhal.h>
#include <polkit/polkit.h>
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#define CK_NAME "org.freedesktop.ConsoleKit"
+#define CK_PATH "/org/freedesktop/ConsoleKit"
+#define CK_INTERFACE "org.freedesktop.ConsoleKit"
+
+#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager"
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
+#define CK_SEAT_INTERFACE "org.freedesktop.ConsoleKit.Seat"
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
+
/* How this works (or "An introduction to this code")
*
* - all ACL's granted by this tool is kept in /var/lib/hal/acl-list
@@ -69,11 +85,6 @@
*
* Optimizations
*
- * - the HAL daemon exports the ConsoleKit seat + session
- * configuration in CK_* environment variables. So we don't
- * need to do IPC to the ConsoleKit daemon to learn about
- * about seats and sessions.
- *
* - special casing for --add-device and --remove-device; here we
* don't need roundtrips to the HAL daemon. Only --reconfigure
* requires that. As such no IPC is required for these cases
@@ -442,6 +453,53 @@ typedef void (*SeatSessionVisitor) (cons
gboolean session_is_active,
gpointer user_data);
+static gboolean
+get_int (DBusGProxy *proxy,
+ const char *method,
+ int *val)
+{
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (proxy,
+ method,
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INT, val,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("%s failed: %s", method, error->message);
+ g_error_free (error);
+ }
+
+ return res;
+}
+
+static gboolean
+get_boolean (DBusGProxy *proxy,
+ const char *method,
+ gboolean *value)
+{
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (proxy,
+ method,
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_BOOLEAN, value,
+ G_TYPE_INVALID);
+ if (! res) {
+ g_warning ("%s failed: %s", method, error->message);
+ g_error_free (error);
+ }
+
+ return res;
+}
+
+
/* Visits all seats and sessions.
*
* NOTE: when a seat is visited session_id will be NULL and session_uid, session_is_active are undefined.
@@ -449,95 +507,131 @@ typedef void (*SeatSessionVisitor) (cons
static gboolean
visit_seats_and_sessions (SeatSessionVisitor visitor_cb, gpointer user_data)
{
- int i;
- int j;
- char *s;
- char *p;
- char **seats;
- gboolean ret;
+ unsigned int i;
+ gboolean ret;
- ret = FALSE;
+ DBusGConnection *connection;
+ GError *error = NULL;
- if ((s = getenv ("CK_SEATS")) == NULL) {
- printf ("%d: CK_SEATS is not set!\n", getpid());
- goto out;
- }
- seats = g_strsplit (s, "\t", 0);
- /* for all seats */
- for (i = 0; seats[i] != NULL; i++) {
- char *seat = seats[i];
+ DBusGProxy *sproxy;
+ GPtrArray *seats;
+
+ g_type_init ();
+
+ connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+
+ if (connection == NULL) {
+ g_message ("Failed to connect to the D-Bus daemon: %s", error->message);
+ exit (1);
+ }
+
+ sproxy = dbus_g_proxy_new_for_name (connection,
+ CK_NAME,
+ CK_MANAGER_PATH,
+ CK_MANAGER_INTERFACE);
+
+ if (sproxy == NULL) {
+ g_message ("Failed to create a proxy for a D-Bus interface");
+ exit (1);
+ }
+
+ ret = dbus_g_proxy_call (sproxy,
+ "GetSeats",
+ &error,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+ &seats,
+ G_TYPE_INVALID);
+
+ if (! ret) {
+ g_warning ("Failed to get list of seats: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+
+ /* for all seats */
+ for (i = 0; i < seats->len; i++) {
+ unsigned int j;
char *seat_id;
- char **sessions;
- int num_sessions_on_seat;
+ GPtrArray *sessions = NULL;
+ DBusGProxy *ssproxy;
- p = g_strdup_printf ("CK_SEAT_%s", seat);
- if ((s = getenv (p)) == NULL) {
- printf ("%d: CK_SEAT_%s is not set!\n", getpid(), seat);
- g_free (p);
- goto out;
- }
- g_free (p);
- sessions = g_strsplit (s, "\t", 0);
- num_sessions_on_seat = g_strv_length (sessions);
-
- seat_id = g_strdup_printf ("/org/freedesktop/ConsoleKit/%s", seat);
- visitor_cb (seat_id, num_sessions_on_seat, NULL, 0, FALSE, FALSE, user_data);
-
- /* for all sessions on seat */
- for (j = 0; sessions[j] != NULL; j++) {
- char *session = sessions[j];
+ seat_id = g_ptr_array_index (seats, i);
+
+ ssproxy = dbus_g_proxy_new_for_name (connection,
+ CK_NAME,
+ seat_id,
+ CK_SEAT_INTERFACE);
+
+ if (ssproxy == NULL) {
+ g_message ("Failed to create a proxy for a D-Bus interface");
+ exit (1);
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (ssproxy,
+ "GetSessions",
+ &error,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH),
+ &sessions,
+ G_TYPE_INVALID);
+
+ if (! ret) {
+ g_warning ("Failed to get list of sessions for %s: %s", seat_id, error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+
+ visitor_cb (seat_id, sessions->len, NULL, 0, FALSE, FALSE, user_data);
+
+ /* for all sessions on seat */
+ for (j = 0; j < sessions->len; j++) {
char *session_id;
- gboolean session_is_local;
- gboolean session_is_active;
- uid_t session_uid;
- char *endptr;
-
- p = g_strdup_printf ("CK_SESSION_IS_LOCAL_%s", session);
- if ((s = getenv (p)) == NULL) {
- printf ("%d: CK_SESSION_IS_LOCAL_%s is not set!\n", getpid(), session);
- g_free (p);
- goto out;
- }
- g_free (p);
- session_is_local = (strcmp (s, "true") == 0);
+ DBusGProxy *nameproxy;
- p = g_strdup_printf ("CK_SESSION_IS_ACTIVE_%s", session);
- if ((s = getenv (p)) == NULL) {
- printf ("%d: CK_SESSION_IS_ACTIVE_%s is not set!\n", getpid(), session);
- g_free (p);
- goto out;
- }
- g_free (p);
- session_is_active = (strcmp (s, "true") == 0);
+ gboolean session_is_local;
+ gboolean session_is_active;
+ uid_t session_uid;
+
+ session_id = g_ptr_array_index (sessions, j);
+
+ nameproxy = dbus_g_proxy_new_for_name (connection,
+ CK_NAME,
+ session_id,
+ CK_SESSION_INTERFACE);
+ if (nameproxy == NULL) {
+ g_message ("Failed to create a proxy for a D-Bus interface");
+ exit (1);
+ }
- p = g_strdup_printf ("CK_SESSION_UID_%s", session);
- if ((s = getenv (p)) == NULL) {
- printf ("%d: CK_SESSION_UID_%s is not set!\n", getpid(), session);
- g_free (p);
- goto out;
- }
- g_free (p);
- session_uid = strtol (s, &endptr, 10);
- if (*endptr != '\0') {
- printf ("%d: CK_SESSION_UID_%s set to '%s' is malformed!\n", getpid(), session, s);
- goto out;
- }
+ get_int (nameproxy, "GetUnixUser", (int *)&session_uid);
+ get_boolean (nameproxy, "IsActive", &session_is_active);
+ get_boolean (nameproxy, "IsLocal", &session_is_local);
- session_id = g_strdup_printf ("/org/freedesktop/ConsoleKit/%s", session);
- visitor_cb (seat_id, num_sessions_on_seat,
- session_id, session_uid, session_is_local, session_is_active, user_data);
+ visitor_cb (seat_id, sessions->len,
+ session_id, session_uid, session_is_local, session_is_active, user_data);
+ g_object_unref (nameproxy);
g_free (session_id);
}
- g_strfreev (sessions);
+
+ g_ptr_array_free (sessions, TRUE);
+ g_object_unref (ssproxy);
g_free (seat_id);
}
- g_strfreev (seats);
ret = TRUE;
out:
+ if (seats != NULL)
+ g_ptr_array_free (seats, TRUE);
+ if (sproxy != NULL)
+ g_object_unref (sproxy);
+
return ret;
}
Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/hal/F-8/.cvsignore,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- .cvsignore 11 Oct 2007 22:52:59 -0000 1.51
+++ .cvsignore 26 Feb 2008 08:29:34 -0000 1.52
@@ -1,46 +1 @@
-hal-0.2.97.cvs20040901.tar.gz
-hal-0.2.98.tar.gz
-hal-0.2.98.cvs20040923.tar.gz
-hal-0.2.98.cvs20040927.tar.gz
-hal-0.2.98.cvs20040929.tar.gz
-hal-0.4.0.tar.gz
-hal-0.4.2.cvs20041210.tar.gz
-hal-0.4.5.tar.gz
-hal-0.4.6.tar.gz
-hal-0.4.7.tar.gz
-hal-0.5.0.tar.gz
-hal-0.5.0.cvs20050310.tar.gz
-hal-0.5.0.cvs20050318.tar.gz
-hal-0.5.0.cvs20050322.tar.gz
-hal-0.5.0.cvs20050322b.tar.gz
-hal-0.5.0.cvs20050404.tar.gz
-hal-0.5.0.cvs20050404b.tar.gz
-hal-0.5.1.tar.gz
-hal-0.5.2.tar.gz
-hal-0.5.3.tar.gz
-hal-0.5.4.tar.gz
-hal-0.5.4.cvs20051111.tar.gz
-hal-0.5.5.1.tar.gz
-hal-0.5.5.1.cvs20060105.tar.gz
-hal-0.5.5.1.cvs20060109.tar.gz
-hal-0.5.6.tar.gz
-hal-0.5.5.1.cvs20060111.tar.gz
-hal-0.5.7-0.cvs20060213.tar.gz
-hal-0.5.7.tar.gz
-hal-0.5.7.1.tar.gz
-hal-0.5.8.1.tar.gz
-hal-0.5.9.git20070206.tar.gz
-hal-info-20070206.tar.gz
-hal-0.5.9.git20070218.tar.gz
-hal-info-20070304.tar.gz
-hal-0.5.9.git20070304.tar.gz
-hal-info-20070326.tar.gz
-hal-0.5.9.git20070326.tar.gz
-hal-info-20070328.tar.gz
-hal-0.5.9.git20070401.tar.gz
-hal-0.5.9.tar.gz
-hal-info-20070402.tar.gz
-hal-0.5.10rc1.tar.gz
-hal-0.5.10rc2.tar.gz
-hal-0.5.10.git20070925.tar.gz
hal-0.5.10.tar.gz
Index: hal.spec
===================================================================
RCS file: /cvs/pkgs/rpms/hal/F-8/hal.spec,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -r1.138 -r1.139
--- hal.spec 11 Oct 2007 22:52:59 -0000 1.138
+++ hal.spec 26 Feb 2008 08:29:34 -0000 1.139
@@ -26,9 +26,10 @@
Summary: Hardware Abstraction Layer
Name: hal
Version: 0.5.10
-Release: 1%{?dist}
+Release: 1%{?dist}.1
URL: http://www.freedesktop.org/Software/hal
Source0: http://hal.freedesktop.org/releases/%{name}-%{version}.tar.gz
+Patch0: hal-0.5.10-ck-acl.patch
License: AFL/GPL
Group: System Environment/Libraries
@@ -120,6 +121,7 @@
%prep
%setup -q
+%patch0 -p1 -b .ck-acl
%build
%configure --enable-docbook-docs --docdir=%{_datadir}/doc/%{name}-%{version} --with-os-type=redhat --enable-console-kit --enable-policy-kit --enable-acl-management --enable-umount-helper --enable-acpi-ibm --enable-acpi-toshiba --with-eject=/usr/sbin/eject
@@ -232,6 +234,9 @@
%{_datadir}/gtk-doc/html/libhal-storage/*
%changelog
+* Tue Feb 26 2008 Lubomir Kundrak <lkundrak at redhat.com> - 0.5.10-1.1
+- Call ConsoleKit for session/seat enumeration in -acl-tool (#384271)
+
* Thu Oct 11 2007 David Zeuthen <davidz at redhat.com> - 0.5.10-1%{?dist}
- Update to latest upstream release
More information about the fedora-extras-commits
mailing list