3

I need to edit extended attributes of directories that are symbolic links.

xattr that comes on OSX 10.5 unfortunately writes to the link target instead of the link itself.

I discovered a different version that supports a "-s" option to suppress following symbolic links. I checked it out of the repository, but there is no installer file that I can make out and I think I need one: https://xattr.svn.sourceforge.net/svnroot/xattr

Then I found another version and also checked it out, and was finally able to install it after installing Xcode:

http://svn.red-bean.com/bob/xattr/releases/xattr-0.6.1/

However when I run this version I don't appear to get the magic "-s" option to suppress following symbolic links. In fact this version didn't appear to have any other options that the original xattr had.

Does anyone have a version of xattr running on OSX 10.5 that will support not following symbolic links, or any other app that will allow me to write extended attributes and not follow symbolic links ?

1 Answer 1

1

The variation at https://github.com/jwodder/xattr1 has the -P option that suppresses the usual behavior of following symbolic links (i.e. passes the XATTR_NOFOLLOW option to listxattr(2), etc.). The included documentation indicates that this “operate on the symlink, not the target” mode is the default (it used to default to operating on the target, but the code was recently updated to match the documentation).

The options and modes of operation are different from the usual xattr(1), so you will probably have to adapt any scripts that you already have in place.

Since you said you have already installed the Developer Tools (i.e. Xcode), a simple make should build the program. I compiled and lightly tested it on a machine running Mac OS X 10.6.7 (I have also previously used it on a 10.4 machine, so it should work fine on 10.5).


Note about “directories that are symbolic links”: A directory entry can either be a directory or a symbolic link (or a plain file, etc.), but not both. It is not accurate to say either “a directory that is a symbolic link” or “a symbolic link that is a directory”. Properly, it just “a symbolic link that ultimately2 points to a directory”.

1 You can use the Downloads button on the right side of the GitHub page to download a .tar.gz or .zip if you do not have Git installed.

2 “Ultimately” because symbolic links can point to other symbolic links. They can even point to a non-existent pathname (creating a “dangling” symbolic link).

4
  • many thanks for yet another xattr :) I downloded the tar, extracted it, then "$ make" from the folder containing the Makefile. I then got the following: "gcc -o xattr xattr.c -std=c99 -O2 ld: can't open output file for writing: xattr collect2: ld returned 1 exit status make: *** [xattr] Error 1" I don't know how to make this makefile work :( Also thank you for the lesson in the definition of a symbolic link :)
    – timoto
    Commented May 7, 2011 at 15:25
  • @timoto: That looks like you do not have write access to the directory you are in. Did you perhaps extract it as root or another user? There should no need for sudo just to unpack this tar file and build the program. Commented May 7, 2011 at 20:17
  • DOH! My hat off to you sir. Permissions mismatch indeed. Make as the user that extracted the tar works. I can now see a lovely "-P" in the xattr help and presumably "-s" (set) is write. Thank you Chris.
    – timoto
    Commented May 7, 2011 at 20:53
  • @timoto: Yes, -s is for “set”. I neglected to mention the documentation. The documentation’s “source” is xattr.pod. It is plain text, but the Pod markup might be a bit of a pain to “read around”. You can use man ./xattr.1 to read the documentation as a manpage. Commented May 8, 2011 at 7:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .