diff options
author | Rob Landley <rob@landley.net> | 2013-11-28 21:06:15 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2013-11-28 21:06:15 -0600 |
commit | 5ec4ab3113dcc813b6040d7ded38e297df99dc0e (patch) | |
tree | afad4e181b9b8ab64496ed7d001c444c245ae429 /toys/lsb/passwd.c | |
parent | 9e44a5841f0ab9bc03cefb5631c80f3e4e5a60fe (diff) | |
download | toybox-5ec4ab3113dcc813b6040d7ded38e297df99dc0e.tar.gz |
Add xgetpwnam() to lib/xwrap.c.
Diffstat (limited to 'toys/lsb/passwd.c')
-rw-r--r-- | toys/lsb/passwd.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/toys/lsb/passwd.c b/toys/lsb/passwd.c index 1784c049..f3338361 100644 --- a/toys/lsb/passwd.c +++ b/toys/lsb/passwd.c @@ -103,17 +103,15 @@ void passwd_main(void) int ret = -1; myuid = getuid(); - if ((myuid) && (toys.optflags & (FLAG_l | FLAG_u | FLAG_d))) - error_exit("You need to be root to do these actions\n"); + if (myuid && (toys.optflags & (FLAG_l | FLAG_u | FLAG_d))) + error_exit("Not root"); - pw = getpwuid(myuid); - if (!pw) error_exit("Unknown uid '%u'",myuid); + pw = xgetpwuid(myuid); - if (toys.optargs[0]) name = toys.optargs[0]; + if (*toys.optargs) name = toys.optargs[0]; else name = xstrdup(pw->pw_name); - pw = getpwnam(name); - if (!pw) error_exit("Unknown user '%s'",name); + pw = xgetpwnam(name); if (myuid && (myuid != pw->pw_uid)) error_exit("You need to be root to change '%s' password\n", name); |