macos – Why does defaults solely learn from information with sure prolonged attributes?

on

|

views

and

comments


It appears that evidently defaults learn solely works on property record information in sure folders (e.g. Desktop, Downloads) when the prolonged attribute com.apple.macl incorporates a selected worth in any other case it stories that the important thing doesn’t exist.

Create a plist file containing a key foo with the worth bar.

$ echo '''<?xml model="1.0" encoding="UTF-8"?>
> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
> <plist model="1.0">
> <dict>
>   <key>foo</key>
>   <string>bar</string>
> </dict>
> </plist>''' > ~/foobar.plist

Use defaults learn to print the worth of foo.

$ /usr/bin/defaults learn ~/foobar.plist foo
bar

Copy the file from the house folder to the desktop.

$ cp ~/foobar.plist ~/Desktop

Making an attempt to learn the important thing with defaults there doesn’t work, in line with the error message as a result of it doesn’t exist.

$ /usr/bin/defaults learn ~/Desktop/foobar.plist foo
2022-11-01 11:03:21.156 defaults[67556:1531405]
The area/default pair of (/Customers/stefan/Desktop/foobar.plist, foo) doesn't exist

PlistBuddy nonetheless stories accurately that key does the truth is exist ( plutil additionally works wonderful).

$ /usr/libexec/PlistBuddy -c "print foo" ~/Desktop/foobar.plist
bar

The listing itemizing reveals that the file on the desktop has an prolonged attribute.

$ ls -l ~/Desktop/foobar.plist
-rw-rw-r--@ 1 stefan  workers  228 Nov  1 11:03 /Customers/stefan/Desktop/foobar.plist

The unique file doesn’t have an prolonged attribute.

$ ls -l ~/foobar.plist
-rw-rw-r--  1 stefan  workers  228 Nov  1 11:03 /Customers/stefan/foobar.plist

The file on the desktop has the com.apple.macl attribute.

$ /usr/bin/xattr -l ~/Desktop/foobar.plist
com.apple.macl:
00000000  04 00 E7 04 31 F1 19 3B 41 2D BA 36 1D 05 19 2F  |....1..;A-.6.../|
00000010  D1 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00                          |........|
00000048

Copy the file from the desktop again to the house folder.

$ cp ~/Desktop/foobar.plist ~

The com.apple.macl attribute has been preserved on the copy.

$ /usr/bin/xattr -l ~/foobar.plist
com.apple.macl:
00000000  04 00 E7 04 31 F1 19 3B 41 2D BA 36 1D 05 19 2F  |....1..;A-.6.../|
00000010  D1 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00                          |........|
00000048

Studying the important thing from the file within the dwelling listing works wonderful regardless of the presence of the com.apple.macl attribute.

$ /usr/bin/defaults learn ~/foobar.plist foo
bar

Attempt to delete the com.apple.macl attribute from the file on the desktop.

$ /usr/bin/xattr -d com.apple.macl ~/Desktop/foobar.plist

The com.apple.macl attribute was not eliminated.

$ /usr/bin/xattr -l ~/Desktop/foobar.plist
com.apple.macl:
00000000  04 00 E7 04 31 F1 19 3B 41 2D BA 36 1D 05 19 2F  |....1..;A-.6.../|
00000010  D1 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00                          |........|
00000048

Attempt to delete the com.apple.macl attribute from the file within the dwelling folder.

$ /usr/bin/xattr -d com.apple.macl ~/foobar.plist

The com.apple.macl attribute was eliminated.

$ /usr/bin/xattr -l ~/foobar.plist

I a way that I can not bear in mind I created one other plist file that additionally had the com.apple.macl attribute however with a special worth. The worth of com.apple.macl begins with 04 00 5B E7 7B 97 C0 D1 49 FF AD 34 CC 5B C3 B1 FC BF and the remaining is zeros.

Write the choice worth of the com.apple.macl attribute to the file within the dwelling folder.

$ /usr/bin/xattr -wx com.apple.macl '04 00 5B E7 7B 97 C0 D1 49 FF AD 34 CC 5B C3 B1 FC BF' ~/foobar.plist

The worth of com.apple.macl was accurately written.

$ /usr/bin/xattr -l ~/foobar.plist
com.apple.macl:
00000000  04 00 5B E7 7B 97 C0 D1 49 FF AD 34 CC 5B C3 B1  |..[.{...I..4.[..|
00000010  FC BF                                            |..|
00000012

Copy the file from the home folder back to the desktop.

$ cp ~/foobar.plist ~/Desktop

The value written to the com.apple.macl attribute is still present, but has been extended with the value 04 00 E7 04 31 F1 19 3B 41 2D BA 36 1D 05 19 2F D1 0F and zeros.

$ /usr/bin/xattr -l ~/Desktop/foobar.plist
com.apple.macl:
00000000  04 00 5B E7 7B 97 C0 D1 49 FF AD 34 CC 5B C3 B1  |..[.{...I..4.[..|
00000010  FC BF 04 00 E7 04 31 F1 19 3B 41 2D BA 36 1D 05  |......1..;A-.6..|
00000020  19 2F D1 0F 00 00 00 00 00 00 00 00 00 00 00 00  |./..............|
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00                          |........|
00000048

Reading the key from the file on the desktop now works.

$ /usr/bin/defaults read ~/Desktop/foobar.plist foo
bar

What is happening here?

Why does defaults seemingly only read a key from a property list file in the Desktop folder when the extended attribute com.apple.macl contains a specific value?


This was tested on macOS Catalina 10.15.7

Share this
Tags

Must-read

Nvidia CEO reveals new ‘reasoning’ AI tech for self-driving vehicles | Nvidia

The billionaire boss of the chipmaker Nvidia, Jensen Huang, has unveiled new AI know-how that he says will assist self-driving vehicles assume like...

Tesla publishes analyst forecasts suggesting gross sales set to fall | Tesla

Tesla has taken the weird step of publishing gross sales forecasts that recommend 2025 deliveries might be decrease than anticipated and future years’...

5 tech tendencies we’ll be watching in 2026 | Expertise

Hi there, and welcome to TechScape. I’m your host, Blake Montgomery, wishing you a cheerful New Yr’s Eve full of cheer, champagne and...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here