hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Sun Apr 15 20:12:16 PDT 2007


 doc/man/hal-is-caller-privileged.1.in          |    3 --
 hald/access-check.c                            |   22 ++-------------
 hald/access-check.h                            |    1 
 hald/hald_dbus.c                               |   35 ++-----------------------
 hald/linux/addons/addon-cpufreq.c              |    1 
 hald/linux/addons/addon-dell-backlight.cpp     |    1 
 hald/linux/addons/addon-macbookpro-backlight.c |   14 ++++------
 libhal/libhal.c                                |   16 -----------
 libhal/libhal.h                                |    1 
 tools/hal-acl-tool.c                           |    9 ++----
 tools/hal-is-caller-privileged.c               |   29 --------------------
 tools/hal-storage-mount.c                      |    1 
 tools/hal-storage-shared.c                     |    2 -
 13 files changed, 17 insertions(+), 118 deletions(-)

New commits:
diff-tree f2b9797c440aeafafffb056a3872ecf3ba014a15 (from b127bfc1e6d03a380d56d48ee189058e84c694f0)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun Apr 15 23:12:17 2007 -0400

    remove use of "action parameters" now that they're going in PolicyKit

diff --git a/doc/man/hal-is-caller-privileged.1.in b/doc/man/hal-is-caller-privileged.1.in
index 8aeddbe..e76de93 100644
--- a/doc/man/hal-is-caller-privileged.1.in
+++ b/doc/man/hal-is-caller-privileged.1.in
@@ -35,9 +35,6 @@ The UDI (\fIUnique Device Identifier\fP)
 .I "--action"
 PolicyKit action to check for.
 .TP
-.I "--action-param <key>=<value>"
-Append parameters to action. This option may occur multiple times.
-.TP
 .I "--caller"
 The unique D-Bus name on the system bus of the caller.
 .TP
diff --git a/hald/access-check.c b/hald/access-check.c
index 2051b76..8cd9380 100644
--- a/hald/access-check.c
+++ b/hald/access-check.c
@@ -208,7 +208,6 @@ out:
  * @cit: the CITracker object
  * @device: the device to check for
  * @action: the PolicyKit action to check for
- * @action_params: parameters (a #NULL terminated list of key/value pairs) to the action or #NULL
  * @caller_unique_sysbus_name: The unique system bus connection
  * name (e.g. ":1.43") of the caller
  * @polkit_result_out: where to store the #PolicyKitResult return 
@@ -248,12 +247,10 @@ gboolean
 access_check_caller_have_access_to_device (CITracker   *cit, 
                                            HalDevice   *device, 
                                            const char  *action, 
-                                           const char **action_params,
                                            const char  *caller_unique_sysbus_name,
                                            int         *polkit_result_out)
 #ifdef HAVE_CONKIT
 {
-        int n;
         gboolean ret;
         CICallerInfo *ci;
 #ifdef HAVE_POLKIT
@@ -301,9 +298,6 @@ access_check_caller_have_access_to_devic
 #ifdef HAVE_POLKIT
         pk_action = libpolkit_action_new ();
         libpolkit_action_set_action_id (pk_action, action);
-        for (n = 0; action_params[n] != NULL; n += 2) {
-                libpolkit_action_set_param (pk_action, action_params[n], action_params[n+1]);
-        }
         
         pk_caller = get_pk_caller_from_ci_tracker (cit, caller_unique_sysbus_name);
         if (pk_caller == NULL)
@@ -399,9 +393,6 @@ access_check_caller_locked_out (CITracke
         HalDevice *computer;
         gboolean is_locked;
         gboolean is_locked_by_self;
-        const char *action_params[3] = {"interface", "", NULL};
-
-        action_params[1] = interface_name;
 
         global_lock_name = NULL;
         holders = NULL;
@@ -442,7 +433,7 @@ access_check_caller_locked_out (CITracke
                         if (strcmp (global_holders[n], caller_unique_sysbus_name) == 0) {
                                 /* we are holding the global lock... */
                                 if (access_check_caller_have_access_to_device (
-                                            cit, device, "hal-lock", action_params, global_holders[n], NULL)) {
+                                            cit, device, "hal-lock", global_holders[n], NULL)) {
                                         /* only applies if the caller can access the device... */
                                         is_locked_by_self = TRUE;
                                         /* this is good enough; we are holding the lock ourselves */
@@ -454,7 +445,7 @@ access_check_caller_locked_out (CITracke
                                  * actually have access to the device...
                                  */
                                 if (access_check_caller_have_access_to_device (
-                                            cit, device, "hal-lock", action_params, global_holders[n], NULL)) {
+                                            cit, device, "hal-lock", global_holders[n], NULL)) {
                                         /* They certainly do. Mark as locked. */
                                         is_locked = TRUE;
                                 }
@@ -508,12 +499,6 @@ access_check_locked_by_others (CITracker
         char **holders;
         char **global_holders;
         HalDevice *computer;
-        char *priv;
-        const char *action_params[3] = {"interface", "", NULL};
-
-        action_params[1] = interface_name;
-
-        priv = g_strdup_printf ("hal-lock:%s", interface_name);
 
         global_lock_name = NULL;
         holders = NULL;
@@ -547,7 +532,7 @@ access_check_locked_by_others (CITracker
                             strcmp (global_holders[n], caller_unique_sysbus_name) != 0) {
                                 /* someone else is holding the global lock... */
                                 if (access_check_caller_have_access_to_device (
-                                            cit, device, "hal-lock", action_params, global_holders[n], NULL)) {
+                                            cit, device, "hal-lock", global_holders[n], NULL)) {
                                         /* ... and they can can access the device */
                                         goto out;
                                 }
@@ -562,7 +547,6 @@ out:
         g_strfreev (global_holders);
         g_strfreev (holders);
         g_free (global_lock_name);
-        g_free (priv);
         return ret;
 }
 
diff --git a/hald/access-check.h b/hald/access-check.h
index 2b9a896..f4303fc 100644
--- a/hald/access-check.h
+++ b/hald/access-check.h
@@ -36,7 +36,6 @@ gboolean access_check_message_caller_is_
 gboolean access_check_caller_have_access_to_device  (CITracker   *cit,
                                                      HalDevice   *device,
                                                      const char  *action,
-                                                     const char **action_params,
                                                      const char  *caller_unique_sysbus_name,
                                                      int         *polkit_result_out);
 gboolean access_check_caller_locked_out             (CITracker   *cit,
diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index 3db89e0..453e9f6 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -2052,10 +2052,7 @@ device_acquire_interface_lock (DBusConne
 	}
 
         if (!local_interface) {
-                const char *action_params[3] = {"interface", "", NULL};
-                action_params[1] = interface_name;
-                if (!access_check_caller_have_access_to_device (ci_tracker, d, "hal-lock", 
-                                                                action_params, sender, NULL)) {
+                if (!access_check_caller_have_access_to_device (ci_tracker, d, "hal-lock", sender, NULL)) {
                         raise_permission_denied (connection, message, "AcquireInterfaceLock: no access to device");
                         return DBUS_HANDLER_RESULT_HANDLED;
                 }
@@ -2203,8 +2200,6 @@ device_is_caller_privileged (DBusConnect
         int polkit_result;
         const char *result;
         DBusMessageIter iter;
-        DBusMessageIter array_iter;
-        GPtrArray *params;
 
 	HAL_TRACE (("entering"));
 
@@ -2221,26 +2216,15 @@ device_is_caller_privileged (DBusConnect
 
 	sender = dbus_message_get_sender (message);
 
-        if (strcmp (dbus_message_get_signature (message), "sass") != 0) {
+        if (strcmp (dbus_message_get_signature (message), "ss") != 0) {
  		raise_syntax (connection, message, "IsCallerPrivileged");
 		return DBUS_HANDLER_RESULT_HANDLED;
         }
 
-        params = g_ptr_array_new ();
-
 	dbus_error_init (&error);
         dbus_message_iter_init (message, &iter);
         dbus_message_iter_get_basic (&iter, &action);
         dbus_message_iter_next (&iter);
-        dbus_message_iter_recurse (&iter, &array_iter);
-        while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_STRING) {
-                const char *param;
-                dbus_message_iter_get_basic (&array_iter, &param);
-                g_ptr_array_add (params, g_strdup (param));
-                dbus_message_iter_next (&array_iter);
-        }
-        g_ptr_array_add (params, NULL);
-        dbus_message_iter_next (&iter);
         dbus_message_iter_get_basic (&iter, &caller_sysbus_name);
 
         /* check whether we want to answer this question... */
@@ -2252,16 +2236,12 @@ device_is_caller_privileged (DBusConnect
                         raise_error (connection, message, 
                                      "org.freedesktop.Hal.Error", 
                                      "Could not determine caller info for sender");
-                        g_ptr_array_foreach (params, (GFunc) g_free, NULL);
-                        g_ptr_array_free (params, TRUE);
                         return DBUS_HANDLER_RESULT_HANDLED;
                 }
                 if ((ci_target = ci_tracker_get_info (ci_tracker, caller_sysbus_name)) == NULL) {
                         raise_error (connection, message, 
                                      "org.freedesktop.Hal.Error", 
                                      "Could not determine caller info for target");
-                        g_ptr_array_foreach (params, (GFunc) g_free, NULL);
-                        g_ptr_array_free (params, TRUE);
                         return DBUS_HANDLER_RESULT_HANDLED;
                 }
 
@@ -2269,8 +2249,6 @@ device_is_caller_privileged (DBusConnect
                 if (ci_tracker_caller_get_uid (ci_sender) != ci_tracker_caller_get_uid (ci_target)) {
                         raise_permission_denied (connection, message, 
                                                  "IsCallerPrivileged: not privileged/authorized to know");
-                        g_ptr_array_foreach (params, (GFunc) g_free, NULL);
-                        g_ptr_array_free (params, TRUE);
                         return DBUS_HANDLER_RESULT_HANDLED;
                 }
         }
@@ -2278,12 +2256,9 @@ device_is_caller_privileged (DBusConnect
 
         polkit_result = -1;
         access_check_caller_have_access_to_device (
-                ci_tracker, d, action, (const char **) params->pdata, caller_sysbus_name, &polkit_result);
+                ci_tracker, d, action, caller_sysbus_name, &polkit_result);
         result = libpolkit_result_to_string_representation (polkit_result);
 
-                        g_ptr_array_foreach (params, (GFunc) g_free, NULL);
-                        g_ptr_array_free (params, TRUE);
-
         if (polkit_result < 0 || result == NULL) {
 		raise_error (connection, message, 
                              "org.freedesktop.Hal.Error", 
@@ -5113,14 +5088,12 @@ validate_lock_for_device (HalDeviceStore
                         continue;
 
                 for (m = 0; holders[m] != NULL; m++) {
-                        const char *action_params[3] = {"interface", "", NULL};
-                        action_params[1] = locked_interfaces[n];
 
                         HAL_INFO (("Validating lock holder '%s' on interface '%s' on udi '%s'",
                                    holders[m], locked_interfaces[n], hal_device_get_udi (device)));
 
                         if (!access_check_caller_have_access_to_device (
-                                    ci_tracker, device, "hal-lock", action_params, holders[m], NULL)) {
+                                    ci_tracker, device, "hal-lock", holders[m], NULL)) {
                                 HAL_INFO (("Kicking out lock holder '%s' on interface '%s' on udi '%s' "
                                            "as he no longer has access to the device",
                                            holders[m], locked_interfaces[n], hal_device_get_udi (device)));
diff --git a/hald/linux/addons/addon-cpufreq.c b/hald/linux/addons/addon-cpufreq.c
index 7ace00c..57eef87 100644
--- a/hald/linux/addons/addon-cpufreq.c
+++ b/hald/linux/addons/addon-cpufreq.c
@@ -933,7 +933,6 @@ dbus_is_privileged (DBusConnection *conn
         polkit_result = libhal_device_is_caller_privileged (halctx,
                                                             udi,
                                                             CPUFREQ_POLKIT_PRIVILEGE,
-                                                            NULL,
                                                             invoked_by_syscon_name,
                                                             error);
         if (polkit_result == NULL) {
diff --git a/hald/linux/addons/addon-dell-backlight.cpp b/hald/linux/addons/addon-dell-backlight.cpp
index b3282b5..371e682 100644
--- a/hald/linux/addons/addon-dell-backlight.cpp
+++ b/hald/linux/addons/addon-dell-backlight.cpp
@@ -138,7 +138,6 @@ check_priv (DBusConnection *connection, 
         polkit_result = libhal_device_is_caller_privileged (halctx,
                                                             udi,
                                                             action,
-                                                            NULL,
                                                             invoked_by_syscon_name,
                                                             &error);
         if (polkit_result == NULL) {
diff --git a/hald/linux/addons/addon-macbookpro-backlight.c b/hald/linux/addons/addon-macbookpro-backlight.c
index d636661..b31f5d0 100644
--- a/hald/linux/addons/addon-macbookpro-backlight.c
+++ b/hald/linux/addons/addon-macbookpro-backlight.c
@@ -219,8 +219,7 @@ static gboolean
 check_priv (DBusConnection *connection, 
             DBusMessage *message, 
             const char *udi, 
-            const char *action,
-            char **action_params)
+            const char *action)
 #ifdef HAVE_POLKIT
 {
         gboolean ret;
@@ -238,7 +237,6 @@ check_priv (DBusConnection *connection, 
         polkit_result = libhal_device_is_caller_privileged (halctx,
                                                             udi,
                                                             action,
-                                                            action_params,
                                                             invoked_by_syscon_name,
                                                             &error);
         if (polkit_result == NULL) {
@@ -297,7 +295,7 @@ filter_function (DBusConnection *connect
 					 "SetBrightness")) {
 		int brightness;
 
-                if (!check_priv (connection, message, udi, "hal-power-lcd-panel", NULL))
+                if (!check_priv (connection, message, udi, "hal-power-lcd-panel"))
                         goto error;
 
 		dbus_error_init (&err);
@@ -334,7 +332,7 @@ filter_function (DBusConnection *connect
 						"GetBrightness")) {
 		int brightness;
 
-                if (!check_priv (connection, message, udi, "hal-power-lcd-panel", NULL))
+                if (!check_priv (connection, message, udi, "hal-power-lcd-panel"))
                         goto error;
 
 		dbus_error_init (&err);
@@ -365,7 +363,7 @@ filter_function (DBusConnection *connect
 						"GetBrightness")) {
 		int brightness[2];
 
-                if (!check_priv (connection, message, udi, "hal-power-light-sensor", NULL))
+                if (!check_priv (connection, message, udi, "hal-power-light-sensor"))
                         goto error;
 
 		brightness[0] = read_light_sensor (FALSE); /* right */
@@ -392,7 +390,7 @@ filter_function (DBusConnection *connect
 						"org.freedesktop.Hal.Device.KeyboardBacklight", 
 						"GetBrightness")) {
 
-                if (!check_priv (connection, message, udi, "hal-power-keyboard-backlight", NULL))
+                if (!check_priv (connection, message, udi, "hal-power-keyboard-backlight"))
                         goto error;
 
 		/* I can't get this working so just cache last SetBrightness value :-/ */
@@ -437,7 +435,7 @@ filter_function (DBusConnection *connect
 						"SetBrightness")) {
 		int brightness;
 
-                if (!check_priv (connection, message, udi, "hal-power-keyboard-backlight", NULL))
+                if (!check_priv (connection, message, udi, "hal-power-keyboard-backlight"))
                         goto error;
 
 		dbus_error_init (&err);
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 9bc8a42..4ddac9e 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -4644,7 +4644,6 @@ libhal_device_is_locked_by_others (LibHa
  * @ctx: the context for the connection to hald
  * @udi: the Unique id of device
  * @action: the action to check for
- * @action_param: A #NULL terminated list of action parameters or #NULL if there are no parameters
  * @caller: the caller to check for
  * @error: pointer to an initialized dbus error object for returning errors
  * 
@@ -4661,13 +4660,11 @@ char*
 libhal_device_is_caller_privileged (LibHalContext *ctx,
                                     const char *udi,
                                     const char *action,
-                                    char **action_parameters,
                                     const char *caller,
                                     DBusError *error)
 {
 	DBusMessage *message;
 	DBusMessageIter iter;
-	DBusMessageIter iter_array;
 	DBusMessage *reply;
 	DBusMessageIter reply_iter;
         char *dbus_str;
@@ -4692,19 +4689,6 @@ libhal_device_is_caller_privileged (LibH
 
 	dbus_message_iter_init_append (message, &iter);
 	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &action);
-	dbus_message_iter_open_container (&iter, 
-					  DBUS_TYPE_ARRAY,
-					  DBUS_TYPE_STRING_AS_STRING,
-					  &iter_array);
-
-        if (action_parameters != NULL) {
-                int n;
-                for (n = 0; action_parameters[n] != NULL; n++) {
-                        dbus_message_iter_append_basic (&iter_array, DBUS_TYPE_STRING, &(action_parameters[n]));
-                }
-        }
-
-        dbus_message_iter_close_container (&iter, &iter_array);
 	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &caller);
 	
 	reply = dbus_connection_send_with_reply_and_block (ctx->connection,
diff --git a/libhal/libhal.h b/libhal/libhal.h
index 110c684..f050d3b 100644
--- a/libhal/libhal.h
+++ b/libhal/libhal.h
@@ -717,7 +717,6 @@ dbus_bool_t libhal_device_is_locked_by_o
 char* libhal_device_is_caller_privileged (LibHalContext *ctx,
                                           const char *udi,
                                           const char *action,
-                                          char **action_parameters,
                                           const char *caller,
                                           DBusError *error);
 
diff --git a/tools/hal-acl-tool.c b/tools/hal-acl-tool.c
index 8813325..eb35cd2 100644
--- a/tools/hal-acl-tool.c
+++ b/tools/hal-acl-tool.c
@@ -654,7 +654,6 @@ acl_device_added_visitor (const char *se
                 pk_action = libpolkit_action_new();
                 priv_name = g_strdup_printf ("hal-device-file-%s", afd->type);
                 libpolkit_action_set_action_id (pk_action, priv_name);
-                libpolkit_action_set_param (pk_action, "device-file", afd->device);
                 g_free (priv_name);
 
                 /* Now ask PolicyKit if the given session should have access */
@@ -1062,7 +1061,7 @@ acl_unlock (void)
 int
 main (int argc, char *argv[])
 {
-        GError *g_error;
+        PolKitError *p_error;
 
 	if (argc != 2) {
 		printf ("hal-acl-tool should only be invoked by hald\n");
@@ -1073,10 +1072,10 @@ main (int argc, char *argv[])
 		goto out;
 	}
 
-        g_error = NULL;
+        p_error = NULL;
         pk_context = libpolkit_context_new ();
-        if (!libpolkit_context_init (pk_context, &g_error)) {
-                printf ("Could not init PolicyKit context: %s", g_error->message);
+        if (!libpolkit_context_init (pk_context, &p_error)) {
+                printf ("Could not init PolicyKit context: %s\n", polkit_error_get_error_message (p_error));
                 goto out;
         }
 
diff --git a/tools/hal-is-caller-privileged.c b/tools/hal-is-caller-privileged.c
index 55d68d7..add237f 100644
--- a/tools/hal-is-caller-privileged.c
+++ b/tools/hal-is-caller-privileged.c
@@ -49,14 +49,12 @@ usage (int argc, char *argv[])
 	fprintf (stderr,
                  "\n"
                  "usage : hal-is-caller-privileged --udi <udi> --action <action>\n"
-                 "                                 [--action-param <key>=<value>]\n"
                  "                                 --caller <caller-name>\n"
                  "                                 [--help] [--version]\n");
 	fprintf (stderr,
                  "\n"
                  "        --udi            Unique Device Id\n"
                  "        --action         PolicyKit action to check for\n"
-                 "        --action-param   Action parameters (may occur multiple times)\n"
                  "        --caller         The name of the caller\n"
                  "        --version        Show version and exit\n"
                  "        --help           Show this information and exit\n"
@@ -89,18 +87,12 @@ main (int argc, char *argv[])
         char *polkit_result;
 	DBusError error;
         LibHalContext *hal_ctx;
-        GPtrArray *params;
-        int n;
-        char *param_key;
-        char *param_value;
-        char **action_params;
 
 	if (argc <= 1) {
 		usage (argc, argv);
 		return 1;
 	}
 
-        params = g_ptr_array_new ();
 	while (1) {
 		int c;
 		int option_index = 0;
@@ -108,7 +100,6 @@ main (int argc, char *argv[])
 		static struct option long_options[] = {
 			{"udi", 1, NULL, 0},
 			{"action", 1, NULL, 0},
-			{"action-param", 1, NULL, 0},
 			{"caller", 1, NULL, 0},
 			{"version", 0, NULL, 0},
 			{"help", 0, NULL, 0},
@@ -135,18 +126,6 @@ main (int argc, char *argv[])
 				caller = strdup (optarg);
 			} else if (strcmp (opt, "action") == 0) {
 				action = strdup (optarg);
-			} else if (strcmp (opt, "action-param") == 0) {
-				param_key = strdup (optarg);
-                                param_value = NULL;
-                                for (n = 0; param_key[n] != '=' && param_key[n] != '\0'; n++)
-                                        ;
-                                if (param_key[n] == '\0')
-                                        usage (argc, argv);
-                                param_key[n] = '\0';
-                                param_value = param_key + n + 1;
-                                g_ptr_array_add (params, g_strdup (param_key));
-                                g_ptr_array_add (params, g_strdup (param_value));
-                                g_free (param_key);
 			}
 			break;
 
@@ -187,17 +166,9 @@ main (int argc, char *argv[])
 		return 1;
 	}
 
-        if (params->len > 0) {
-                g_ptr_array_add (params, NULL);
-                action_params = (char **) g_ptr_array_free (params, FALSE);
-        } else {
-                action_params = NULL;
-        }
-
         polkit_result = libhal_device_is_caller_privileged (hal_ctx,
                                                             udi,
                                                             action,
-                                                            action_params,
                                                             caller,
                                                             &error);
         if (dbus_error_is_set (&error)) {
diff --git a/tools/hal-storage-mount.c b/tools/hal-storage-mount.c
index a35cc2d..32d68e5 100644
--- a/tools/hal-storage-mount.c
+++ b/tools/hal-storage-mount.c
@@ -798,7 +798,6 @@ handle_mount (LibHalContext *hal_ctx, 
                 polkit_result = libhal_device_is_caller_privileged (hal_ctx,
                                                                     udi,
                                                                     action,
-                                                                    action_params,
                                                                     invoked_by_syscon_name,
                                                                     &error);
                 if (polkit_result == NULL){
diff --git a/tools/hal-storage-shared.c b/tools/hal-storage-shared.c
index 88eb71a..40235d7 100644
--- a/tools/hal-storage-shared.c
+++ b/tools/hal-storage-shared.c
@@ -427,7 +427,6 @@ line_found:
                         polkit_result = libhal_device_is_caller_privileged (hal_ctx,
                                                                             udi,
                                                                             action,
-                                                                            NULL, /* TODO: FIXME: */
                                                                             invoked_by_syscon_name,
                                                                             &error);
                         if (polkit_result == NULL){
@@ -602,7 +601,6 @@ try_open_excl_again:
                 polkit_result = libhal_device_is_caller_privileged (hal_ctx,
                                                                     udi,
                                                                     action,
-                                                                    NULL,
                                                                     invoked_by_syscon_name,
                                                                     &error);
                 if (polkit_result == NULL){


More information about the hal-commit mailing list