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
18 #include "privileges.h"
21 privileges_drop (uid_t uid, gid_t gid)
24 g_assert (setresgid (gid, gid, -1) == 0);
26 g_assert (setgid (gid) == 0);
27 g_assert (setegid (gid) == 0);
30 g_assert (setresuid (uid, uid, -1) == 0);
32 g_assert (setuid (uid) == 0);
33 g_assert (seteuid (uid) == 0);
38 privileges_reclaim (void)
41 g_assert (setresuid (0, 0, -1) == 0);
43 g_assert (setuid (0) == 0);
44 g_assert (seteuid (0) == 0);
47 g_assert (setresgid (0, 0, -1) == 0);
49 g_assert (setgid (0) == 0);
50 g_assert (setegid (0) == 0);