Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive/zip: Writer drops fs.FileMode data #48166

Open
colin-sitehost opened this issue Sep 2, 2021 · 1 comment
Open

archive/zip: Writer drops fs.FileMode data #48166

colin-sitehost opened this issue Sep 2, 2021 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@colin-sitehost
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.17 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go/pkg/mod"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2958766942=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Two zips were created with Info-ZIP 3.0 and Writer:
(it was assumed that the archive files may not be identical, but the input files were)

mkdir -p path/to/ dir/
touch path/to/file
chmod 0666 path/to/file dir/
zip info.zip path/to/file dir/
w := zip.NewWriter(os.Stdout)
w.Create("path/to/file")
w.Create("dir/")
w.Close()

We can see that both (according to Reader) have the same permissions: https://play.golang.org/p/SLK2LT1e1Gs

[stdlib] path/to/file: 0o666
[stdlib] dir/: 0o20000000666
[infozip] path/to/file: 0o666
[infozip] dir/: 0o20000000666

Thus we would expect unzip (still Info-ZIP 3.0), to unpack them identically:

[user@localhost ~]$ unzip /path/to/file.zip
Archive:  /path/to/file.zip
  inflating: path/to/file
   creating: dir/

What did you expect to see?

(from info.zip)

[user@localhost ~]$ ls -lR
.:
total 0
drw-rw-rw- 2 user users 40 Dec 31  1979 dir
drwxr-xr-x 3 user users 60 Sep  2 21:45 path

./dir:
total 0

./path:
total 0
drwxr-xr-x 2 user users 60 Sep  2 21:45 to

./path/to:
total 0
-rw-rw-rw- 1 user users 0 Dec 31  1979 file

What did you see instead?

(from stdlib.zip)

[user@localhost ~]$ ls -lR
.:
total 0
drw-r-xr-x 2 user users 40 Dec 31  1979 dir
drwxr-xr-x 3 user users 60 Sep  2 21:45 path

./dir:
total 0

./path:
total 0
drwxr-xr-x 2 user users 60 Sep  2 21:45 to

./path/to:
total 0
-rw-rw-rw- 1 user users 0 Dec 31  1979 file
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 3, 2021
@seankhliao
Copy link
Member

cc @dsnet

@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants