diff options
author | Rob Landley <rob@landley.net> | 2015-03-12 14:21:33 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-03-12 14:21:33 -0500 |
commit | be4048dd2509f2b9e968a4d03c06050d847971d3 (patch) | |
tree | 298af9767d25d5922c23a4752e03fc7251e4f697 /toys/other/makedevs.c | |
parent | 9ff639cef3c2f73ce876c6cab4c4f517e512bf13 (diff) | |
download | toybox-be4048dd2509f2b9e968a4d03c06050d847971d3.tar.gz |
Make find accept numeric uid/gid, and simplify makedevs using the new infrastructure.
Diffstat (limited to 'toys/other/makedevs.c')
-rw-r--r-- | toys/other/makedevs.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/toys/other/makedevs.c b/toys/other/makedevs.c index f6e7ece9..0d20a57d 100644 --- a/toys/other/makedevs.c +++ b/toys/other/makedevs.c @@ -41,7 +41,7 @@ GLOBALS( void makedevs_main() { - int value, fd = 0, line_no, i; + int fd = 0, line_no, i; char *line = NULL; // Open file and chdir, verbosely @@ -78,27 +78,8 @@ void makedevs_main() continue; } else mode |= (mode_t[]){S_IFIFO, S_IFCHR, S_IFBLK, 0, 0}[i]; - if (*user) { - struct passwd *usr; - - if (!(usr = getpwnam(user)) && isdigit(*user)) { - sscanf(user, "%u", &value); - usr = xgetpwuid(value); - } - if (!usr) error_exit("bad user '%s'", user); - uid = usr->pw_uid; - } else uid = getuid(); - - if (*group) { - struct group *grp; - - if (!(grp = getgrnam(group)) && isdigit(*group)) { - sscanf (group, "%u", &value); - grp = getgrgid(value); - } - if (!grp) error_exit("bad group '%s'", group); - gid = grp->gr_gid; - } else gid = getgid(); + uid = *user ? xgetpwnamid(user)->pw_uid : getuid(); + gid = *group ? xgetgrnamid(group)->gr_gid : getgid(); while (*node == '/') node++; // using relative path |