From cfa261b49dd9cafb172deae3db22dba0c2e54bf9 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Wed, 2 Apr 2003 00:29:33 +0000 Subject: 2003-04-01 Havoc Pennington * bus/config-parser.c, bus/bus.c: implement and (at least mostly) * dbus/dbus-sysdeps.c (_dbus_change_identity): set the group ID first, then the user ID --- dbus/dbus-keyring.c | 4 ++++ dbus/dbus-sysdeps.c | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'dbus') diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index d63bc3e8..b9203404 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -41,6 +41,10 @@ * file in the user's homedir. However they are transient (only used * by a single server instance for a fixed period of time, then * discarded). Also, the keys are not sent over the wire. + * + * @todo there's a memory leak on some codepath in here, I saw it once + * when running make check - probably some specific initial cookies + * present in the cookie file, then depending on what we do with them. */ /** diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 71863ef6..8aa91811 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -3185,18 +3185,21 @@ _dbus_change_identity (unsigned long uid, unsigned long gid, DBusError *error) { - if (setuid (uid) < 0) + /* Set GID first, or the setuid may remove our permission + * to change the GID + */ + if (setgid (gid) < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to set UID to %lu: %s", uid, + "Failed to set GID to %lu: %s", gid, _dbus_strerror (errno)); return FALSE; } - - if (setgid (gid) < 0) + + if (setuid (uid) < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to set GID to %lu: %s", gid, + "Failed to set UID to %lu: %s", uid, _dbus_strerror (errno)); return FALSE; } -- cgit