From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: util-linux-owner@vger.kernel.org Received: from [195.159.176.226] ([195.159.176.226]:43381 "EHLO blaine.gmane.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751056AbdEaTqU (ORCPT ); Wed, 31 May 2017 15:46:20 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dG9ZL-0005wZ-5A for util-linux@vger.kernel.org; Wed, 31 May 2017 21:46:11 +0200 To: util-linux@vger.kernel.org From: yumkam@gmail.com (Yuriy M. Kaminskiy) Subject: Re: [PATCH] setpriv: Add --init-groups option Date: Wed, 31 May 2017 22:46:05 +0300 Message-ID: References: <20170531160117.27803-1-sebastian.schrader@ossmail.de> Mime-Version: 1.0 Content-Type: text/plain Sender: util-linux-owner@vger.kernel.org List-ID: Sebastian Schrader writes: > 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.1 | 8 +++++++ > sys-utils/setpriv.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++----- > 2 files changed, 66 insertions(+), 5 deletions(-) > > diff --git a/sys-utils/setpriv.1 b/sys-utils/setpriv.1 > index bf18fe050..be97c0799 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 2129115a0..618119385 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