[hackers] [sbase][PATCH] tar: Fully preserve file permissions

From: Arthur Williams <taaparthur_AT_disroot.org>
Date: Thu, 8 Sep 2022 19:13:40 -0700

Previously when extracting an archive, tar threw away information
regarding the sticky, setguid, setuid bits. This commits correctly
preservers that info.
---
 tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tar.c b/tar.c
index d3a9f3b..13a1c86 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -202,7 +202,7 @@ archive(const char *path)
 	h = (struct header *)b;
 	memset(b, 0, sizeof(b));
 	estrlcpy(h->name,    path,                        sizeof(h->name));
-	putoctal(h->mode,    (unsigned)st.st_mode & 0777, sizeof(h->mode));
+	putoctal(h->mode,    (unsigned)st.st_mode & 07777,sizeof(h->mode));
 	putoctal(h->uid,     (unsigned)st.st_uid,         sizeof(h->uid));
 	putoctal(h->gid,     (unsigned)st.st_gid,         sizeof(h->gid));
 	putoctal(h->size,    0,                           sizeof(h->size));
-- 
2.37.1
Received on Fri Sep 09 2022 - 04:13:40 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 09 2022 - 04:24:37 CEST