2
* Copyright (C) 2010-2011 Robert Ancell.
3
* Author: Robert Ancell <robert.ancell@canonical.com>
5
* This program is free software: you can redistribute it and/or modify it under
6
* the terms of the GNU General Public License as published by the Free Software
7
* Foundation, either version 3 of the License, or (at your option) any later
8
* version. See http://www.gnu.org/copyleft/gpl.html the full text of the
16
#include "privileges.h"
19
privileges_drop (User *user)
21
g_return_if_fail (user != NULL);
23
g_debug ("Dropping privileges to uid %i", user_get_uid (user));
25
g_debug ("Calling setresgid");
26
g_assert (setresgid (user_get_gid (user), user_get_gid (user), -1) == 0);
28
g_assert (setgid (user_get_gid (user)) == 0);
29
g_assert (setegid (user_get_gid (user)) == 0);
32
g_debug ("Calling setresuid");
33
g_assert (setresuid (user_get_uid (user), user_get_uid (user), -1) == 0);
35
g_assert (setuid (user_get_uid (user)) == 0);
36
g_assert (seteuid (user_get_uid (user)) == 0);
41
privileges_reclaim (void)
43
g_debug ("Restoring privileges");
45
g_debug ("Calling setresuid");
46
g_assert (setresuid (0, 0, -1) == 0);
48
g_assert (setuid (0) == 0);
49
g_assert (seteuid (0) == 0);
52
g_debug ("Calling setresgid");
53
g_assert (setresgid (0, 0, -1) == 0);
55
g_assert (setgid (0) == 0);
56
g_assert (setegid (0) == 0);