summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-sysdeps.c24
-rw-r--r--dbus/dbus-sysdeps.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index b941c19e..f706d08a 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -1478,6 +1478,30 @@ _dbus_credentials_from_username (const DBusString *username,
}
/**
+ * Gets user ID given username
+ *
+ * @param username the username
+ * @param uid return location for UID
+ * @returns #TRUE if username existed and we got the UID
+ */
+dbus_bool_t
+_dbus_get_user_id (const DBusString *username,
+ dbus_uid_t *uid)
+{
+ DBusCredentials creds;
+
+ if (!_dbus_credentials_from_username (username, &creds))
+ return FALSE;
+
+ if (creds.uid == DBUS_UID_UNSET)
+ return FALSE;
+
+ *uid = creds.uid;
+
+ return TRUE;
+}
+
+/**
* Gets the credentials corresponding to the given user ID.
*
* @param user_id the user ID
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index 74e0cb61..4edfe94a 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -134,6 +134,8 @@ void _dbus_credentials_from_current_process (DBusCredentials *crede
dbus_bool_t _dbus_credentials_match (const DBusCredentials *expected_credentials,
const DBusCredentials *provided_credentials);
+dbus_bool_t _dbus_get_user_id (const DBusString *username,
+ dbus_uid_t *uid);
dbus_bool_t _dbus_string_append_our_uid (DBusString *str);
dbus_bool_t _dbus_homedir_from_username (const DBusString *username,