aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-11-17 12:13:44 -0600
committerRob Landley <rob@landley.net>2018-11-17 12:13:44 -0600
commit2559f9dd6b7eedd97e029c80b4b8ba72309db45b (patch)
tree1274888dda460a85edf0b0f1a268b93b2eb69190 /toys/posix
parent7f75b87aed07691405efeff96efa6d917e2008da (diff)
downloadtoybox-2559f9dd6b7eedd97e029c80b4b8ba72309db45b.tar.gz
Volodymyr Medvid reported that install -d doesn't honor -o or -g.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/cp.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 373ac13e..97cccb2f 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -487,9 +487,14 @@ void install_main(void)
char **ss;
int flags = toys.optflags;
+ TT.uid = TT.i.o ? xgetuid(TT.i.o) : -1;
+ TT.gid = TT.i.g ? xgetgid(TT.i.g) : -1;
+
if (flags & FLAG_d) {
for (ss = toys.optargs; *ss; ss++) {
if (mkpathat(AT_FDCWD, *ss, 0777, 3)) perror_msg_raw(*ss);
+ if (flags & (FLAG_g|FLAG_o))
+ if (lchown(*ss, TT.uid, TT.gid)) perror_msg("chown '%s'", *ss);
if (flags & FLAG_v) printf("%s\n", *ss);
}
@@ -509,9 +514,6 @@ 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.o) TT.uid = xgetuid(TT.i.o);
- if (TT.i.g) TT.gid = xgetgid(TT.i.g);
-
TT.callback = install_node;
cp_main();
}