summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2007-07-24 12:17:39 +0000
committerRichard Hughes <richard@hughsie.com>2007-07-24 12:17:39 +0000
commit153a2aed604b4b09e915397fe3b1db3f37e830e0 (patch)
treed46231c4911a46a4117cfe4c5563d78918bacce3
parent74e1b986192d817c5c84a0e71c70fb0cb0378cc6 (diff)
2007-07-24 Richard Hughes <richard@hughsie.com>
* bus/activation.c: (bus_activation_entry_unref), (update_desktop_file_entry): Add the concept of, and read the value of user from the desktop file. The user string is not required unless we are using system activation.
-rw-r--r--ChangeLog7
-rw-r--r--bus/activation.c35
2 files changed, 41 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d7029fb..56c0f8da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2007-07-24 Richard Hughes <richard@hughsie.com>
+ * bus/activation.c: (bus_activation_entry_unref),
+ (update_desktop_file_entry):
+ Add the concept of, and read the value of user from the desktop file.
+ The user string is not required unless we are using system activation.
+
+2007-07-24 Richard Hughes <richard@hughsie.com>
+
* bus/activation.c:
* bus/desktop-file.h:
Move the defines into the header file, as we use these in the lauch
diff --git a/bus/activation.c b/bus/activation.c
index 06dcf0ad..41671d3d 100644
--- a/bus/activation.c
+++ b/bus/activation.c
@@ -65,6 +65,7 @@ typedef struct
int refcount;
char *name;
char *exec;
+ char *user;
unsigned long mtime;
BusServiceDirectory *s_dir;
char *filename;
@@ -237,6 +238,7 @@ bus_activation_entry_unref (BusActivationEntry *entry)
dbus_free (entry->name);
dbus_free (entry->exec);
+ dbus_free (entry->user);
dbus_free (entry->filename);
dbus_free (entry);
@@ -249,17 +251,21 @@ update_desktop_file_entry (BusActivation *activation,
BusDesktopFile *desktop_file,
DBusError *error)
{
- char *name, *exec;
+ char *name, *exec, *user;
BusActivationEntry *entry;
DBusStat stat_buf;
DBusString file_path;
+ DBusError tmp_error;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
name = NULL;
exec = NULL;
+ user = NULL;
entry = NULL;
+ dbus_error_init (&tmp_error);
+
if (!_dbus_string_init (&file_path))
{
BUS_SET_OOM (error);
@@ -294,6 +300,29 @@ update_desktop_file_entry (BusActivation *activation,
error))
goto failed;
+ /* user is not _required_ unless we are using system activation */
+ if (!bus_desktop_file_get_string (desktop_file,
+ DBUS_SERVICE_SECTION,
+ DBUS_SERVICE_USER,
+ &user, &tmp_error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
+ /* if we got OOM, then exit */
+ if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
+ {
+ dbus_move_error (&tmp_error, error);
+ goto failed;
+ }
+ else
+ {
+ /* if we have error because we didn't find anything then continue */
+ dbus_error_free (&tmp_error);
+ dbus_free (user);
+ user = NULL;
+ }
+ }
+ _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
+
entry = _dbus_hash_table_lookup_string (s_dir->entries,
_dbus_string_get_const_data (filename));
if (entry == NULL) /* New file */
@@ -317,6 +346,7 @@ update_desktop_file_entry (BusActivation *activation,
entry->name = name;
entry->exec = exec;
+ entry->user = user;
entry->refcount = 1;
entry->s_dir = s_dir;
@@ -357,8 +387,10 @@ update_desktop_file_entry (BusActivation *activation,
dbus_free (entry->name);
dbus_free (entry->exec);
+ dbus_free (entry->user);
entry->name = name;
entry->exec = exec;
+ entry->user = user;
if (!_dbus_hash_table_insert_string (activation->entries,
entry->name, bus_activation_entry_ref(entry)))
{
@@ -382,6 +414,7 @@ update_desktop_file_entry (BusActivation *activation,
failed:
dbus_free (name);
dbus_free (exec);
+ dbus_free (user);
_dbus_string_free (&file_path);
if (entry)