aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb/passwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'toys/lsb/passwd.c')
-rw-r--r--toys/lsb/passwd.c12
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);