diff options
author | David Zeuthen <davidz@redhat.com> | 2011-04-11 12:41:35 -0400 |
---|---|---|
committer | David Zeuthen <davidz@redhat.com> | 2011-04-11 13:24:22 -0400 |
commit | 55e6f92e7340d57a66f83bd69bdf26454fdf7533 (patch) | |
tree | 23b56e0bf4fb0f2bbab455304aa414b9e4357d0b | |
parent | 9a44af8ab67d09a2c08be29428b8fe32da809e99 (diff) | |
download | polkit-55e6f92e7340d57a66f83bd69bdf26454fdf7533.tar.gz |
Use polkit_unix_process_get_uid() to get the owner of a process
This avoids a TOCTTOU problem.
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r-- | src/polkitbackend/polkitbackendsessionmonitor.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/polkitbackend/polkitbackendsessionmonitor.c b/src/polkitbackend/polkitbackendsessionmonitor.c index 2028250..d976514 100644 --- a/src/polkitbackend/polkitbackendsessionmonitor.c +++ b/src/polkitbackend/polkitbackendsessionmonitor.c @@ -418,14 +418,13 @@ polkit_backend_session_monitor_get_user_for_subject (PolkitBackendSessionMonitor if (POLKIT_IS_UNIX_PROCESS (subject)) { - GError *local_error; - - local_error = NULL; - uid = polkit_unix_process_get_owner (POLKIT_UNIX_PROCESS (subject), &local_error); - if (local_error != NULL) + uid = polkit_unix_process_get_uid (POLKIT_UNIX_PROCESS (subject)); + if ((gint) uid == -1) { - g_propagate_error (error, local_error); - g_error_free (local_error); + g_set_error (error, + POLKIT_ERROR, + POLKIT_ERROR_FAILED, + "Unix process subject does not have uid set"); goto out; } user = polkit_unix_user_new (uid); |