Bug 73450 - Cannot create lines in /etc/group longer than 8k
Cannot create lines in /etc/group longer than 8k
Product: Red Hat Linux
Classification: Retired
Component: shadow-utils (Show other bugs)
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Eido Inoue
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2002-09-04 16:31 EDT by Charlie Brady
Modified: 2007-04-18 12:46 EDT (History)
1 user (show)

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

Attachments (Terms of Use)

  None (edit)
Description Charlie Brady 2002-09-04 16:31:33 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.0 (X11; Linux i686; U;) Gecko/20020408

Description of problem:
Lines in /etc/group are truncated if enough users are added to a group to make
the line length > 8k.

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

How reproducible:

Steps to Reproduce:
Instal RH linux, and run this program:

#! /usr/bin/perl -w

use strict;

foreach my $user (0..1100)
	$user = "user$user";
	print "Doing user $user\n";
	system("/usr/sbin/useradd", "$user");
	system("/usr/sbin/usermod", "-G", "shared", "$user");


Actual Results: 

Expected Results: 

Additional info:

This was noticed, and a fix promised, long ago:


> I'm using #4 for my PAM'ified systems now. Still need to "port" some
> of the reliability fixes I did for libpwdb to the password file I/O
> routines found in shadow-utils.

Just curious, what are these fixes? These routines were meant to be
quite reliable, though I have received one bug report recently: very
long lines (>8K characters) in group files are truncated (this is a
very old bug, but reported after shadow-20000826 was released, so I'll
probably make another bugfix release soon, probably the last one from
me after all these years...). 

The bug is fixed in the PLD version of the package:


- fix bug discovered and fixed by Marcel Ritter
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:
	typeset -i NUM
	groupadd demogroup
	while [ $NUM -le 1000 ]; do
	   useradd -g demogroup -G demogroup -p "NONE" user$NUM

This patch to lib/commonio.c is the relevant bit of their fix:

 	while (db->ops->fgets(buf, buflen, db->fp)) {
	while (!(cp = strrchr(buf, '\n')) && !feof(db->fp)) {
		int len;
		buflen += BUFLEN;
		cp = (char *) realloc(buf, buflen);
		if (!cp)
			goto cleanup_buf;
		buf = cp;
		db->ops->fgets(buf + buflen - BUFLEN, BUFLEN, db->fp);
		len = strlen(buf);
		db->ops->fgets(buf + len, buflen - len, db->fp);
	if ((cp = strrchr(buf, '\n')))
		*cp = '\0';
Comment 1 Leszek Matok 2002-10-03 17:39:14 EDT
Please take a look at bug 60304, it's duplicate (and these two are duplicates of
bug 3809), I have attached my patch there.

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