diff options
author | Rob Landley <rob@landley.net> | 2016-08-18 21:33:27 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-08-18 21:33:27 -0500 |
commit | 3d64b0cc95c5957e53474c3e50f143c61a057104 (patch) | |
tree | 0c32cb7e4d104aa5d3c1f7ee0dcb7ac1f45f3a20 /toys/posix/chgrp.c | |
parent | 05e1582ec435932a25db21fd3ae71fbf62a4b45d (diff) | |
download | toybox-3d64b0cc95c5957e53474c3e50f143c61a057104.tar.gz |
Change xgetpwnamid/xgetgrnamid to xgetuid/xgetgid returning the id number
instead of a struct. This means it can return "12345" even if that user/group
doesn't exist in /etc/passwd and similar.
All the users were immediately dereferencing it to get pw_uid or gr_gid
anyway, so just return it directly and adjust the users. This fixes
things like "chown 12345:23456 filename".
Diffstat (limited to 'toys/posix/chgrp.c')
-rw-r--r-- | toys/posix/chgrp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/posix/chgrp.c b/toys/posix/chgrp.c index e0690c93..62e9eb1d 100644 --- a/toys/posix/chgrp.c +++ b/toys/posix/chgrp.c @@ -87,11 +87,11 @@ void chgrp_main(void) *(grp++) = 0; TT.group_name = grp; } - if (*own) TT.owner = xgetpwnamid(TT.owner_name = own)->pw_uid; + if (*own) TT.owner = xgetuid(TT.owner_name = own); } else TT.group_name = *toys.optargs; if (TT.group_name && *TT.group_name) - TT.group = xgetgrnamid(TT.group_name)->gr_gid; + TT.group = xgetgid(TT.group_name); for (s=toys.optargs+1; *s; s++) dirtree_flagread(*s, DIRTREE_SYMFOLLOW*!!(toys.optflags&(FLAG_H|FLAG_L)), |