From 11f5cfdca1fe2bf6cf756f8ec29f7e9030c4e771 Mon Sep 17 00:00:00 2001 From: kientzle Date: Fri, 2 Mar 2007 16:44:58 +0000 Subject: [PATCH] Force the umask to something predictable while creating objects on disk. In particular, this fixes tar -xp restore of mode bits. --- lib/libarchive/archive_read_extract.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libarchive/archive_read_extract.c b/lib/libarchive/archive_read_extract.c index d86ddddcbdff..ef2e2b50d820 100644 --- a/lib/libarchive/archive_read_extract.c +++ b/lib/libarchive/archive_read_extract.c @@ -262,6 +262,7 @@ archive_read_extract(struct archive *a, struct archive_entry *entry, int flags) if (stat(archive_entry_pathname(entry), &extract->st) == 0) extract->pst = &extract->st; + extract->umask = umask(0); /* Set the umask to zero, record old one. */ if (extract->pst != NULL && extract->pst->st_dev == a->skip_file_dev && @@ -295,7 +296,7 @@ archive_read_extract(struct archive *a, struct archive_entry *entry, int flags) break; } } - + umask(extract->umask); /* Restore umask. */ cleanup: #ifdef HAVE_FCHDIR