hal/hald hald_dbus.c,1.45,1.46
Kay Sievers
kay at freedesktop.org
Tue Dec 13 15:51:30 PST 2005
Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv23800/hald
Modified Files:
hald_dbus.c
Log Message:
2005-12-14 Kay Sievers <kay.sievers at vrfy.org>
Add HAL_METHOD_INVOKED_BY_UID to the method-call environment
and use it to mount FAT, NTFS and hfs volumes to make them available
to the user who invoked the method.
* hald/hald_dbus.c: (hald_exec_method):
* tools/hal-system-storage-mount:
Index: hald_dbus.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_dbus.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- hald_dbus.c 8 Dec 2005 22:12:40 -0000 1.45
+++ hald_dbus.c 13 Dec 2005 23:51:28 -0000 1.46
@@ -2577,18 +2577,30 @@
DBusMessageIter iter;
int stdin_fd;
int *stderr_fd;
+ const char *sender;
+ char *extra_env[2];
- /* TODO: check that sender is e.g. at console */
-/*
- if (!sender_has_privileges (connection, message)) {
- raise_permission_denied (connection, message, "not privileged");
- return DBUS_HANDLER_RESULT_HANDLED;
- }
-*/
+ /* add calling uid */
+ extra_env[0] = NULL;
+ sender = dbus_message_get_sender (message);
+ if (sender != NULL) {
+ DBusError error;
+ unsigned long uid;
- stdin_str = g_string_sized_new (256); /* reasonable default size for passing params; can grow */
+ dbus_error_init (&error);
+ uid = dbus_bus_get_unix_user (connection, sender, &error);
+ if (!dbus_error_is_set (&error)) {
+ char uid_export[128];
+
+ sprintf (uid_export, "HAL_METHOD_INVOKED_BY_UID=%lu", uid);
+ extra_env[0] = uid_export;
+ extra_env[1] = NULL;
+ HAL_INFO(("%s", uid_export));
+ }
+ }
/* prepare stdin with parameters */
+ stdin_str = g_string_sized_new (256); /* default size for passing params; can grow */
dbus_message_iter_init (message, &iter);
while ((type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) {
switch (type) {
@@ -2693,7 +2705,7 @@
stderr_fd = (int *) g_new0 (int, 1);
/* no timeout */
- if (hal_util_helper_invoke_with_pipes (execpath, NULL, d,
+ if (hal_util_helper_invoke_with_pipes (execpath, extra_env, d,
(gpointer) message, (gpointer) stderr_fd,
hald_exec_method_cb, 0, &stdin_fd, NULL, stderr_fd) != NULL) {
write (stdin_fd, stdin, strlen (stdin));
More information about the hal-commit
mailing list