* [PATCH] putgrent/putpwent and +/- entries
@ 2005-01-11 10:55 Thorsten Kukuk
2005-01-12 3:22 ` Ulrich Drepper
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Kukuk @ 2005-01-11 10:55 UTC (permalink / raw)
To: libc-hacker
Hi,
putpwent and putgrent should not write a '0' as user/group id if an
entry starting with + or - is written. We have a check in the get*
code to ignore this, but it is better to not write the values and
let the fields empty.
Thorsten
2005-01-11 Thorsten Kukuk <kukuk@suse.de>
* grp/putgrent.c (putgrent): Don't write 0 as group
ID if groupname starts with + or -.
* pwd/putpwent.c (putpwent): Don't write 0 as user or
group ID if user name starts with + or -.
--- grp/putgrent.c
+++ grp/putgrent.c 2003/10/15 11:14:18
@@ -44,8 +44,13 @@
flockfile (stream);
- retval = fprintf (stream, "%s:%s:%u:",
- gr->gr_name, _S (gr->gr_passwd), gr->gr_gid);
+ if (gr->gr_name[0] == '+' || gr->gr_name[0] == '-')
+ retval = fprintf (stream, "%s:%s::",
+ gr->gr_name, _S (gr->gr_passwd));
+ else
+ retval = fprintf (stream, "%s:%s:%lu:",
+ gr->gr_name, _S (gr->gr_passwd),
+ (unsigned long int) gr->gr_gid);
if (__builtin_expect (retval, 0) < 0)
{
funlockfile (stream);
--- pwd/putpwent.c
+++ pwd/putpwent.c 2003/10/15 11:10:20
@@ -35,11 +35,21 @@
return -1;
}
- if (fprintf (stream, "%s:%s:%lu:%lu:%s:%s:%s\n",
- p->pw_name, _S (p->pw_passwd),
- (unsigned long int) p->pw_uid, (unsigned long int) p->pw_gid,
- _S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
- return -1;
-
+ if (p->pw_name[0] == '+' || p->pw_name[0] == '-')
+ {
+ if (fprintf (stream, "%s:%s:::%s:%s:%s\n",
+ p->pw_name, _S (p->pw_passwd),
+ _S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
+ return -1;
+ }
+ else
+ {
+ if (fprintf (stream, "%s:%s:%lu:%lu:%s:%s:%s\n",
+ p->pw_name, _S (p->pw_passwd),
+ (unsigned long int) p->pw_uid,
+ (unsigned long int) p->pw_gid,
+ _S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
+ return -1;
+ }
return 0;
}
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE Linux Products GmbH Maxfeldstr. 5 D-90409 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] putgrent/putpwent and +/- entries
2005-01-11 10:55 [PATCH] putgrent/putpwent and +/- entries Thorsten Kukuk
@ 2005-01-12 3:22 ` Ulrich Drepper
2005-01-12 9:35 ` Thorsten Kukuk
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Drepper @ 2005-01-12 3:22 UTC (permalink / raw)
To: Thorsten Kukuk; +Cc: libc-hacker
[-- Attachment #1: Type: text/plain, Size: 628 bytes --]
Thorsten Kukuk wrote:
> putpwent and putgrent should not write a '0' as user/group id if an
> entry starting with + or - is written. We have a check in the get*
> code to ignore this, but it is better to not write the values and
> let the fields empty.
I don't have a problem in principle with this but it needs to be
documented that user/group names starting with +- are everywhere treated
special. Provide some text for the manual.
Also, the copyrights in the files weren't updated and the changelog
format was wrong.
--
⧠Ulrich Drepper ⧠Red Hat, Inc. ⧠444 Castro St ⧠Mountain View, CA â
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] putgrent/putpwent and +/- entries
2005-01-12 3:22 ` Ulrich Drepper
@ 2005-01-12 9:35 ` Thorsten Kukuk
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Kukuk @ 2005-01-12 9:35 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: libc-hacker
On Tue, Jan 11, Ulrich Drepper wrote:
> Thorsten Kukuk wrote:
>
> >putpwent and putgrent should not write a '0' as user/group id if an
> >entry starting with + or - is written. We have a check in the get*
> >code to ignore this, but it is better to not write the values and
> >let the fields empty.
>
> I don't have a problem in principle with this but it needs to be
> documented that user/group names starting with +- are everywhere treated
> special. Provide some text for the manual.
2005-01-12 Thorsten Kukuk <kukuk@suse.de>
* manual/users.texi (Writing a User Entry): Document behavior
of putpwent if user name starts with + or -.
--- manual/users.texi 6 Apr 2002 01:01:48 -0000 1.34
+++ manual/users.texi 12 Jan 2005 09:33:20 -0000
@@ -1690,6 +1690,9 @@
would inevitably leave out much of the important information.
@c Then how are programmers to modify the password file? -zw
+This implementation leaves the group and user ID field empty if the
+group or user name starts with a - or +.
+
The function @code{putpwent} is declared in @file{pwd.h}.
@end deftypefun
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE Linux Products GmbH Maxfeldstr. 5 D-90409 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-01-12 9:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-11 10:55 [PATCH] putgrent/putpwent and +/- entries Thorsten Kukuk
2005-01-12 3:22 ` Ulrich Drepper
2005-01-12 9:35 ` Thorsten Kukuk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).