Mercurial > hg > toybox
comparison toys/posix/id.c @ 1130:6df194c6de88 draft
Add xgetpwnam() to lib/xwrap.c.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 28 Nov 2013 21:06:15 -0600 |
parents | c644f85444d0 |
children | 0f42d83199a9 |
comparison
equal
deleted
inserted
replaced
1129:c644f85444d0 | 1130:6df194c6de88 |
---|---|
65 | 65 |
66 flags = toys.optflags; | 66 flags = toys.optflags; |
67 | 67 |
68 // check if a username is given | 68 // check if a username is given |
69 if (username) { | 69 if (username) { |
70 if (!(pw = getpwnam(username))) | 70 pw = xgetpwnam(username); |
71 error_exit("no such user '%s'", username); | |
72 uid = euid = pw->pw_uid; | 71 uid = euid = pw->pw_uid; |
73 gid = egid = pw->pw_gid; | 72 gid = egid = pw->pw_gid; |
74 if (cmd_groups) | 73 if (cmd_groups) printf("%s : ", pw->pw_name); |
75 printf("%s : ", pw->pw_name); | |
76 } | 74 } |
77 | 75 |
78 i = flags & FLAG_r; | 76 i = flags & FLAG_r; |
79 pw = xgetpwuid(i ? uid : euid); | 77 pw = xgetpwuid(i ? uid : euid); |
80 if (flags & FLAG_u) s_or_u(pw->pw_name, pw->pw_uid, 1); | 78 if (flags & FLAG_u) s_or_u(pw->pw_name, pw->pw_uid, 1); |