aboutsummaryrefslogtreecommitdiff
path: root/toys/pending
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-11-28 21:06:15 -0600
committerRob Landley <rob@landley.net>2013-11-28 21:06:15 -0600
commit5ec4ab3113dcc813b6040d7ded38e297df99dc0e (patch)
treeafad4e181b9b8ab64496ed7d001c444c245ae429 /toys/pending
parent9e44a5841f0ab9bc03cefb5631c80f3e4e5a60fe (diff)
downloadtoybox-5ec4ab3113dcc813b6040d7ded38e297df99dc0e.tar.gz
Add xgetpwnam() to lib/xwrap.c.
Diffstat (limited to 'toys/pending')
-rw-r--r--toys/pending/groupadd.c3
-rw-r--r--toys/pending/tftpd.c6
2 files changed, 2 insertions, 7 deletions
diff --git a/toys/pending/groupadd.c b/toys/pending/groupadd.c
index ab290e54..8ff539eb 100644
--- a/toys/pending/groupadd.c
+++ b/toys/pending/groupadd.c
@@ -79,8 +79,7 @@ void groupadd_main(void)
if (toys.optc == 2) { //add user to group
//toys.optargs[0]- user, toys.optargs[1] - group
- if (!getpwnam(toys.optargs[0]))
- error_exit("user '%s' does not exist", toys.optargs[0]);
+ xgetpwnam(*toys.optargs);
if (!(grp = getgrnam(toys.optargs[1])))
error_exit("group '%s' does not exist", toys.optargs[1]);
if (!grp->gr_mem) entry = xmsprintf("%s", *toys.optargs);
diff --git a/toys/pending/tftpd.c b/toys/pending/tftpd.c
index 3e7264b5..ea8d3eac 100644
--- a/toys/pending/tftpd.c
+++ b/toys/pending/tftpd.c
@@ -249,11 +249,7 @@ void tftpd_main(void)
error_exit(NULL);
}
- if (toys.optflags & FLAG_u) {
- struct passwd *pw = getpwnam(TT.user);
- if (!pw) error_exit("unknown user %s", TT.user);
- TT.pw = pw;
- }
+ if (TT.user) TT.pw = xgetpwnam(TT.user);
if (*toys.optargs) {
if (chroot(*toys.optargs))
perror_exit("can't change root directory to '%s'", *toys.optargs);