OSDN Git Service

In cp -a, don't complain if non-root user can't chown, failure is expected.
authorRob Landley <rob@landley.net>
Tue, 31 May 2016 22:33:23 +0000 (17:33 -0500)
committerRob Landley <rob@landley.net>
Tue, 31 May 2016 22:33:23 +0000 (17:33 -0500)
toys/posix/cp.c

index d21af2f..06c537e 100644 (file)
@@ -318,7 +318,7 @@ int cp_node(struct dirtree *try)
         rc = fchownat(cfd, catch, try->st.st_uid, try->st.st_gid,
                       AT_SYMLINK_NOFOLLOW);
       else rc = fchown(fdout, try->st.st_uid, try->st.st_gid);
-      if (rc) {
+      if (rc && !geteuid()) {
         char *pp;
 
         perror_msg("chown '%s'", pp = dirtree_path(try, 0));