os: handle the sticky bit separately for *BSD
open(2) and mkdir(2) won't set the sticky bit on *BSD.
This behavior is mentioned on sticky(8).
see also: https://github.com/dotcloud/docker/pull/6587
Fixes issue 8383.
Hello golang-codereviews@googlegroups.com (cc: dave@cheney.net, golang-codereviews@googlegroups.com, unclejacksons@gmail.com), I'd like you to review this change to https://code.google.com/p/go/
9 years, 9 months ago
(2014-07-14 13:27:16 UTC)
#4
On 2014/07/14 14:45:51, iant wrote: > It would be pretty easy to add a const ...
9 years, 9 months ago
(2014-07-15 13:02:42 UTC)
#7
On 2014/07/14 14:45:51, iant wrote:
> It would be pretty easy to add a const that tells Openfile and Mkdir whether
> they actually need to test this, and have the const be true on systems that
> require it. Is it worth doing?
>
> For example, look at supportsCloseOnExec.
>
> https://codereview.appspot.com/102640045/diff/40001/src/pkg/os/file.go
> File src/pkg/os/file.go (right):
>
>
https://codereview.appspot.com/102640045/diff/40001/src/pkg/os/file.go#newcod...
> src/pkg/os/file.go:207: // FreeBSD and NetBSD's open(2) can't handle the
sticky
> bit correctly
> s/open/mkdir/ , I assume.
Thanks for reviewing. I've added supportsCreateWithStickyBit as the constant.
I suspect this will break the build on dragonfly because supportsCreateWithStickyBit won't be defined anywhere. ...
9 years, 9 months ago
(2014-07-15 21:05:37 UTC)
#8
I suspect this will break the build on dragonfly because
supportsCreateWithStickyBit won't be defined anywhere.
Rather than try to fit this in with other files, I think we should introduce two
new files, one setting the new constant to false, one setting it to true, with
+build netbsd freebsd on one and +build !netbsd,!freebsd on the other.
Very sorry, I completely lost track of this. https://codereview.appspot.com/102640045/diff/120001/src/pkg/os/file_unix.go File src/pkg/os/file_unix.go (right): https://codereview.appspot.com/102640045/diff/120001/src/pkg/os/file_unix.go#newcode80 src/pkg/os/file_unix.go:80: if ...
9 years, 5 months ago
(2014-11-01 22:11:30 UTC)
#17
Very sorry, I completely lost track of this.
https://codereview.appspot.com/102640045/diff/120001/src/pkg/os/file_unix.go
File src/pkg/os/file_unix.go (right):
https://codereview.appspot.com/102640045/diff/120001/src/pkg/os/file_unix.go#...
src/pkg/os/file_unix.go:80: if !supportsCreateWithStickyBit && e == nil &&
perm&ModeSticky != 0 {
It seems to me that this will do the wrong thing if the file is not being
created. We don't want to change the mode of an existing file. Unfortunately I
think we need to write something like
chmod := false
if !supportsCreateWithStickyBit && flag&O_CREATE != 0 && perm&ModeSticky !=
0 {
if _, err := Stat(name); IsNotExist(err) {
chmod = true
}
}
r, e := syscall.Open(...)
if chmod && e == nil {
e = Chmod(name, perm)
}
This is very imperfect but I don't see what else we can do.
On 2014/11/01 22:11:30, iant wrote: > Very sorry, I completely lost track of this. > ...
9 years, 4 months ago
(2014-12-17 16:10:23 UTC)
#18
On 2014/11/01 22:11:30, iant wrote:
> Very sorry, I completely lost track of this.
>
> https://codereview.appspot.com/102640045/diff/120001/src/pkg/os/file_unix.go
> File src/pkg/os/file_unix.go (right):
>
>
https://codereview.appspot.com/102640045/diff/120001/src/pkg/os/file_unix.go#...
> src/pkg/os/file_unix.go:80: if !supportsCreateWithStickyBit && e == nil &&
> perm&ModeSticky != 0 {
> It seems to me that this will do the wrong thing if the file is not being
> created. We don't want to change the mode of an existing file. Unfortunately
I
> think we need to write something like
>
> chmod := false
> if !supportsCreateWithStickyBit && flag&O_CREATE != 0 && perm&ModeSticky
!=
> 0 {
> if _, err := Stat(name); IsNotExist(err) {
> chmod = true
> }
> }
>
> r, e := syscall.Open(...)
>
> if chmod && e == nil {
> e = Chmod(name, perm)
> }
>
> This is very imperfect but I don't see what else we can do.
The change is submitted as https://go-review.googlesource.com/#/c/1673/ and
merged! Thanks.
Issue 102640045: code review 102640045: os: handle the sticky bit separately for *BSD
(Closed)
Created 9 years, 10 months ago by kazuyoshi
Modified 9 years, 4 months ago
Reviewers: golang-codereviews, iant, dfc
Base URL:
Comments: 4