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
0
votes
0 answers

finding xattr recursively for symbolic links rather than their target?

I've been using the following command (in bash terminal) to find the extended attribute com.apple.metadata:kMDItemComment for files/folders on my system. sudo find "`pwd`" -xattrname com.apple.metadata:kMDItemComment -exec printf %s\\t {} \; -exec…
Max Well
  • 257
  • 2
  • 9
0
votes
0 answers

Does NTFS have extended file attributes and how do I read/write them on windows?

I'm writing a cross-platform app that needs to keep track of files that may also be worked on by other software, most notably the default file explorer app of whichever platform. To do this, I attach an ID to each file and directory that I'm keeping…
user81993
  • 6,167
  • 6
  • 32
  • 64
0
votes
0 answers

Linux Security Module: Is there a way to check/audit shared library loading?

I'm working on a linux security module based on xattr (file's extended attributes), and I want to implement security measures to prevent shared libraries without certain xattr from loading. This requires me to hook file_open and check the file's…
0
votes
0 answers

How to create a zip from command line that preserves macOS metadata but also passes validation tests when > 4GB?

I am looking for a method of creating zip archives of files and folders on macOS that meets the following requirements: Creates zips from command line (not GUI such as Finder or Archive Utility) Properly preserves macOS metadata (resource forks,…
Niel
  • 9
  • 3
0
votes
0 answers

Why can’t I get ENODATA from Setxattr?

The following is always meeting the ENOENT condition at the end. I would like to print ENODATA. What do I need to change in setxattr? #include #include #include #include int main() { int ret; const…
dodobirdie
  • 13
  • 3
0
votes
1 answer

Are extended attributes name and value guaranteed to be UTF-8 encoded

I am trying to implement Rusty wrappers for those extended attributes syscalls, if they are guaranteed to be UTF-8 encoded, then I can use the type String, or I have to use OsString. I googled a lot, but only found these two pages: freedesktop:…
Steve Lau
  • 658
  • 7
  • 13
0
votes
0 answers

How do I add tags to xattributes until there is an error?

I'm adding a list of tags to xattrs with: def write_dolphin_xattr(parent_folder: str, metadata: Dict, tags: List[str], filetypes: List[str] = FILETYPES) -> None: stars = metadata['score'] comment = metadata['comment'] for filetype in…
user19924240
0
votes
0 answers

Cannot interact with com.apple.quarantine'd file with Mac terminal?

I have a file, abc.bin ~ ls -al ... -rw-r--r--@ 1 username groupname 285342 Jul 23 14:45 abc.bin ... I see that it has the apple @ additional metadata things ~ ls -l@ -rw-r--r--@ 1 username groupname 285342 Jul 23 14:45 abc.bin …
Kaia
  • 862
  • 5
  • 21
0
votes
1 answer

Samba(v 4.10.16) win10 can't open the files(like .xlsx .pptx) that has set extended attribute by setxattr() in centos7

Please forgive my broken English I try to use setxattr() to sets the value of the extended attribute for some file, the code is like that: int set_scl(string file_name, char scl) { char scl_data[16]; scl_data[0] = scl; ssize_t size = 1; …
0
votes
1 answer

Linux setxattr: possible to use Unicode string?

I wrote the following code in VS Code and ran it to set file attribute. It seemed to have run successfully, but when I checked the value, the text was not correct. Is Unicode string supported for file extended attributes? If so, how can I fix the…
Damn Vegetables
  • 11,484
  • 13
  • 80
  • 135
0
votes
1 answer

How to remove lock from file showing extended attributes

I am on macos mojave. I have a file on my system that was locked by Dreamweaver. I copied the file to another directory to work on it while it is checked out by another user, but the lock was copied with the file. So I have a file on my system…
mtsafe
  • 1
  • 4
0
votes
1 answer

Format xargs output to grep

I have a script that I'm trying to optimize with xargs. The current version uses find with -exec to call the command: find -type f -iname "*.mp4" -print0 -printf '\n' -exec getfattr -d --absolute-names {} \; after which I can pipe to grep with…
bcHelix
  • 13
  • 2
0
votes
0 answers

Adding Metadata Attribute with white-space — Unix shell command

I'm trying to change a metadata attribute on a file, in a Node.js app, the problem is that I need to use white-space in the attribute value. I tried the following (used \ to add the white-space) but it did not work: In the sample below, the Musical…
Bondsmith
  • 1,343
  • 3
  • 13
  • 27
0
votes
0 answers

Trouble with xattr, "No module named 'pkg_resources' "

I've been on MacOS using Python for a while and lately, when trying to execute MacOS's xattr, such as xattr -cr I'm always getting this error: Traceback (most recent call last): File "/usr/bin/xattr", line 8, in from…
0
votes
1 answer

Passing awk results to command after pipe

I'm trying to pass what would be the awk outputs of print $1 and print $2 to setfattr after a pipe. The value of the extended attribute is an MD5 hash which is calculated from input files from the output of a find command. This is what I have so…
bcHelix
  • 13
  • 2