summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-userdb.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2007-06-09 21:53:20 +0000
committerHavoc Pennington <hp@redhat.com>2007-06-09 21:53:20 +0000
commit23832672266bb4ff23b66247c0cfa1a2ed0cc97b (patch)
tree119e37411f14923780de3ca7a759707508f1ec63 /dbus/dbus-userdb.c
parentb80a8fe6b364543aa4b32a02a5ad913faf97173b (diff)
2007-06-09 Havoc Pennington <hp@redhat.com>
* bus/dispatch.c (check_get_connection_unix_process_id): adapt since sysdeps-unix.h stuff isn't included anymore * bus/bus.c (bus_context_new): use more abstract functions to change user, so they can be no-ops on Windows * dbus/dbus-credentials.c, dbus/dbus-credentials.h, dbus/dbus-credentials-util.c: new files containing a fully opaque DBusCredentials data type to replace the old not opaque one. * configure.in (DBUS_UNIX): define DBUS_UNIX to match DBUS_WIN on windows * dbus/dbus-userdb.h: prohibit on Windows, next step is to clean up the uses of it in bus/*.c and factor out the parts of cookie auth that depend on it
Diffstat (limited to 'dbus/dbus-userdb.c')
-rw-r--r--dbus/dbus-userdb.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c
index 2aa395dc..c3ae8ef4 100644
--- a/dbus/dbus-userdb.c
+++ b/dbus/dbus-userdb.c
@@ -26,6 +26,7 @@
#include "dbus-test.h"
#include "dbus-internals.h"
#include "dbus-protocol.h"
+#include "dbus-credentials.h"
#include <string.h>
/**
@@ -66,6 +67,30 @@ _dbus_group_info_free_allocated (DBusGroupInfo *info)
}
/**
+ * Frees the members of info
+ * (but not info itself)
+ * @param info the user info struct
+ */
+void
+_dbus_user_info_free (DBusUserInfo *info)
+{
+ dbus_free (info->group_ids);
+ dbus_free (info->username);
+ dbus_free (info->homedir);
+}
+
+/**
+ * Frees the members of info (but not info itself).
+ *
+ * @param info the group info
+ */
+void
+_dbus_group_info_free (DBusGroupInfo *info)
+{
+ dbus_free (info->groupname);
+}
+
+/**
* Checks if a given string is actually a number
* and converts it if it is
*
@@ -412,18 +437,19 @@ _dbus_homedir_from_username (const DBusString *username,
}
/**
- * Gets the credentials corresponding to the given username.
+ * Adds the credentials corresponding to the given username.
*
+ * @param credentials credentials to fill in
* @param username the username
- * @param credentials credentials to fill in
* @returns #TRUE if the username existed and we got some credentials
*/
dbus_bool_t
-_dbus_credentials_from_username (const DBusString *username,
- DBusCredentials *credentials)
+_dbus_credentials_add_from_username (DBusCredentials *credentials,
+ const DBusString *username)
{
DBusUserDatabase *db;
const DBusUserInfo *info;
+
_dbus_user_database_lock_system ();
db = _dbus_user_database_get_system ();
@@ -440,9 +466,11 @@ _dbus_credentials_from_username (const DBusString *username,
return FALSE;
}
- credentials->pid = DBUS_PID_UNSET;
- credentials->uid = info->uid;
- credentials->gid = info->primary_gid;
+ if (!_dbus_credentials_add_unix_uid(credentials, info->uid))
+ {
+ _dbus_user_database_unlock_system ();
+ return FALSE;
+ }
_dbus_user_database_unlock_system ();
return TRUE;