From 94826d0dec68455aa4c311d71d50a6ecf8c82a06 Mon Sep 17 00:00:00 2001 From: Sebastian Schrader Date: Thu, 1 Jun 2017 16:52:10 +0200 Subject: setpriv: Add --init-groups option Add an --init-groups option which initializes the supplementary groups from the system's group database (e.g /etc/group) using initgroups(3). --- sys-utils/setpriv.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 5 deletions(-) (limited to 'sys-utils/setpriv.c') diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c index 2129115a0..8d996e8be 100644 --- a/sys-utils/setpriv.c +++ b/sys-utils/setpriv.c @@ -62,15 +62,20 @@ struct privctx { have_euid:1, /* effective uid */ have_rgid:1, /* real gid */ have_egid:1, /* effective gid */ + have_passwd:1, /* passwd entry */ have_groups:1, /* add groups */ keep_groups:1, /* keep groups */ clear_groups:1, /* remove groups */ + init_groups:1, /* initialize groups */ have_securebits:1; /* remove groups */ /* uids and gids */ uid_t ruid, euid; gid_t rgid, egid; + /* real user passwd entry */ + struct passwd passwd; + /* supplementary groups */ size_t num_groups; gid_t *groups; @@ -109,6 +114,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(_(" --regid set real and effective gid\n"), out); fputs(_(" --clear-groups clear supplementary groups\n"), out); fputs(_(" --keep-groups keep supplementary groups\n"), out); + fputs(_(" --init-groups initialize supplementary groups\n"), out); fputs(_(" --groups set supplementary groups\n"), out); fputs(_(" --securebits set securebits\n"), out); fputs(_(" --selinux-label