This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFC and patch: pw_comment


There's something puzzling in libc/unix/getpwent.c: it uses a field
pw_comment which doesn't seem to exist on any Unix I know. Furthermore,
the sscanf format string lacks one element, so I assume that pw_comment
was added without ever using or testing the whole thing. (There's no
ChangeLog or newlib-cvs list entry either.)

I've attached a patch that simply removes the comment field and sets
pw_comment to an empty string. If there is a good reason to keep the
comment thing around, all this would have to become conditional instead.

- Werner

---------------------------------- ChangeLog ----------------------------------

2000-08-23  Werner Almesberger  <Werner.Almesberger@epfl.ch>
	* libc/unix/getpwent.c (getpwnam, getpwuid, getpwent): removed
	(broken) support for non-existent /etc/passwd field "comment"

------------------------------------ patch ------------------------------------

--- orig/newlib/libc/unix/getpwent.c	Wed Aug 23 09:36:48 2000
+++ src/newlib/libc/unix/getpwent.c	Wed Aug 23 09:36:50 2000
@@ -12,7 +12,6 @@
 
 static char logname[8];
 static char password[1024];
-static char comment[1024];
 static char gecos[1024];
 static char dir[1024];
 static char shell[1024];
@@ -33,11 +32,11 @@
     {
       sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
 	      logname, password, &pw_passwd.pw_uid,
-	      &pw_passwd.pw_gid, comment, gecos,
+	      &pw_passwd.pw_gid, gecos,
 	      dir, shell);
       pw_passwd.pw_name = logname;
       pw_passwd.pw_passwd = password;
-      pw_passwd.pw_comment = comment;
+      pw_passwd.pw_comment = "";
       pw_passwd.pw_gecos = gecos;
       pw_passwd.pw_dir = dir;
       pw_passwd.pw_shell = shell;
@@ -67,11 +66,11 @@
     {
       sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
 	      logname, password, &pw_passwd.pw_uid,
-	      &pw_passwd.pw_gid, comment, gecos,
+	      &pw_passwd.pw_gid, gecos,
 	      dir, shell);
       pw_passwd.pw_name = logname;
       pw_passwd.pw_passwd = password;
-      pw_passwd.pw_comment = comment;
+      pw_passwd.pw_comment = "";
       pw_passwd.pw_gecos = gecos;
       pw_passwd.pw_dir = dir;
       pw_passwd.pw_shell = shell;
@@ -99,11 +98,11 @@
 
   sscanf (buf, "%[^:]:%[^:]:%d:%d:%[^:]:%[^:]:%s\n",
 	  logname, password, &pw_passwd.pw_uid,
-	  &pw_passwd.pw_gid, comment, gecos,
+	  &pw_passwd.pw_gid, gecos,
 	  dir, shell);
   pw_passwd.pw_name = logname;
   pw_passwd.pw_passwd = password;
-  pw_passwd.pw_comment = comment;
+  pw_passwd.pw_comment = "";
   pw_passwd.pw_gecos = gecos;
   pw_passwd.pw_dir = dir;
   pw_passwd.pw_shell = shell;

-- 
  _________________________________________________________________________
 / Werner Almesberger, ICA, EPFL, CH       werner.almesberger@ica.epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]