FS#16092 - [shadow] groupadd always add system groups with gid=99
Attached to Project:
Arch Linux
Opened by Anton Leontiev (bunder) - Tuesday, 08 September 2009, 05:39 GMT
Last edited by Allan McRae (Allan) - Sunday, 28 February 2010, 04:34 GMT
Opened by Anton Leontiev (bunder) - Tuesday, 08 September 2009, 05:39 GMT
Last edited by Allan McRae (Allan) - Sunday, 28 February 2010, 04:34 GMT
|
Details
Description:
When I try to add system group with default /etc/login.defs it always creates group with gid=99, even if '-o' option isn't specified and group with this gid is already exist (nobody). $ sudo groupadd --system test $ getent group test test:x:99: This happens because of login.defs file provided with 'shadow' package. In this file following value are defined: UID_MIN 1000 UID_MAX 60000 GID_MIN 100 GID_MAX 60000 While the group manipulation utils by default set SYS_GID_MIN to 101 and SYS_GID_MAX to GID_MIN-1 if GID_MIN is defined or to 999 if isn't. Thus in present configuration 'groupadd --system' searches for free gid's in range from GID_MIN=101 to GID_MAX=99!!! So it always sets gid for new group to 99. (This is of course error of shadow, because it must report an error in this case as I think.) I see two ways to resolve this problem: 1. Change the default value of GID_MIN to 1000. This is reasonable as gids within range [100,1000] already used as system gids by many packages (policykit, for example). 2. Introduce SYS_GID_MAX, SYS_GID_MIN to provided 'login.defs' explicitly. I think we should apply both changes. Additional info: * package version(s): shadow 4.1.4.2-1 Steps to reproduce: When using default login.defs try to run 'groupadd --system newgroup' as root. |
This task depends upon
Closed by Allan McRae (Allan)
Sunday, 28 February 2010, 04:34 GMT
Reason for closing: Fixed
Additional comments about closing: shadow-4.1.4.2-2
Sunday, 28 February 2010, 04:34 GMT
Reason for closing: Fixed
Additional comments about closing: shadow-4.1.4.2-2
Gid of 'hal' group and other common groups have the common defaults. So all gids below 100 are reserved as I understand.
How can I find free gid for the new group above the 100. Some gid are reserved by policykit and others. I've decided that using 'groupadd --system' is the most correct way. And I really don't understand why gid for policykit is hardcoded.
And about GID_MIN=500. What arguments you have for this value. I'm asking because the default value of 'shadow' itself is 1000, and why you want to set 500?
% grep 99 /etc/group
nobody::99:
svn:x:99:
It breaks lots of things: no author/date/message in commits for example. You will have packages like gitosis unusable too (which use useradd) because of this.
Or we can move lower boundary to, say, 150. And then say, that packages like policykit, which are "very" system packages, have hardcoded gids in the range [101,150]. But in this case I don't understand how one can find free gid in this range to add its own "very" system package.
So I am for the first solution. What do you think about this?
Shadow is a little bit responsible because if you use gid 1 to 15 and have a gid 85, groupadd will never use 16 to 84 (and there is no way to do it).
For me, the good way to manage uid/gid is:
1-99: reserved accounts (hardcoded)
* only for well know services (general purpose)
* a predefined list should exist somewhere on the system so packagers can refer to it
100-999: system accounts (SYS_UID_MIN = SYS_GID_MIN = 100, SYS_UID_MAX = SYS_GID_MAX = 999 in /etc/login.defs)
* for accounts automatically created by package (ie. getent user snort || useradd -s snort)
* remove all hardcoded uid/gid from pkg.install files (grep -r 'useradd.*-u *[0-9]' /var/abs)
1000-60000: normal accounts (UID_MIN = GID_MIN = 1000, UID_MAX = GID_MAX = 60000 in /etc/login.defs)
There's a lot of ideas floating around here. Could someone summarize them into a patch against the files from ABS?
According to http://wiki.archlinux.org/index.php/UID_and_GID_list, we need to deal with the packages for these groups:
policykit, deluge, cherokee, vboxusers, partimag, gdm, qmail, nofiles
% grep -r 'useradd.*-u *[0-9][0-9][0-9]' /var/abs
% grep -r 'groupadd.*-g *[0-9][0-9][0-9]' /var/abs
in format package:user/group:uid/gid, we have:
* useradd
extra/deluge:deluge:125
extra/gdm:gdm:120
extra/policykit:102:policykit
community/dspam:dspam:115
community/partimage:partimag:110
community/postgrey:postgrey:314
community/pulseaudio:pulse:130
* groupadd
extra/deluge:deluge:125
extra/gdm:gdm:120
extra/policykit:policykit:102
community/dspam:dspam:115
community/partimage:partimag:110
community/postgrey:postgrey:314
community/vlock:vlock:129
community/pulseaudio:pulse:130
community/pulseaudio:pulse-access:131
community/pulseaudio:pulse-rt:132
community/adesklets:adesklets:107
SYS_UID_MIN 100
SYS_UID_MAX 999
e.g. I could "groupadd --system" a few times making group 102 and then install policykit which specifically creates group 102, resulting in "two" group 102's.
The highest hardcoded id seems to be postgrey at 314.