From: Sebastian Schrader Date: Thu, 1 Jun 2017 14:52:10 +0000 (+0200) Subject: setpriv: Add --init-groups option X-Git-Tag: v2.31-rc1~338 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=94826d0dec68455aa4c311d71d50a6ecf8c82a06;p=thirdparty%2Futil-linux.git 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). --- diff --git a/sys-utils/setpriv.1 b/sys-utils/setpriv.1 index bf18fe0504..be97c07990 100644 --- a/sys-utils/setpriv.1 +++ b/sys-utils/setpriv.1 @@ -52,6 +52,14 @@ Preserve supplementary groups. Only useful in conjunction with .BR \-\-egid ", or" .BR \-\-regid . .TP +.B \-\-init\-groups +Initialize supplementary groups using +.BR initgroups "(3)." +Only useful in conjunction with +.BR \-\-ruid +or +.BR \-\-reuid . +.TP .BR \-\-list\-caps List all known capabilities. This option must be specified alone. .TP diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c index 2129115a0e..8d996e8bec 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