summaryrefslogtreecommitdiff
path: root/pwd
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2005-07-18 03:08:46 +0000
committerRoland McGrath <roland@gnu.org>2005-07-18 03:08:46 +0000
commit79e7ba1611c2002e376f972131e705f30142ef68 (patch)
treed8d95a6c258b919eb08def2c74005638c7d91a46 /pwd
parenta8f2e5659fe008d2c38e349ed5315e43fbd0e0d5 (diff)
2005-01-11 Thorsten Kukuk <kukuk@suse.de>
[BZ #1099] * 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 -.
Diffstat (limited to 'pwd')
-rw-r--r--pwd/putpwent.c24
1 files changed, 17 insertions, 7 deletions
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;
}