We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version
$ go version go version go1.14.5 linux/amd64
Yes, I also tested with go 1.14.6 linux/amd64
go env
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/theo/.cache/go-build" GOENV="/home/theo/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/theo/dev/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/theo/dev/repos/ubsu/go.mod" 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-build371835464=/tmp/go-build -gno-record-gcc-switches"
I tried using os.Mkdir with an os.FileMode that should result in the suid bit being set for the directory.
os.Mkdir
os.FileMode
package main import "os" func main() { os.Mkdir("testdir", 0755 | os.ModeSetuid) // os.Chmod("testdir", 0755 | os.ModeSetuid) }
I expected the resulting directory to have the setuid bit set when running ls -l in my shell, but to no avail.
ls -l
Note that when uncommenting the last line of the program, os.Chmod properly sets the setuid bit for the directory.
os.Chmod
Am I missing something here; perhaps this is a dumb question? What's with this behavior?
The text was updated successfully, but these errors were encountered:
Forgot to mention in the body: the same thing happens with os.ModeSetgid and the setgid bit.
os.ModeSetgid
Sorry, something went wrong.
The mkdir syscall cannot set the S_ISUID bit.
Here is the relevant sentence from the Linux mkdir manual:
It is modified by the process's umask in the usual way: in the absence of a default ACL, the mode of the created directory is (mode & ~umask & 0777).
The mask 0777 removes the S_ISUID bit.
Mask 0777 excludes the S_IGUID as well. I suggest to extend the documentation of os.Mkdir.
Ok, thanks for the clarification.
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, I also tested with go 1.14.6 linux/amd64
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried using
os.Mkdir
with anos.FileMode
that should result in the suid bit being set for the directory.I expected the resulting directory to have the setuid bit set when running
ls -l
in my shell, but to no avail.Note that when uncommenting the last line of the program,
os.Chmod
properly sets the setuid bit for the directory.Am I missing something here; perhaps this is a dumb question? What's with this behavior?
The text was updated successfully, but these errors were encountered: