Skip to content

x/telemetry: [email protected]/ directory is mode 0555, not 0755, in the go mod cache after go mod vendor -modcacherw #69239

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

Closed
Mikcl opened this issue Sep 4, 2024 · 6 comments
Labels
telemetry x/telemetry issues
Milestone

Comments

@Mikcl
Copy link

Mikcl commented Sep 4, 2024

Go version

go version go1.23.0 linux/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3287513302=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I have somewhat an interesting setup but for the sake of a reproducible I ran the following commands:

main.go:

package main

import (
	"fmt"
	"github.com/spf13/cobra"
	"os"
)

func main() {
	var rootCmd = &cobra.Command{
		Use:   "hello",
		Run: func(cmd *cobra.Command, args []string) {
			fmt.Println("Hello, World!")
		},
	}

	if err := rootCmd.Execute(); err != nil {
		os.Exit(1)
	}
}

Ran these commands

go mod init mytelemtery
go mod tidy

Created this Dockerfile:

FROM golang:1.23-alpine
WORKDIR /app
COPY . .
CMD ["/bin/sh"]
docker build -t mytelemetry:latest .
docker run -it mytelemetry:latest

Within the docker container:

go mod vendor -modcacherw

What did you see happen?

The problem is the [email protected] directory that comes with this x/telemtry package is not writeable by the owner, typically directories are 0755.

$ ls -l $GOPATH/pkg/mod/golang.org/x/telemetry/
total 4
dr-xr-xr-x    2 root     root          4096 Sep  4 00:44 [email protected]

I also ran stat $GOPATH/pkg/mod/golang.org/x/telemetry/[email protected]/

which shows Access: (0555/dr-xr-xr-x)

What did you expect to see?

I expect directories to be 0755 so that they can be removed by owners.

It seems like this telemtry package is new https://pkg.go.dev/golang.org/x/telemetry?tab=versions (in existence since only Aug 28 2024).

In the Docker example above, I can remove the directory, since you're root in docker. But in other setups where this directory exists (I can share further details on how such a setup gets ends up with this file) I would expect them to be 0755 so that they could be removed.

Is it intentional for this directory to be 0555?

@gopherbot gopherbot added the telemetry x/telemetry issues label Sep 4, 2024
@gopherbot gopherbot added this to the Unreleased milestone Sep 4, 2024
@gabyhelp
Copy link

gabyhelp commented Sep 4, 2024

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@seankhliao
Copy link
Member

the entire mod cache is intentionally read only.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 4, 2024
@Mikcl
Copy link
Author

Mikcl commented Sep 4, 2024

hi @seankhliao thank you for responding,

could you please reconsider.

I realalise the cache is read only, however when running go mod vendor -modcacherw the telemtery package is still read only, note the -modecacherw, this problem doesnt exist for other packages in the cache, see below:

# go mod vendor -modcacherw
go: downloading github.com/spf13/cobra v1.8.1
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/inconshreveable/mousetrap v1.1.0
# stat $GOPATH/pkg/mod/golang.org/x/telemetry/[email protected]/
  File: /go/pkg/mod/golang.org/x/telemetry/[email protected]/
Access: (0555/dr-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
# stat /go/pkg/mod/github.com/spf13/[email protected]/
  File: /go/pkg/mod/github.com/spf13/[email protected]/
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

I have a simple cobra script which causes this,

here is the go.mod:

module mytelemetry

go 1.22.4

require github.com/spf13/cobra v1.8.1

require (
	github.com/inconshreveable/mousetrap v1.1.0 // indirect
	github.com/spf13/pflag v1.0.5 // indirect
)

@Mikcl Mikcl changed the title x/telemetry: [email protected]/ directory is mode 0555, not 0755 x/telemetry: [email protected]/ directory is mode 0555, not 0755, in the go mod cache after -modcacherw Sep 4, 2024
@Mikcl Mikcl changed the title x/telemetry: [email protected]/ directory is mode 0555, not 0755, in the go mod cache after -modcacherw x/telemetry: [email protected]/ directory is mode 0555, not 0755, in the go mod cache after go mod vendor -modcacherw Sep 4, 2024
@Mikcl
Copy link
Author

Mikcl commented Sep 4, 2024

I have updated the reproducible "What did I do section",

Please let me know if this is something that could be reopen :)

@seankhliao
Copy link
Member

see #68946

@Mikcl
Copy link
Author

Mikcl commented Sep 4, 2024

I see, thank you @seankhliao

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
telemetry x/telemetry issues
Projects
None yet
Development

No branches or pull requests

4 participants