From 2559f9dd6b7eedd97e029c80b4b8ba72309db45b Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 17 Nov 2018 12:13:44 -0600 Subject: Volodymyr Medvid reported that install -d doesn't honor -o or -g. --- toys/posix/cp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'toys/posix/cp.c') 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(); } -- cgit v1.2.3