summaryrefslogtreecommitdiff
path: root/zip
diff options
context:
space:
mode:
author Chris Gross <chrisgross@google.com> 2021-06-02 12:56:08 -0700
committer Chris Gross <chrisgross@google.com> 2021-06-02 16:14:45 -0700
commitfa5b4e909b566bf00861c46ecead178de2c73235 (patch)
treedfa4a715f0d501a36bdeb58d6c863c751f62c330 /zip
parentc92738a24b48c9e0f6f7eea8cca81b6aab2700ab (diff)
Use broader permissions when archiving files.
Using broader premissions for archived files allows them to be more easily used when extracted. For example, defaulting regular files to 0644 will allow other tooling to use a file without the need to change permissions manually. Bug: 189919409 Test: m dist and inspected file permissions of archived files Change-Id: I4a0f8075206391254c639ecf865639bb9e8df0bf
Diffstat (limited to 'zip')
-rw-r--r--zip/zip.go6
-rw-r--r--zip/zip_test.go6
2 files changed, 6 insertions, 6 deletions
diff --git a/zip/zip.go b/zip/zip.go
index 6e412c956..ae379f52e 100644
--- a/zip/zip.go
+++ b/zip/zip.go
@@ -656,9 +656,9 @@ func (z *ZipWriter) addFile(dest, src string, method uint16, emulateJar, srcJar
UncompressedSize64: uint64(fileSize),
}
- mode := os.FileMode(0600)
+ mode := os.FileMode(0644)
if executable {
- mode = 0700
+ mode = 0755
}
header.SetMode(mode)
@@ -955,7 +955,7 @@ func (z *ZipWriter) writeDirectory(dir string, src string, emulateJar bool) erro
dirHeader = &zip.FileHeader{
Name: cleanDir + "/",
}
- dirHeader.SetMode(0700 | os.ModeDir)
+ dirHeader.SetMode(0755 | os.ModeDir)
}
dirHeader.SetModTime(z.time)
diff --git a/zip/zip_test.go b/zip/zip_test.go
index 441dea3bd..79cc0b4b7 100644
--- a/zip/zip_test.go
+++ b/zip/zip_test.go
@@ -62,7 +62,7 @@ func fh(name string, contents []byte, method uint16) zip.FileHeader {
Method: method,
CRC32: crc32.ChecksumIEEE(contents),
UncompressedSize64: uint64(len(contents)),
- ExternalAttrs: (syscall.S_IFREG | 0600) << 16,
+ ExternalAttrs: (syscall.S_IFREG | 0644) << 16,
}
}
@@ -72,7 +72,7 @@ func fhManifest(contents []byte) zip.FileHeader {
Method: zip.Store,
CRC32: crc32.ChecksumIEEE(contents),
UncompressedSize64: uint64(len(contents)),
- ExternalAttrs: (syscall.S_IFREG | 0700) << 16,
+ ExternalAttrs: (syscall.S_IFREG | 0644) << 16,
}
}
@@ -92,7 +92,7 @@ func fhDir(name string) zip.FileHeader {
Method: zip.Store,
CRC32: crc32.ChecksumIEEE(nil),
UncompressedSize64: 0,
- ExternalAttrs: (syscall.S_IFDIR|0700)<<16 | 0x10,
+ ExternalAttrs: (syscall.S_IFDIR|0755)<<16 | 0x10,
}
}