[PATCH 1/1] tar: no mtime/chown/chmod on hard links

From: Brad Barden <brad_AT_13os.net>
Date: Sun, 6 Dec 2015 02:43:32 -0600

---
 tar.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/tar.c b/tar.c
index e8dd26a..551585f 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -325,18 +325,20 @@ unarchive(char *fname, ssize_t l, char b[BLKSIZ])
 		close(fd);
 	}
 
-	times[0].tv_sec = times[1].tv_sec = mtime;
-	times[0].tv_nsec = times[1].tv_nsec = 0;
-	if (!mflag && utimensat(AT_FDCWD, fname, times, AT_SYMLINK_NOFOLLOW) < 0)
-		weprintf("utimensat %s:\n", fname);
-	if (h->type == SYMLINK) {
-		if (!getuid() && lchown(fname, uid, gid))
-			weprintf("lchown %s:\n", fname);
-	} else {
-		if (!getuid() && chown(fname, uid, gid))
-			weprintf("chown %s:\n", fname);
-		if (chmod(fname, mode) < 0)
-			eprintf("fchmod %s:\n", fname);
+	if (h->type != HARDLINK) {
+		times[0].tv_sec = times[1].tv_sec = mtime;
+		times[0].tv_nsec = times[1].tv_nsec = 0;
+		if (!mflag && utimensat(AT_FDCWD, fname, times, AT_SYMLINK_NOFOLLOW) < 0)
+			weprintf("utimensat %s:\n", fname);
+		if (h->type == SYMLINK) {
+			if (!getuid() && lchown(fname, uid, gid))
+				weprintf("lchown %s:\n", fname);
+		} else {
+			if (!getuid() && chown(fname, uid, gid))
+				weprintf("chown %s:\n", fname);
+			if (chmod(fname, mode) < 0)
+				eprintf("fchmod %s:\n", fname);
+		}
 	}
 
 	return 0;
-- 
2.3.6
--c3bfwLpm8qysLVxt--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Sun Dec 06 2015 - 13:12:10 CET