OSDN Git Service

cp: set rc properly
authorXiang Fan <sfanxiang@gmail.com>
Wed, 1 Feb 2017 15:50:23 +0000 (15:50 +0000)
committerXiang Fan <sfanxiang@gmail.com>
Wed, 1 Feb 2017 15:51:22 +0000 (15:51 +0000)
This fixes the failure when going through symlinks.

Change-Id: If0e2959356312b44ad9e93a2b35f4d60acb52777

toys/posix/cp.c

index 6e035f7..0dd63a7 100644 (file)
@@ -315,7 +315,7 @@ int cp_node(struct dirtree *try)
       // permission bits already correct for mknod and don't apply to symlink
       // If we can't get a filehandle to the actual object, use racy functions
       if (fdout == AT_FDCWD)
-        fchownat(cfd, catch, try->st.st_uid, try->st.st_gid,
+        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 && !geteuid()) {