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:
parent
c92738a24b
commit
fa5b4e909b
3 changed files with 8 additions and 8 deletions
|
@ -77,7 +77,7 @@ func MetaDirFileHeader() *zip.FileHeader {
|
||||||
Name: MetaDir,
|
Name: MetaDir,
|
||||||
Extra: []byte{MetaDirExtra[1], MetaDirExtra[0], 0, 0},
|
Extra: []byte{MetaDirExtra[1], MetaDirExtra[0], 0, 0},
|
||||||
}
|
}
|
||||||
dirHeader.SetMode(0700 | os.ModeDir)
|
dirHeader.SetMode(0755 | os.ModeDir)
|
||||||
dirHeader.SetModTime(DefaultTime)
|
dirHeader.SetModTime(DefaultTime)
|
||||||
|
|
||||||
return dirHeader
|
return dirHeader
|
||||||
|
@ -95,7 +95,7 @@ func ManifestFileContents(contents []byte) (*zip.FileHeader, []byte, error) {
|
||||||
Method: zip.Store,
|
Method: zip.Store,
|
||||||
UncompressedSize64: uint64(len(b)),
|
UncompressedSize64: uint64(len(b)),
|
||||||
}
|
}
|
||||||
fh.SetMode(0700)
|
fh.SetMode(0644)
|
||||||
fh.SetModTime(DefaultTime)
|
fh.SetModTime(DefaultTime)
|
||||||
|
|
||||||
return fh, b, nil
|
return fh, b, nil
|
||||||
|
|
|
@ -656,9 +656,9 @@ func (z *ZipWriter) addFile(dest, src string, method uint16, emulateJar, srcJar
|
||||||
UncompressedSize64: uint64(fileSize),
|
UncompressedSize64: uint64(fileSize),
|
||||||
}
|
}
|
||||||
|
|
||||||
mode := os.FileMode(0600)
|
mode := os.FileMode(0644)
|
||||||
if executable {
|
if executable {
|
||||||
mode = 0700
|
mode = 0755
|
||||||
}
|
}
|
||||||
header.SetMode(mode)
|
header.SetMode(mode)
|
||||||
|
|
||||||
|
@ -955,7 +955,7 @@ func (z *ZipWriter) writeDirectory(dir string, src string, emulateJar bool) erro
|
||||||
dirHeader = &zip.FileHeader{
|
dirHeader = &zip.FileHeader{
|
||||||
Name: cleanDir + "/",
|
Name: cleanDir + "/",
|
||||||
}
|
}
|
||||||
dirHeader.SetMode(0700 | os.ModeDir)
|
dirHeader.SetMode(0755 | os.ModeDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
dirHeader.SetModTime(z.time)
|
dirHeader.SetModTime(z.time)
|
||||||
|
|
|
@ -62,7 +62,7 @@ func fh(name string, contents []byte, method uint16) zip.FileHeader {
|
||||||
Method: method,
|
Method: method,
|
||||||
CRC32: crc32.ChecksumIEEE(contents),
|
CRC32: crc32.ChecksumIEEE(contents),
|
||||||
UncompressedSize64: uint64(len(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,
|
Method: zip.Store,
|
||||||
CRC32: crc32.ChecksumIEEE(contents),
|
CRC32: crc32.ChecksumIEEE(contents),
|
||||||
UncompressedSize64: uint64(len(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,
|
Method: zip.Store,
|
||||||
CRC32: crc32.ChecksumIEEE(nil),
|
CRC32: crc32.ChecksumIEEE(nil),
|
||||||
UncompressedSize64: 0,
|
UncompressedSize64: 0,
|
||||||
ExternalAttrs: (syscall.S_IFDIR|0700)<<16 | 0x10,
|
ExternalAttrs: (syscall.S_IFDIR|0755)<<16 | 0x10,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue