Questions tagged [xattr]

Use the xattr tag for questions about extended attributes on files in a (Linux or macOS) file system.

Extended attributes are descriptions of the file stored separately from the file data. They are read by special system calls. People often first encounter them as a result of seeing an @ after the permissions in the output from ls -l. (The related symbol, a +, indicates that there are ACLs — access control lists — associated with the file.)

On macOS (or Mac OS X), you find out about the extended attributes with the @ option to ls. For example, a file might have the extra attribute:

$ ls -l@d Cscope
drwxr-xr-x@ 3 someuser  staff  102 Mar  8 21:49 Cscope
    com.apple.quarantine     30 
$

indicating that the directory had been copied from the internet and had not yet been marked as clean/safe. The Time Machine software makes extensive use of extended attributes too.

For macOS, the system calls are listxattr(), flistxattr() getxattr(), fgetxattr(), removexattr(), setxattr(). Linux adds lgetxattr() to this set.

96 questions
1
vote
1 answer

Swift - How to modify file metadata like kMDItemDisplayName?

I'm trying to find a way to change a file's metadata attributes (those with the prefix of "kMDItem", listed by mdls), but I didn't find any solution for it. ToT At first, I've tried using FileManager.default.setAttributes(_attributes:ofItemAtPath:),…
AgentBilly
  • 756
  • 5
  • 20
1
vote
0 answers

Xcode 9.0.1 crash during uploading app to App Store

Xcode 9.0.1 (9A1004) crash after I updated Xcode during uploading, In Terminal.app, When i run xattr $ xattr Traceback (most recent call last): File "/usr/bin/xattr-2.7", line 7, in from pkg_resources import…
Kerem Bekman
  • 1,281
  • 2
  • 13
  • 24
1
vote
0 answers

What com.apple.quarantine value should I set to mark a file as potentially malicious?

I'm making a desktop application which will open files (of the LHTML format) and which can save files (of whatever format) to a user's computer. In other words, a user might: Download something.lhtml from an email they receive Open…
iffy
  • 719
  • 1
  • 4
  • 20
1
vote
2 answers

Recursive xattr fails horribly

I've been trying to figure out a way to recursively remove all of the xattr for some files, however, none of the previous methods seem to work anymore; there might be a newly introduced bug too? $ xattr -rc . option -r not recognized $ xattr -c…
l'L'l
  • 44,951
  • 10
  • 95
  • 146
1
vote
1 answer

Is there an API for com.apple.TextEncoding?

When you save an NSString (or Swift.String) using a method like this, it writes the xattr "com.apple.TextEncoding". When you load it back with one of the corresponding methods, it checks this xattr and uses that as the default encoding. Is there…
Ssswift
  • 916
  • 10
  • 20
1
vote
0 answers

xattr -w Writing metadata to a file - syntax issue

Testing the ability to write metadata to files in Mac OSX. Any help would be appreciated as I know little about unix syntax. In Terminal. Why does this work; xattr -w com.apple.metadata:kMDItemDescription 'Somedescription' /somePath/someFile.pdf but…
user3118171
  • 357
  • 1
  • 2
  • 8
1
vote
1 answer

does linux fsync will sync file's xattr?

From man fsync(2), it will sync the file's metadata, which i think it's something list in stat. What's about file's xattr? does it belongs to metadata? We did a test, write a file, and set 6 xattrs, then do fsync, then change 1 xattr value, and do…
hjwsm1989
  • 83
  • 1
  • 9
1
vote
1 answer

remove extended attribute : fails

From a shell script, I'm trying to remove extended attribute setfattr -x security.selinux file.txt The file.txt has mode 777, but im getting "permission denied error". How can I fix this?
webminal.org
  • 44,948
  • 37
  • 94
  • 125
1
vote
2 answers

Can you implement OS X's Finder download progress bars from a shell script?

At first I thought this might be some variation on the extended attributes that can be modified with the xattr command line tool. However, I've staged several tests, and the files don't seem to have any special attributes while in this mode. Is this…
John O
  • 4,863
  • 8
  • 45
  • 78
1
vote
2 answers

Getting a comment attribute from a file in Bash on osx

i'm trying to get the comment attribute of a file using xattr in bash on OSX. This is my code I'm running: xattr -p com.apple.metadata:kMDItemFinderComment "/Users/fred/Dropbox/OSXStuff/app.icns" However it is returning hexadecimal instead of the…
CoopC
  • 105
  • 1
  • 8
1
vote
1 answer

OSX Mavericks get tags of a file in c program

I need to get the usertags for a file in c program. I am aware of "mdls -name kMDItemUserTags FILENAME" command to get this details. But i need to do it in c code. Is there any way from which i can get the values directly instead of running this…
user12345
  • 425
  • 1
  • 3
  • 14
1
vote
1 answer

Read the extended attributes for a file in SELinux

I want to read the capabilities of a file in linux. I want answer something like this with complete details... /path/to/file: uid:0 gid:2000 mode:100750 capability:40 selinux:u:object_r:runas_exec:s0 0x40 = 64 decimal I tried ls -l, getfattr, xattr…
msa
  • 31
  • 1
  • 7
1
vote
0 answers

How to set quarantine flag for Gatekeeper

I was looking for a way to flag some files after downloading so gatekeeper would inspect them. Web browsers also quarantine downloaded files for gatekeeper. I know that there is an extended attribute set on files "com.apple.quarantine", but setting…
Abcd Efg
  • 2,146
  • 23
  • 41
1
vote
2 answers

Java UserDefinedFileAttributeView

When I add a new UserDefinedFileAttributeView attribute to a file, where does Java store this information? There are no additional files in the directory, the file does not have any new attributes or details when I view the file properties. My…
gwin003
  • 7,432
  • 5
  • 38
  • 59
1
vote
1 answer

Linux capabilities over FUSE file system

I have a FUSE filesystem in which I coded the getxattr and setxattr like this: int mfs_setxattr(const char *path, const char *name, const char *value, size_t size, int flags) { ... /* some translation processing of path to rpath */ int ret =…
nsstl
  • 15
  • 5