[OE-core] [PATCH] useradd-staticids: don't create username-group if gid is specified

Peter Kjellerstedt peter.kjellerstedt at axis.com
Thu Sep 21 13:02:43 UTC 2017


> -----Original Message-----
> From: André Draszik [mailto:git at andred.net]
> Sent: den 21 september 2017 10:24
> To: Peter Kjellerstedt <peter.kjellerstedt at axis.com>; openembedded-
> core at lists.openembedded.org
> Subject: Re: [OE-core] [PATCH] useradd-staticids: don't create
> username-group if gid is specified
> 
> On Wed, 2017-09-20 at 14:20 +0000, Peter Kjellerstedt wrote:
> > > -----Original Message-----
> > > From: André Draszik [mailto:git at andred.net]
> > > Sent: den 20 september 2017 11:29
> > > To: Peter Kjellerstedt <peter.kjellerstedt at axis.com>; openembedded-
> > > core at lists.openembedded.org
> > > Subject: Re: [OE-core] [PATCH] useradd-staticids: don't create
> > > username-group if gid is specified
> > >
> > > ping
> >
> > Sorry, I forgot to reply to this.
> >
> > > On Tue, 2017-09-05 at 08:40 +0100, André Draszik wrote:
> > > > On Mon, 2017-09-04 at 10:22 +0000, Peter Kjellerstedt wrote:
> > > > > >
> > > >
> > > > [...]
> > > > > > diff --git a/meta/classes/useradd-staticids.bbclass
> > > > > > b/meta/classes/useradd-staticids.bbclass
> > > > > > index ce4ac62ab5..1b61a8bf9b 100644
> > > > > > --- a/meta/classes/useradd-staticids.bbclass
> > > > > > +++ b/meta/classes/useradd-staticids.bbclass
> > > > > > @@ -102,7 +102,7 @@ def update_useradd_static_config(d):
> > > > > >              # So if the implicit username-group creation is
> on,
> > > > > > then the implicit groupname (LOGIN)
> > > > > >              # is used, and we disable the user_group option.
> > > > > >              #
> > > > > > -            user_group = uaargs.user_group is None or
> > > > > > uaargs.user_group is True
> > > > > > +            user_group = uaargs.gid is None or
> uaargs.user_group
> > > > > > is True
> > > > >
> > > > > Hmm, I believe that should be:
> > > > >
> > > > >             user_group = uaargs.gid is None and
> uaargs.user_group is
> > > > > None or uaargs.user_group is True
> > > > >
> > > > > I.e., if neither --gid nor --user-group is specified, then it
> should
> > > > > treat it as if --user-group was specified.
> > > >
> > > > Hm, isn't this still the same as
> > > >
> > > > user_group = uaargs.gid is None or uaargs.user_group is True
> >
> > No, because uaargs.user_group may be False if --no-user-group is
> > specified (which I of course should have mentioned in my previous
> > reply). With your version, you would still get a user group even
> > if --no-user-group is specified.
> 
> OK, this is how useradd behaves:
> 
> useradd --system --home /dev/null --no-create-home --no-user-group
> distcc
>   -> will add the new user to the group 'users' (as per GROUP from
> /etc/default/useradd)
> 
> useradd --system --home /dev/null --no-create-home --gid foo --user-
> group distcc
>   -> --gid and --user-group together conflict
> 
> useradd --system --home /dev/null --no-create-home --user-group distcc
> useradd --system --home /dev/null --no-create-home distcc
>  -> in both cases distcc user and group are created
> 
> 
> Sp, what about this instead:
> 
>             if uaargs.gid:
>                 uaargs.groupname = uaargs.gid
>                 uaargs.groupid = field[3] or uaargs.gid
>             elif uaargs.user_group is not False:
>                 uaargs.groupname = uaargs.LOGIN
>                 uaargs.groupid = field[3] or uaargs.LOGIN
>             else:
>                 uaargs.groupname = 'users'
>                 uaargs.groupid = field[3] or 'users'

Looks correct. However, you can simplify it to:

             if uaargs.gid:
                 uaargs.groupname = uaargs.gid
             elif uaargs.user_group is not False:
                 uaargs.groupname = uaargs.LOGIN
             else:
                 uaargs.groupname = 'users'
             uaargs.groupid = field[3] or uaargs.groupname

> Cheers,
> Andre'
> 
> > > > ? If neither --gid nor --user-group is specified, then gid is
> None, so
> > > > it
> > > > will do what you want already. IOW, unless the group name (gid)
> is
> > > > specified, a username-group is being created.
> > > >
> > > >
> > > > Cheers,
> > > > Andre'
> >
> > //Peter

//Peter



More information about the Openembedded-core mailing list