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

x/sys/unix: add *xattr functions on darwin. #14456

Closed
hirochachacha opened this issue Feb 22, 2016 · 8 comments
Closed

x/sys/unix: add *xattr functions on darwin. #14456

hirochachacha opened this issue Feb 22, 2016 · 8 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin
Milestone

Comments

@hirochachacha
Copy link
Contributor

OS X has own *xattr implementations.

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/setxattr.2.html#//apple_ref/doc/man/2/setxattr

Parameter is different, but we can make workaround for this.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Feb 22, 2016
@rfjakob
Copy link

rfjakob commented Mar 24, 2018

Third-party implementations are already out: https://github.com/pkg/xattr/blob/master/xattr_darwin.go

@andybons andybons added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Mar 26, 2018
@gopherbot
Copy link

Change https://golang.org/cl/113995 mentions this issue: unix: add {get,set,remove,list}xattr to darwin amd64

@rfjakob
Copy link

rfjakob commented May 23, 2018

Nice! But what about the symlink-safe variants Lgetxattr / Lsetxattr / Llistxattr etc ? It's just a matter of passing the option XATTR_NOFOLLOW to the underlying syscall.

@gopherbot
Copy link

Change https://golang.org/cl/114198 mentions this issue: unix: add symlink-safe *xattr functions on darwin

@rfjakob
Copy link

rfjakob commented May 23, 2018

Wow, awesome!

I noticed a test fails with EPERM on linux, i hit this recently, maybe related?

// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/xattr.c?h=v4.17-rc5#n122 :
// In the user.* namespace, only regular files and directories can have
// extended attributes.

https://github.com/rfjakob/pkg-xattr/blob/LGet/xattr_test.go

@tklauser
Copy link
Member

@rfjakob exactly, that's what I just found out too 😃

From http://man7.org/linux/man-pages/man7/xattr.7.html:

       The file permission bits of regular files and directories are
       interpreted differently from the file permission bits of special
       files and symbolic links.  For regular files and directories the file
       permission bits define access to the file's contents, while for
       device special files they define access to the device described by
       the special file.  The file permissions of symbolic links are not
       used in access checks.  These differences would allow users to
       consume filesystem resources in a way not controllable by disk quotas
       for group or world writable special files and directories.

       For this reason, extended user attributes are allowed only for
       regular files and directories, and access to extended user attributes
       is restricted to the owner and to users with appropriate capabilities
       for directories with the sticky bit set (see the chmod(1) manual page
       for an explanation of the sticky bit).

I'll just drop the corresponding tests from the CL for now.

@rfjakob
Copy link

rfjakob commented May 23, 2018

Ok - if you want to keep the tests, what I have done in pkg/xattr is to operate on a broken symlink, and check that we get EPERM for Lgetxattr and ENOENT for Getxattr.

@tklauser
Copy link
Member

@rfjakob nice, thanks. Will do that too for x/sys/unix then.

gopherbot pushed a commit to golang/sys that referenced this issue May 23, 2018
Updates golang/go#14456

Change-Id: I04632ef1d302e938a2cc373eb90f600f01404380
Reviewed-on: https://go-review.googlesource.com/114198
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators May 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin
Projects
None yet
Development

No branches or pull requests

6 participants