putgrent writes incorrect /etc/group
michael.schaefer@dlr.de
michael.schaefer@dlr.de
Thu Apr 1 00:00:00 GMT 1999
Originator: Michael Schaefer
Organization:
Institute for Structural Mechanics
German Aerospace Research Center
Braunschweig
Confidential: no
Synopsis: putgrent (from grp/putgrent.c) writes incorrect /etc/group
Severity: serious
Priority: medium
Category: libc
Class: sw-bug
Release: libc-2.0.111
Environment:
libshadow-981228
Host type: i586-pc-linux-gnu
System: Linux shadowlands 2.2.0-final #2 Sat Jan 23 13:40:39 CET 1999 i586 unknown
Architecture: i586
Addons: crypt linuxthreads
Build CC: gcc
Compiler version: pgcc-2.91.60 19981201 (egcs-1.1.1 release)
Kernel headers: 2.2.0-final
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio
Description:
The function 'putgrent' from grp/putgrent.c is broken. Using it entries in /etc/group get one : too much,
right before the list of group members.
Example:
Line before using putgrent:
www::100:mica
Line after using putgrent to add 'testuser':
www::100::mica,testuser
This results in group 'www' not beeing recognized by the system as group for user testuser.
It happend using the shadow-980724 and shadow-981228 package, which uses glibc-provided putgrent if available.
There is a putgrent function with the shadow-package (lib/putgrent.c) which works all right, which you can use
to compare with the code within glibc2 and my patch below.
How-To-Repeat:
Install shadow-981228 (or shadow-980724) with glibc2-2.1.111 beeing installed
Then use gpasswd to add a user to a group like
gpasswd -a <user> <group>
Or add a user using useradd.
Check /etc/group for the problem
Fix:
Fixing it is rather easy, patch below:
---------- CUT HERE -----------
--- putgrent.c.orig Sat Jan 23 19:27:45 1999
+++ putgrent.c Sat Jan 23 19:27:32 1999
@@ -54,7 +54,7 @@
int i;
for (i = 0 ; gr->gr_mem[i] != NULL; i++)
- if (fprintf (stream, "%c%s", i == 0 ? ':' : ',', gr->gr_mem[i]) < 0)
+ if (fprintf (stream, i == 0 ? "%s" : ",%s", gr->gr_mem[i]) < 0)
{
/* What else can we do? */
funlockfile (stream);
---------- CUT HERE -----------
More information about the Libc-alpha
mailing list