utils: add lxc_drop_groups()

parent fde1420c
......@@ -1444,6 +1444,18 @@ bool lxc_switch_uid_gid(uid_t uid, gid_t gid)
}
/* Simple convenience function which enables uniform logging. */
bool lxc_drop_groups(void)
{
int ret;
ret = setgroups(0, NULL);
if (ret)
return log_error_errno(false, errno, "Failed to drop supplimentary groups");
NOTICE("Dropped supplimentary groups");
return ret == 0;
}
bool lxc_setgroups(int size, gid_t list[])
{
if (setgroups(size, list) < 0) {
......
......@@ -157,6 +157,7 @@ __hidden extern bool task_blocks_signal(pid_t pid, int signal);
*/
__hidden extern bool lxc_switch_uid_gid(uid_t uid, gid_t gid);
__hidden extern bool lxc_setgroups(int size, gid_t list[]);
__hidden extern bool lxc_drop_groups(void);
/* Find an unused loop device and associate it with source. */
__hidden extern int lxc_prepare_loop_dev(const char *source, char *loop_dev, int flags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment