diff options
-rw-r--r-- | grp/putgrent.c | 9 | ||||
-rw-r--r-- | pwd/putpwent.c | 24 |
2 files changed, 24 insertions, 9 deletions
diff --git a/grp/putgrent.c b/grp/putgrent.c index cb9b6b1f79..8280b0cb2f 100644 --- a/grp/putgrent.c +++ b/grp/putgrent.c @@ -44,8 +44,13 @@ putgrent (gr, stream) 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); diff --git a/pwd/putpwent.c b/pwd/putpwent.c index 8b7767bd4a..a265719d36 100644 --- a/pwd/putpwent.c +++ b/pwd/putpwent.c @@ -20,7 +20,7 @@ #include <stdio.h> #include <pwd.h> -#define _S(x) x ? x : "" +#define _S(x) x ?: "" /* Write an entry to the given stream. This must know the format of the password file. */ @@ -35,11 +35,21 @@ putpwent (p, stream) 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; } |