Bug 60304 - 'usermod' cannot add more than 800 users into a group.
'usermod' cannot add more than 800 users into a group.
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: shadow-utils (Show other bugs)
7.2
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Eido Inoue
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2002-02-24 22:32 EST by Mitsuo Hamada
Modified: 2007-04-18 12:40 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-27 14:12:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
My proposed patch fixing the issue. (440 bytes, patch)
2002-10-03 17:35 EDT, Leszek Matok
no flags Details | Diff

  None (edit)
Description Mitsuo Hamada 2002-02-24 22:32:36 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)

Description of problem:
'usermod' cannot add more than 800 users into a group.

# cat account.txt
a0001
a0002
.
.
.
a0999
a1000

# addgroup hello

# for acc in `cat account.txt`
>do
>adduser $acc
>usermod -G hello $acc
>done

After executing above shell script, I found /etc/group was broken.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.make account list more than 800.
2.addgroup hello
3.execute script written bellow.
for acc in `cat account.txt`
do
adduser $acc
usermod -G hello $acc
done
	

Actual Results:  /etc/group file was broken.

Expected Results:  all users are added into 'hello' group.

Additional info:
Comment 1 Need Real Name 2002-06-18 05:53:03 EDT
Problem looks to be in a 4096 byte barrier somewhere - I found this problem 
also to exist when I add a user with adduser and secundairy groups; right at a 
4096 byte length line it's broken and the groupfile is truncated (and thus 
broken)
Comment 2 Daniel Drown 2002-06-19 13:56:33 EDT
I ran into this as well.

fix is in shadow cvs at:
http://cvs.pld.org.pl/shadow/lib/commonio.c?r1=1.19&r2=1.20

comment from the above fix:
2001-09-07  Tomasz K3oczko  <kloczek@pld.org.pl>
	* lib/commonio.c, NEWS:
	Fix bug discovered and fixed by Marcel Ritter <Marcel.Ritter@rrze.uni-erlangen.de>
	Due to a big buffer size in lib/commonio.c this error does only appear
	if a line gets longer than 4096 bytes (there are probably very few people
	stumbling across this).
	Ths bug can be exposed by trashing /etc/groups file using useradd with script:
		#!/bin/sh
		typeset -i NUM
		NUM=0
		groupadd demogroup
		while [ $NUM -le 1000 ]; do
		   useradd -g demogroup -G demogroup -p "NONE" user$NUM
		   NUM=$NUM+1
		done

After applying the above patch to the source, I was able to create a group that
exceeded 4096 characters with the usermod tool.
Comment 3 Daniel Drown 2002-07-12 20:01:35 EDT
this also affects RedHat 7.3
Comment 4 Leszek Matok 2002-10-03 17:33:49 EDT
This affects newest RawHide packages, and Red Hat 8.0. I have a multiuser system
and the current number of users causes useradd to delete all my users' groups,
truncating the 'users' group. I'm attaching my own patch applying clearly to
shadow-utils-20000902-12 sources, which I came up with when trying to understand
what is happening to my system. It doesn't use any dynamically allocated
integer, contrary to PLD patch. This also isn't the perfect patch. It allocates
4096 bytes and reads at most 4095 at a time, so on a system with one /etc/group
line having 8192 characters, it wastes 2 bytes. What a pity :) Works for me now,
but I'm really disappointed on Red Hat having the patch since almost two years
(take a look at bug 3809!) and doing nothing, when the tools they provide delete
their users' and clients' data...
Comment 5 Leszek Matok 2002-10-03 17:35:21 EDT
Created attachment 78444 [details]
My proposed patch fixing the issue.
Comment 6 Leszek Matok 2002-10-03 17:48:55 EDT
Oh, by the way, building an rpm with my patch, I have noticed:
useradd.o(.text+0x5c4): the use of `mktemp' is dangerous, better use `mkstemp'
Maybe it's harmful, but also doesn't give me the sense of security a Linux
distribution should provide.
Comment 7 Leszek Matok 2002-10-03 18:08:19 EDT
I meant "harmless", please excuse me.
Comment 8 Dave Brown 2003-02-16 21:29:05 EST
Any ideas as to when we can expect this bug fixed?
Comment 9 Per Steinar Iversen 2003-03-21 08:17:36 EST
Just discovered this bug the hard way on RedHat 8.0, a trashed /etc/group file.
Not very nice for large linux servers. This is really bad for enterprise sized
servers. Will this be fixed in version 8.1 ?
Comment 10 Dave Brown 2003-04-28 20:22:38 EDT
This appears to be fixed in RedHat 9 however it is still broken in RedHat 7.2. 
Any ideas as to whether this will be fixed in 7.2 seeing as it goes End Of Life 
at the end of this year?

Note You need to log in before you can comment on or make changes to this bug.