summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-userdb.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2007-06-14 20:59:16 +0000
committerHavoc Pennington <hp@redhat.com>2007-06-14 20:59:16 +0000
commit48c6f1472dc315c9572cb1aebf8c7b68a66f5bef (patch)
tree75c1b5a65141ac5a69ee11cf1d6354b5211bc45d /dbus/dbus-userdb.c
parent323790705782bee0d54ea9a342718a49b4ee5be6 (diff)
2007-06-14 Havoc Pennington <hp@redhat.com>
* dbus/dbus-auth.c: adapt to keyring changes * dbus/dbus-keyring.c: change to avoid using user ID and home directory directly; instead use a keyring-location-from-credentials function in dbus-sysdeps * fix to use _dbus_append_user_from_current_process() instead of _dbus_username_from_current_process() or _dbus_append_desired_identity().
Diffstat (limited to 'dbus/dbus-userdb.c')
-rw-r--r--dbus/dbus-userdb.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c
index 46e2275a..75475999 100644
--- a/dbus/dbus-userdb.c
+++ b/dbus/dbus-userdb.c
@@ -436,6 +436,45 @@ _dbus_homedir_from_username (const DBusString *username,
}
/**
+ * Gets the home directory for the given user.
+ *
+ * @param uid the uid
+ * @param homedir string to append home directory to
+ * @returns #TRUE if user existed and we appended their homedir
+ */
+dbus_bool_t
+_dbus_homedir_from_uid (dbus_uid_t uid,
+ DBusString *homedir)
+{
+ DBusUserDatabase *db;
+ const DBusUserInfo *info;
+ _dbus_user_database_lock_system ();
+
+ db = _dbus_user_database_get_system ();
+ if (db == NULL)
+ {
+ _dbus_user_database_unlock_system ();
+ return FALSE;
+ }
+
+ if (!_dbus_user_database_get_uid (db, uid,
+ &info, NULL))
+ {
+ _dbus_user_database_unlock_system ();
+ return FALSE;
+ }
+
+ if (!_dbus_string_append (homedir, info->homedir))
+ {
+ _dbus_user_database_unlock_system ();
+ return FALSE;
+ }
+
+ _dbus_user_database_unlock_system ();
+ return TRUE;
+}
+
+/**
* Adds the credentials corresponding to the given username.
*
* @param credentials credentials to fill in