summaryrefslogtreecommitdiff
path: root/dbus/dbus-sysdeps-util-win.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2023-06-29 16:06:39 +0100
committerSimon McVittie <smcv@collabora.com>2023-08-18 16:04:03 +0100
commit980e52898b9d684592e3fe706891b3f360d48372 (patch)
tree1e06b60cbc7e093100e218c69a38a93c07239ee4 /dbus/dbus-sysdeps-util-win.c
parent73093fb3bce6d5b5cf1606d67367e67b79022631 (diff)
userdb: Add proper error reporting when getting groups from a uid
Previously, if dbus_connection_get_unix_user() succeeded but _dbus_unix_groups_from_uid() failed, then bus_connection_get_unix_groups() would incorrectly fail without setting the error indicator, resulting in "(null)" being logged, which is rather unhelpful. This also lets us distinguish between ENOMEM and other errors, such as the uid not existing in the system's user database. Fixes: 145fb99b (untitled refactoring commit, 2006-12-12) Helps: https://gitlab.freedesktop.org/dbus/dbus/-/issues/343 Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus/dbus-sysdeps-util-win.c')
-rw-r--r--dbus/dbus-sysdeps-util-win.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c
index 12d7b369..befe1ba2 100644
--- a/dbus/dbus-sysdeps-util-win.c
+++ b/dbus/dbus-sysdeps-util-win.c
@@ -651,6 +651,13 @@ dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid)
unix emulation functions - should be removed sometime in the future
=====================================================================*/
+static void
+set_unix_uid_unsupported (DBusError *error)
+{
+ dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
+ "UNIX user IDs not supported on Windows");
+}
+
/**
* Checks to see if the UNIX user ID is at the console.
* Should always fail on Windows (set the error to
@@ -664,8 +671,7 @@ dbus_bool_t
_dbus_unix_user_is_at_console (dbus_uid_t uid,
DBusError *error)
{
- dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
- "UNIX user IDs not supported on Windows\n");
+ set_unix_uid_unsupported (error);
return FALSE;
}
@@ -709,13 +715,16 @@ _dbus_parse_unix_user_from_config (const DBusString *username,
* @param uid the UID
* @param group_ids return location for array of group IDs
* @param n_group_ids return location for length of returned array
+ * @param error error location
* @returns #TRUE if the UID existed and we got some credentials
*/
dbus_bool_t
_dbus_unix_groups_from_uid (dbus_uid_t uid,
dbus_gid_t **group_ids,
- int *n_group_ids)
+ int *n_group_ids,
+ DBusError *error)
{
+ set_unix_uid_unsupported (error);
return FALSE;
}