From 3d64b0cc95c5957e53474c3e50f143c61a057104 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 18 Aug 2016 21:33:27 -0500 Subject: 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". --- toys/posix/cp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toys/posix/cp.c') diff --git a/toys/posix/cp.c b/toys/posix/cp.c index eafabcd1..0dd63a7d 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -499,8 +499,8 @@ void install_main(void) if (flags & FLAG_v) toys.optflags |= cp_flag_v(); if (flags & (FLAG_p|FLAG_o|FLAG_g)) toys.optflags |= cp_flag_p(); - if (TT.i.user) TT.uid = xgetpwnamid(TT.i.user)->pw_uid; - if (TT.i.group) TT.gid = xgetgrnamid(TT.i.group)->gr_gid; + if (TT.i.user) TT.uid = xgetuid(TT.i.user); + if (TT.i.group) TT.gid = xgetgid(TT.i.group); TT.callback = install_node; cp_main(); -- cgit v1.2.3