useradd-staticids: don't create username-group if gid is specified
PATCH 1/1 useradd-staticids: don't create username-group if gid is specified
From: André Draszik <[email protected]>
Adding distcc to an image, and having staticids enabled,
doesn't work as it causes a a superfluous 'distcc' group
being added using a conflicting GID, thus failing the
build:
| ERROR: distcc-3.2-r0 do_prepare_recipe_sysroot: distcc: groupadd command did not succeed.
Compared to other recipes, the distcc recipe only specifies --gid for the primary group, and doesn't specify --no-user-group, but when --gid is given, it doesn't make sense to create a matching username-group in addition, even if --no-user-group was not specified, and 'useradd' actually complains if --gid and --user-group are given both.
If only --gid is given, the current code in here effectively behaves as if --user-group was specified, taking the group-id of the username-group from the --gid parameter. This causes the error above, as we try to add a new group (distcc) with an existing group-id (nogroup).
This is contrary to the comment in this file just above, contrary to what useradd can do, contrary to behaviour without the useradd-staticids bbclass, and non-intuitive.
Change the code such that a username-group is only created if actually requested, of if a primary group using --gid was *not* specified.
--- meta/classes/useradd-staticids.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/useradd-staticids.bbclass +1 -1
@@ -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 uaargs.groupname = uaargs.LOGIN if user_group else uaargs.gid uaargs.groupid = field[3] or uaargs.gid or uaargs.groupname
Signature · 1 line
2.14.1
Quoted 50 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of André Draszik
Sent: den 4 september 2017 11:37
To: [email protected]
Subject: [OE-core] [PATCH] useradd-staticids: don't create username- group if gid is specifiedFrom: André Draszik <[email protected]>
Adding distcc to an image, and having staticids enabled,
doesn't work as it causes a a superfluous 'distcc' group
being added using a conflicting GID, thus failing the
build:
| ERROR: distcc-3.2-r0do_prepare_recipe_sysroot: distcc: groupadd command did not succeed.Compared to other recipes, the distcc recipe only specifies --gid for the primary group, and doesn't specify --no-user-group, but when --gid is given, it doesn't make sense to create a matching username-group in addition, even if --no-user-group was not specified, and 'useradd' actually complains if --gid and --user-group are given both.
If only --gid is given, the current code in here effectively behaves as if --user-group was specified, taking the group-id of the username-group from the --gid parameter. This causes the error above, as we try to add a new group (distcc) with an existing group-id (nogroup).
This is contrary to the comment in this file just above, contrary to what useradd can do, contrary to behaviour without the useradd-staticids bbclass, and non-intuitive.
Change the code such that a username-group is only created if actually requested, of if a primary group using --gid was *not* specified.
Signed-off-by André Draszik <[email protected]>--- meta/classes/useradd-staticids.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta/classes/useradd-staticids.bbclass +0
-0
meta/classes/useradd-staticids.bbclass def update_useradd_static_config(d): · line 105
Quoted 5 lines
meta/classes/useradd-staticids.bbclass +1
-1@@ -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.
Quoted 5 lines
meta/classes/useradd-staticids.bbclass +0
-1uaargs.groupname = uaargs.LOGIN if user_group else uaargs.gid uaargs.groupid = field[3] or uaargs.gid or uaargs.groupname --2.14.1
//Peter
Quoted 1 line · Peter Kjellerstedt
Quoted 1 line
[...]
Quoted 17 lines
Quoted 11 lines
meta/classes/useradd-staticids.bbclass +0
-1@@ -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_groupQuoted 3 lines
is True
+ user_group = uaargs.gid is None or uaargs.user_group is TrueHmm, I believe that should be:
Quoted 5 lines
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
? 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'
ping
Quoted 41 lines · André Draszik
Quoted 1 line · Peter Kjellerstedt
Quoted 1 line
[...]
Quoted 18 lines
Quoted 11 lines
meta/classes/useradd-staticids.bbclass +0
-1@@ -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 orQuoted 4 lines
uaargs.user_group
is True
+ user_group = uaargs.gid is None or uaargs.user_group is TrueHmm, I believe that should be:
Quoted 6 lines
user_group = uaargs.gid is None and uaargs.user_group is None
or uaargs.user_group is TrueI.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? 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'
Sorry, in mut now.
Ross
Quoted 50 lines · André Draszik
ping
Quoted 33 lines · André Draszik
Quoted 1 line · Peter Kjellerstedt
Quoted 1 line
[...]
Quoted 18 lines
Quoted 11 lines
meta/classes/useradd-staticids.bbclass +0
-1@@ -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 orQuoted 4 lines
uaargs.user_group
is True
+user_group= uaargs.gid is None or uaargs.user_group is
TrueHmm, I believe that should be:
Quoted 6 lines
user_group= uaargs.gid is None and uaargs.user_group is
None
or uaargs.user_group is TrueI.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 TrueQuoted 8 lines
? 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'--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Quoted 9 lines
-----Original Message-----
From: André Draszik [mailto:[email protected]]
Sent: den 20 september 2017 11:29
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH] useradd-staticids: don't create username-group if gid is specifiedping
Sorry, I forgot to reply to this.
Quoted 19 lines · André Draszik
Quoted 18 lines · Peter Kjellerstedt
Quoted 1 line
Quoted 1 line
[...]
Quoted 14 lines
meta/classes/useradd-staticids.bbclass def update_useradd_static_config(d): · line 105
Quoted 11 lines
meta/classes/useradd-staticids.bbclass +1
-1@@ -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 TrueHmm, I believe that should be:
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
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.
Quoted 7 lines
Quoted 7 lines
? 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
Quoted 40 lines · Peter Kjellerstedt
Quoted 9 lines
-----Original Message-----
From: André Draszik [mailto:[email protected]]
Sent: den 20 september 2017 11:29
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH] useradd-staticids: don't create username-group if gid is specifiedping
Sorry, I forgot to reply to this.
Quoted 28 lines · André Draszik
Quoted 27 lines · Peter Kjellerstedt
Quoted 1 line
Quoted 1 line
[...]
Quoted 22 lines
Quoted 11 lines
meta/classes/useradd-staticids.bbclass +0
-1@@ -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 orQuoted 3 lines
uaargs.user_group is True
+ user_group = uaargs.gid is None or uaargs.user_group is TrueHmm, 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.
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Hm, isn't this still the same as
user_group= uaargs.gid is None or uaargs.user_group is TrueNo, 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'
Cheers,
Andre'
Quoted 11 lines
Quoted 8 lines
Quoted 8 lines
? 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
Quoted 80 lines
-----Original Message-----
From: André Draszik [mailto:[email protected]]
Sent: den 21 september 2017 10:24
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH] useradd-staticids: don't create username-group if gid is specifiedQuoted 16 lines · Peter Kjellerstedt
Quoted 9 lines
-----Original Message-----
From: André Draszik [mailto:[email protected]]
Sent: den 20 september 2017 11:29
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH] useradd-staticids: don't create username-group if gid is specifiedping
Sorry, I forgot to reply to this.
Quoted 4 lines · André Draszik
Quoted 3 lines · Peter Kjellerstedt
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
[...]
Quoted 7 lines
meta/classes/useradd-staticids.bbclass def update_useradd_static_config(d): · line 102
Quoted 7 lines
meta/classes/useradd-staticids.bbclass +0
-0@@ -102,7 +102,7 @@ def update_useradd_static_config(d): # So if the implicit username-group creation ison,
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/classes/useradd-staticids.bbclass +0
-1then the implicit groupname (LOGIN) # is used, and we disable the user_group option. # - user_group = uaargs.user_group is None oruaargs.user_group is True
+ user_group = uaargs.gid is None oruaargs.user_group
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
is True
Hmm, I believe that should be:
user_group = uaargs.gid is None and
uaargs.user_group is
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
None or uaargs.user_group is True
I.e., if neither --gid nor --user-group is specified, then it
should
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
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 TrueNo, 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 conflictuseradd --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 createdSp, what about this instead:
Quoted 9 lines
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
Quoted 15 lines
Cheers,
Andre'Quoted 1 line
Quoted 1 line
Quoted 1 line
? If neither --gid nor --user-group is specified, then gid is
None, so
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
it
will do what you want already. IOW, unless the group name (gid)is
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
specified, a username-group is being created.
Cheers,
Andre'//Peter
//Peter
PATCH v2 1/1 useradd-staticids: don't create username-group if gid is specified
In reply to André DraszikFrom: André Draszik <[email protected]>
Adding distcc to an image, and having staticids enabled,
doesn't work as it causes a a superfluous 'distcc' group
being added using a conflicting GID, thus failing the
build:
| ERROR: distcc-3.2-r0 do_prepare_recipe_sysroot: distcc: groupadd command did not succeed.
Compared to other recipes, the distcc recipe only specifies --gid for the primary group, and doesn't specify --no-user-group, but when --gid is given, it doesn't make sense to create a matching username-group in addition, even if --no-user-group was not specified, and 'useradd' actually complains if --gid and --user-group are given both.
If only --gid is given, the current code in here effectively behaves as if --user-group was specified, taking the group-id of the username-group from the --gid parameter. This causes the error above, as we try to add a new group (distcc) with an existing group-id (nogroup).
This is contrary to the comment in this file just above, contrary to what useradd can do, contrary to behaviour without the useradd-staticids bbclass, and non-intuitive.
Change the code such that a username-group is only created
- if a primary group using --gid was not specified, or
- if --no-user-group was not specified
To be in line with useradd, if gid is not given, and --no-user-group is given, we add the user to the group 'users', which mimics useradd's behaviour.
---
v2: bring this even more in line with useradd
--- meta/classes/useradd-staticids.bbclass | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
meta/classes/useradd-staticids.bbclass +7 -3
@@ -102,9 +102,13 @@ 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 - uaargs.groupname = uaargs.LOGIN if user_group else uaargs.gid - uaargs.groupid = field[3] or uaargs.gid or uaargs.groupname + 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 if uaargs.groupid and uaargs.gid != uaargs.groupid: newgroup = None
Signature · 1 line
2.14.1