From 8aabca8dd28a113712389be51e75ea8c2fd17838 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 13 Apr 2003 08:33:10 +0000 Subject: 2003-04-13 Havoc Pennington * bus/config-parser.c: Load up the BusPolicy and BusPolicyRules * dbus/dbus-sysdeps.c (_dbus_get_user_id): new function * bus/policy.c (bus_policy_append_mandatory_rule) (bus_policy_append_default_rule, bus_policy_append_user_rule) (bus_policy_append_group_rule): new functions --- dbus/dbus-sysdeps.c | 24 ++++++++++++++++++++++++ dbus/dbus-sysdeps.h | 2 ++ 2 files changed, 26 insertions(+) (limited to 'dbus') 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 @@ -1477,6 +1477,30 @@ _dbus_credentials_from_username (const DBusString *username, return get_user_info (username, -1, credentials, NULL, NULL); } +/** + * 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. * 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, -- cgit