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
This commit is contained in:
Chris Gross 2021-06-02 12:56:08 -07:00
parent c92738a24b
commit fa5b4e909b
3 changed files with 8 additions and 8 deletions

View file

@ -77,7 +77,7 @@ func MetaDirFileHeader() *zip.FileHeader {
Name: MetaDir,
Extra: []byte{MetaDirExtra[1], MetaDirExtra[0], 0, 0},
}
dirHeader.SetMode(0700 | os.ModeDir)
dirHeader.SetMode(0755 | os.ModeDir)
dirHeader.SetModTime(DefaultTime)
return dirHeader
@ -95,7 +95,7 @@ func ManifestFileContents(contents []byte) (*zip.FileHeader, []byte, error) {
Method: zip.Store,
UncompressedSize64: uint64(len(b)),
}
fh.SetMode(0700)
fh.SetMode(0644)
fh.SetModTime(DefaultTime)
return fh, b, nil

View file

@ -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)

View file

@ -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,
}
}