Skip to content

Commit a8f7209

Browse files
committed
Update Xattr to 1.1
Added "Clear All Quarantine Attributes" command and made it available as a system service to access in contextual menus in Finder. Technically, the functionality is "Recursively remove quarantine extended attribute from all directories and files with Xattr.app" but that new would be a bit long-ish name for a menu item... This feature enables easy removal of 'com.apple.quarantine' extended attribute from files or from directories, recursively with all items within. This can also be used on downloaded apps when even re-codesigning for local deployment does not help until you remove the quarantine attribute.
1 parent 2996a12 commit a8f7209

8 files changed

Lines changed: 113 additions & 50 deletions

File tree

Xattr.app/Contents/Info.plist

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</dict>
5252
</array>
5353
<key>CFBundleVersion</key>
54-
<string>1.0</string>
54+
<string>1.1</string>
5555
<key>LSMinimumSystemVersion</key>
5656
<string>11.0</string>
5757
<key>NSMainNibFile</key>
@@ -81,6 +81,27 @@
8181
<key>NSUserData</key>
8282
<string>Xattr</string>
8383
</dict>
84+
<dict>
85+
<key>NSMenuItem</key>
86+
<dict>
87+
<key>default</key>
88+
<string>Clear All Quarantine Attributes</string>
89+
</dict>
90+
<key>NSMessage</key>
91+
<string>runOMCService</string>
92+
<key>NSPortName</key>
93+
<string>OMCService</string>
94+
<key>NSRequiredContext</key>
95+
<dict/>
96+
<key>NSReturnTypes</key>
97+
<array/>
98+
<key>NSSendTypes</key>
99+
<array>
100+
<string>NSFilenamesPboardType</string>
101+
</array>
102+
<key>NSUserData</key>
103+
<string>clear.quarantine</string>
104+
</dict>
84105
</array>
85106
</dict>
86107
</plist>

Xattr.app/Contents/Resources/Command.plist

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<key>COMMAND_ID</key>
1919
<string>xattr.new</string>
2020
<key>EXECUTION_MODE</key>
21-
<string>exe_popen</string>
21+
<string>exe_shell_script</string>
2222
<key>NAME</key>
2323
<string>Xattr</string>
2424
<key>NIB_DIALOG</key>
@@ -40,10 +40,6 @@
4040
<string>Xattr</string>
4141
</dict>
4242
<dict>
43-
<key>COMMAND</key>
44-
<array>
45-
<string>#using $OMC_DLG_CHOOSE_OBJECT_PATH</string>
46-
</array>
4743
<key>CHOOSE_OBJECT_DIALOG</key>
4844
<dict>
4945
<key>MESSAGE</key>
@@ -129,8 +125,11 @@
129125
<key>NIB_NAME</key>
130126
<string>AddAttribute</string>
131127
</dict>
132-
<key>VERSION</key>
133-
<integer>1</integer>
128+
<key>ENVIRONMENT_VARIABLES</key>
129+
<dict>
130+
<key>OMC_OBJ_PATH</key>
131+
<string></string>
132+
</dict>
134133
</dict>
135134
<dict>
136135
<key>COMMAND_ID</key>
@@ -140,6 +139,34 @@
140139
<key>NAME</key>
141140
<string>Add Attribute</string>
142141
</dict>
142+
<dict>
143+
<key>NAME</key>
144+
<string>Clear All Quarantine Attributes</string>
145+
<key>ACTIVATION_MODE</key>
146+
<string>act_file_or_folder</string>
147+
<key>NEXT_COMMAND_ID</key>
148+
<string>clear.quarantine</string>
149+
<key>ENVIRONMENT_VARIABLES</key>
150+
<dict>
151+
<key>OMC_OBJ_PATH</key>
152+
<string></string>
153+
</dict>
154+
</dict>
155+
<dict>
156+
<key>NAME</key>
157+
<string>Clear All Quarantine Attributes</string>
158+
<key>COMMAND_ID</key>
159+
<string>clear.quarantine</string>
160+
<key>EXECUTION_MODE</key>
161+
<string>exe_script_file</string>
162+
<key>END_NOTIFICATION</key>
163+
<dict>
164+
<key>TITLE</key>
165+
<string>XAttr</string>
166+
<key>MESSAGE</key>
167+
<string>Cleared all quarantine attributes!</string>
168+
</dict>
169+
</dict>
143170
</array>
144171
<key>VERSION</key>
145172
<integer>2</integer>

Xattr.app/Contents/Resources/Scripts/add.dialog.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ source "$OMC_APP_BUNDLE_PATH/Contents/Resources/Scripts/xattr.library.sh"
77

88
# get values from hidden controls passed from parent dialog
99
XATTR_OBJECT_PATH="$OMC_NIB_DIALOG_CONTROL_3_VALUE"
10+
if [ -z "${XATTR_OBJECT_PATH}" ]; then
11+
# try exported OMC_OBJ_PATH
12+
XATTR_OBJECT_PATH="${OMC_OBJ_PATH}"
13+
fi
14+
1015
XATTR_PARENT_DIALOG_GUID="$OMC_NIB_DIALOG_CONTROL_4_VALUE"
1116
echo "XATTR_PARENT_DIALOG_GUID: ${XATTR_PARENT_DIALOG_GUID}"
1217

@@ -15,5 +20,7 @@ attribute_value="$OMC_NIB_DIALOG_CONTROL_2_VALUE"
1520

1621
/usr/bin/xattr -w "${attribute_name}" "${attribute_value}" "${XATTR_OBJECT_PATH}"
1722

18-
"$dialog" "$XATTR_PARENT_DIALOG_GUID" 1 omc_table_remove_all_rows
19-
load_attribute_table "$XATTR_PARENT_DIALOG_GUID" "${XATTR_OBJECT_PATH}"
23+
if [ -n "${XATTR_PARENT_DIALOG_GUID}" ]; then
24+
"$dialog" "$XATTR_PARENT_DIALOG_GUID" 1 omc_table_remove_all_rows
25+
load_attribute_table "$XATTR_PARENT_DIALOG_GUID" "${XATTR_OBJECT_PATH}"
26+
fi
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
echo "[$(/usr/bin/basename "$0")]"
4+
5+
echo "/usr/bin/xattr -r -d 'com.apple.quarantine' ${OMC_OBJ_PATH}"
6+
/usr/bin/xattr -r -d 'com.apple.quarantine' "${OMC_OBJ_PATH}"
7+
xattr_result=$?
8+
echo "xattr result: $xattr_result"
File renamed without changes.

Xattr.app/Contents/Resources/en.lproj/InfoPlist.strings

Lines changed: 0 additions & 12 deletions
This file was deleted.

codesign_app.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

codesign_applet.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
3+
self_dir=$(/usr/bin/dirname "$0")
4+
app_to_sign="$1"
5+
identity="$2"
6+
7+
if test -z "$app_to_sign"; then
8+
echo "error: a path to app must be provided"
9+
exit 1
10+
fi
11+
12+
# full path
13+
app_to_sign=$(/bin/realpath "$app_to_sign")
14+
app_id=$(/usr/bin/defaults read "$app_to_sign/Contents/Info.plist" CFBundleIdentifier)
15+
if test "$?" != "0"; then
16+
echo "error: could not obtain bundle identifier for app at: $app_to_sign"
17+
exit 1
18+
fi
19+
20+
entitlements_path="$self_dir/OMCApplet.entitlements"
21+
22+
if test -z "$identity"; then
23+
identity="-"
24+
entitlements=""
25+
timestamp="--timestamp=none"
26+
sign_options=""
27+
else
28+
entitlements="--entitlements $entitlements_path"
29+
timestamp="--timestamp"
30+
sign_options="--options runtime"
31+
fi
32+
33+
echo "/usr/bin/codesign --deep --verbose --force $sign_options $entitlements $timestamp --identifier $app_id --sign $identity $app_to_sign"
34+
/usr/bin/codesign --deep --verbose --force $sign_options $entitlements $timestamp --identifier "$app_id" --sign "$identity" "$app_to_sign"
35+
36+
echo ""
37+
echo "Verifying codesigned app:"
38+
echo "-------------------------"
39+
/usr/bin/codesign -dv --verbose=4 "$app_to_sign"
40+
echo "-------------------------"

0 commit comments

Comments
 (0)