Commit 88cd5da3 authored by Havoc Pennington's avatar Havoc Pennington

2003-04-17 Havoc Pennington <hp@redhat.com>

	* dbus/dbus-userdb.c, dbus/dbus-sysdeps.c: redo all the passwd
	database usage so it all goes via the DBusUserDatabase cache.
parent 4219b08b
2003-04-17 Havoc Pennington <hp@redhat.com>
* dbus/dbus-userdb.c, dbus/dbus-sysdeps.c: redo all the passwd
database usage so it all goes via the DBusUserDatabase cache.
2003-04-17 Havoc Pennington <hp@redhat.com>
* dbus/dbus-mainloop.c (_dbus_loop_iterate): fix logic so that if
......
......@@ -30,6 +30,7 @@
#include "dbus-hash.h"
#include "dbus-internals.h"
#include "dbus-marshal.h"
#include "dbus-userdb.h"
/**
* @defgroup DBusAuthScript code for running unit test scripts for DBusAuth
......@@ -373,7 +374,8 @@ _dbus_auth_script_run (const DBusString *filename)
goto out;
}
if (!_dbus_string_append_our_uid (&username))
if (!_dbus_string_append_uint (&username,
_dbus_getuid ()))
{
_dbus_warn ("no memory for userid\n");
_dbus_string_free (&username);
......@@ -407,7 +409,7 @@ _dbus_auth_script_run (const DBusString *filename)
goto out;
}
if (!_dbus_user_info_from_current_process (&u, NULL, NULL) ||
if (!_dbus_username_from_current_process (&u) ||
!_dbus_string_copy (u, 0, &username,
_dbus_string_get_length (&username)))
{
......
......@@ -26,6 +26,7 @@
#include "dbus-internals.h"
#include "dbus-keyring.h"
#include "dbus-sha.h"
#include "dbus-userdb.h"
/* See doc/dbus-sasl-profile.txt */
......@@ -712,8 +713,7 @@ handle_client_initial_response_cookie_sha1_mech (DBusAuth *auth,
retval = FALSE;
if (!_dbus_user_info_from_current_process (&username,
NULL, NULL))
if (!_dbus_username_from_current_process (&username))
goto out_0;
if (!_dbus_string_base64_encode (username, 0,
......@@ -1000,8 +1000,8 @@ handle_server_data_external_mech (DBusAuth *auth,
}
else
{
if (!_dbus_credentials_from_uid_string (&auth->identity,
&auth->desired_identity))
if (!_dbus_uid_from_string (&auth->identity,
&auth->desired_identity.uid))
{
_dbus_verbose ("could not get credentials from uid string\n");
return send_rejected (auth);
......@@ -1066,7 +1066,8 @@ handle_client_initial_response_external_mech (DBusAuth *auth,
if (!_dbus_string_init (&plaintext))
return FALSE;
if (!_dbus_string_append_our_uid (&plaintext))
if (!_dbus_string_append_uint (&plaintext,
_dbus_getuid ()))
goto failed;
if (!_dbus_string_base64_encode (&plaintext, 0,
......
......@@ -195,9 +195,9 @@ _DBUS_DECLARE_GLOBAL_LOCK (connection_slots);
_DBUS_DECLARE_GLOBAL_LOCK (server_slots);
_DBUS_DECLARE_GLOBAL_LOCK (atomic);
_DBUS_DECLARE_GLOBAL_LOCK (message_handler);
_DBUS_DECLARE_GLOBAL_LOCK (user_info);
_DBUS_DECLARE_GLOBAL_LOCK (bus);
_DBUS_DECLARE_GLOBAL_LOCK (shutdown_funcs);
_DBUS_DECLARE_GLOBAL_LOCK (system_users);
#define _DBUS_N_GLOBAL_LOCKS (8)
dbus_bool_t _dbus_threads_init_debug (void);
......
......@@ -22,6 +22,7 @@
*/
#include "dbus-keyring.h"
#include "dbus-userdb.h"
#include <dbus/dbus-string.h>
#include <dbus/dbus-list.h>
#include <dbus/dbus-sysdeps.h>
......@@ -699,10 +700,9 @@ _dbus_keyring_new_homedir (const DBusString *username,
if (username == NULL)
{
const DBusString *const_homedir;
if (!_dbus_user_info_from_current_process (&username,
&const_homedir,
NULL))
if (!_dbus_username_from_current_process (&username) ||
!_dbus_homedir_from_current_process (&const_homedir))
goto failed;
if (!_dbus_string_copy (const_homedir, 0,
......
This diff is collapsed.
......@@ -124,34 +124,50 @@ dbus_bool_t _dbus_send_credentials_unix_socket (int server_fd,
void _dbus_credentials_clear (DBusCredentials *credentials);
dbus_bool_t _dbus_credentials_from_username (const DBusString *username,
DBusCredentials *credentials);
dbus_bool_t _dbus_credentials_from_user_id (dbus_uid_t user_id,
DBusCredentials *credentials);
dbus_bool_t _dbus_credentials_from_uid_string (const DBusString *uid_str,
DBusCredentials *credentials);
void _dbus_credentials_from_current_process (DBusCredentials *credentials);
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,
DBusString *homedir);
dbus_bool_t _dbus_user_info_from_current_process (const DBusString **username,
const DBusString **homedir,
const DBusCredentials **credentials);
typedef struct DBusUserInfo DBusUserInfo;
typedef struct DBusGroupInfo DBusGroupInfo;
struct DBusUserInfo
{
dbus_uid_t uid; /**< UID */
dbus_gid_t primary_gid; /**< GID */
dbus_gid_t *group_ids; /**< Groups IDs, *including* above primary group */
int n_group_ids; /**< Size of group IDs array */
char *username; /**< Username */
char *homedir; /**< Home directory */
};
struct DBusGroupInfo
{
dbus_gid_t gid; /**< GID */
char *groupname; /**< Group name */
};
dbus_bool_t _dbus_user_info_fill (DBusUserInfo *info,
const DBusString *username,
DBusError *error);
dbus_bool_t _dbus_user_info_fill_uid (DBusUserInfo *info,
dbus_uid_t uid,
DBusError *error);
void _dbus_user_info_free (DBusUserInfo *info);
dbus_bool_t _dbus_group_info_fill (DBusGroupInfo *info,
const DBusString *groupname,
DBusError *error);
dbus_bool_t _dbus_group_info_fill_gid (DBusGroupInfo *info,
dbus_gid_t gid,
DBusError *error);
void _dbus_group_info_free (DBusGroupInfo *info);
dbus_bool_t _dbus_get_group_id (const DBusString *group_name,
dbus_gid_t *gid);
dbus_bool_t _dbus_get_groups (dbus_uid_t uid,
dbus_gid_t **group_ids,
int *n_group_ids,
DBusError *error);
unsigned long _dbus_getpid (void);
dbus_uid_t _dbus_getuid (void);
dbus_gid_t _dbus_getgid (void);
typedef int dbus_atomic_t;
......
......@@ -226,9 +226,9 @@ init_global_locks (void)
LOCK_ADDR (server_slots),
LOCK_ADDR (atomic),
LOCK_ADDR (message_handler),
LOCK_ADDR (user_info),
LOCK_ADDR (bus),
LOCK_ADDR (shutdown_funcs)
LOCK_ADDR (shutdown_funcs),
LOCK_ADDR (system_users)
#undef LOCK_ADDR
};
......
This diff is collapsed.
......@@ -30,14 +30,52 @@ DBUS_BEGIN_DECLS;
typedef struct DBusUserDatabase DBusUserDatabase;
DBusUserDatabase* _dbus_user_database_new (void);
void _dbus_user_database_ref (DBusUserDatabase *db);
void _dbus_user_database_unref (DBusUserDatabase *db);
dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db,
dbus_uid_t uid,
dbus_gid_t **group_ids,
int *n_group_ids,
DBusError *error);
DBusUserDatabase* _dbus_user_database_new (void);
void _dbus_user_database_ref (DBusUserDatabase *db);
void _dbus_user_database_unref (DBusUserDatabase *db);
dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db,
dbus_uid_t uid,
dbus_gid_t **group_ids,
int *n_group_ids,
DBusError *error);
dbus_bool_t _dbus_user_database_get_uid (DBusUserDatabase *db,
dbus_uid_t uid,
const DBusUserInfo **info,
DBusError *error);
dbus_bool_t _dbus_user_database_get_gid (DBusUserDatabase *db,
dbus_gid_t gid,
const DBusGroupInfo **info,
DBusError *error);
dbus_bool_t _dbus_user_database_get_username (DBusUserDatabase *db,
const DBusString *username,
const DBusUserInfo **info,
DBusError *error);
dbus_bool_t _dbus_user_database_get_groupname (DBusUserDatabase *db,
const DBusString *groupname,
const DBusGroupInfo **info,
DBusError *error);
DBusUserDatabase* _dbus_user_database_get_system (void);
void _dbus_user_database_lock_system (void);
void _dbus_user_database_unlock_system (void);
dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
dbus_bool_t _dbus_homedir_from_current_process (const DBusString **homedir);
dbus_bool_t _dbus_homedir_from_username (const DBusString *username,
DBusString *homedir);
dbus_bool_t _dbus_get_user_id (const DBusString *username,
dbus_uid_t *uid);
dbus_bool_t _dbus_get_group_id (const DBusString *group_name,
dbus_gid_t *gid);
dbus_bool_t _dbus_uid_from_string (const DBusString *uid_str,
dbus_uid_t *uid);
dbus_bool_t _dbus_credentials_from_username (const DBusString *username,
DBusCredentials *credentials);
dbus_bool_t _dbus_credentials_from_uid (dbus_uid_t user_id,
DBusCredentials *credentials);
DBUS_END_DECLS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment