From 23832672266bb4ff23b66247c0cfa1a2ed0cc97b Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sat, 9 Jun 2007 21:53:20 +0000 Subject: 2007-06-09 Havoc Pennington * 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 --- bus/bus.c | 11 ++--------- bus/dispatch.c | 6 +++++- bus/policy.c | 4 ---- 3 files changed, 7 insertions(+), 14 deletions(-) (limited to 'bus') diff --git a/bus/bus.c b/bus/bus.c index fb9322a9..e1396f23 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -533,7 +533,6 @@ bus_context_new (const DBusString *config_file, { BusContext *context; BusConfigParser *parser; - DBusCredentials creds; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -660,13 +659,7 @@ bus_context_new (const DBusString *config_file, /* check user before we fork */ if (context->user != NULL) { - DBusString u; - - _dbus_string_init_const (&u, context->user); - - if (!_dbus_credentials_from_username (&u, &creds) || - creds.uid < 0 || - creds.gid < 0) + if (!_dbus_verify_daemon_user (context->user)) { dbus_set_error (error, DBUS_ERROR_FAILED, "Could not get UID and GID for username \"%s\"", @@ -769,7 +762,7 @@ bus_context_new (const DBusString *config_file, */ if (context->user != NULL) { - if (!_dbus_change_identity (creds.uid, creds.gid, error)) + if (!_dbus_change_to_daemon_user (context->user, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; diff --git a/bus/dispatch.c b/bus/dispatch.c index f491ef44..ef75933f 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -399,6 +399,10 @@ bus_dispatch_remove_connection (DBusConnection *connection) #ifdef DBUS_BUILD_TESTS #include +#ifdef DBUS_UNIX +#include +#include +#endif /* This is used to know whether we need to block in order to finish * sending a message, or whether the initial dbus_connection_send() @@ -1313,7 +1317,7 @@ check_get_connection_unix_process_id (BusContext *context, * cause then we can test that the pid returned matches * getppid() */ - if (pid != (dbus_uint32_t) _dbus_getpid ()) + if (pid != (dbus_uint32_t) getpid ()) { _dbus_assert (dbus_error_is_set (&error)); _dbus_warn ("Result from GetConnectionUnixProcessID is not our own pid\n"); diff --git a/bus/policy.c b/bus/policy.c index 52ae72a4..7782563b 100644 --- a/bus/policy.c +++ b/bus/policy.c @@ -324,13 +324,9 @@ bus_policy_create_client_policy (BusPolicy *policy, if (!dbus_connection_get_unix_user (connection, &uid)) { -#ifdef DBUS_WIN_FIXME - _dbus_verbose ("policy.c: dbus_connection_get_unix_user check disabled under windows\n"); -#else dbus_set_error (error, DBUS_ERROR_FAILED, "No user ID known for connection, cannot determine security policy\n"); goto failed; -#endif } if (_dbus_hash_table_get_n_entries (policy->rules_by_uid) > 0) -- cgit