Skip to content

Commit

Permalink
Merge pull request #34 from woky/zero-umask-extract
Browse files Browse the repository at this point in the history
deb/extract: Extract with umask set to 0
  • Loading branch information
niemeyer authored Jan 10, 2023
2 parents 36cf47d + 69ef992 commit 10b92d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions internal/deb/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"sort"
"strings"
"syscall"

"github.com/blakesmith/ar"
"github.com/klauspost/compress/zstd"
Expand Down Expand Up @@ -104,6 +105,11 @@ func Extract(pkgReader io.Reader, options *ExtractOptions) (err error) {

func extractData(dataReader io.Reader, options *ExtractOptions) error {

oldUmask := syscall.Umask(0)
defer func() {
syscall.Umask(oldUmask)
}()

shouldExtract := func(pkgPath string) (globPath string, ok bool) {
if pkgPath == "" {
return "", false
Expand Down
4 changes: 2 additions & 2 deletions internal/deb/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var extractTests = []extractTest{{
},
},
result: map[string]string{
"/tmp/": "dir 01775",
"/tmp/": "dir 01777",
"/usr/": "dir 0755",
"/usr/bin/": "dir 0755",
"/usr/bin/hello": "file 0775 eaf29575",
Expand Down Expand Up @@ -263,7 +263,7 @@ var extractTests = []extractTest{{
"/etc/": "dir 0755",
"/usr/": "dir 0755",
"/usr/bin/": "dir 0755",
"/tmp/": "dir 01775",
"/tmp/": "dir 01777",
},
}, {
summary: "Optional entries mixed in cannot be missing",
Expand Down

0 comments on commit 10b92d0

Please sign in to comment.