kcrawford / dockutil

command line tool for managing dock items
http://patternbuffer.wordpress.com
Apache License 2.0
1.36k stars 131 forks source link

3.0.2 Dockutil hangs when run as sudo #126

Open K1jaff opened 2 years ago

K1jaff commented 2 years ago

sudo /usr/local/bin/dockutil --add "/Applications/Microsoft Outlook.app" --allhomes --no-restart -v

verbose mode 1 [file:///Users/Deleted%20Users/, file:///Users/_mbsetupuser/, file:///Users/.localized, file:///Users/Shared/, file:///Users/root/, file:///Users/anuser/, file:///Users/anuser2/] /Users/Deleted Users/Library/Preferences /Users/_mbsetupuser/Library/Preferences /Users/.localized/Library/Preferences /Users/Shared/Library/Preferences /Users/root/Library/Preferences /Users/anuser/Library/Preferences /Users/anuser2/Library/Preferences Plist paths: ["/Users/_mbsetupuser/Library/Preferences/com.apple.dock.plist", "/Users/root/Library/Preferences/com.apple.dock.plist", "/Users/anuser/Library/Preferences/com.apple.dock.plist", "/Users/anuser2/Library/Preferences/com.apple.dock.plist"] processing /Users/_mbsetupuser/Library/Preferences/com.apple.dock.plist Skipping: /Users/_mbsetupuser/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist processing /Users/root/Library/Preferences/com.apple.dock.plist Skipping: /Users/root/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist processing /Users/anuser/Library/Preferences/com.apple.dock.plist Skipping: /Users/anuser/Library/Preferences/com.apple.dock.plist does not seem to be a home directory or a dock plist processing /Users/anuser2/Library/Preferences/com.apple.dock.plist /Users/anuser2/Library/Preferences/com.apple.dock.plist Comparing /Users/anuser2/Library/Preferences/com.apple.dock.plist to /Users/anuser2/Library/Preferences/com.apple.dock.plist ^C - Hangs here

Running in user context or sudo -u $username works without issue.

Theile commented 2 years ago

I have the same problem:

# /usr/local/bin/dockutil --add "/Applications/Microsoft Word.app" --after 'Microsoft Edge' -v 
verbose mode 1
Plist paths: ["/Users/st/Library/Preferences/com.apple.dock.plist"]
processing /Users/st/Library/Preferences/com.apple.dock.plist
/Users/st/Library/Preferences/com.apple.dock.plist
Comparing /Users/st/Library/Preferences/com.apple.dock.plist to /Users/st/Library/Preferences/com.apple.dock.plist

^C

It just stalls on my MBP M1 on the comparing step. Alså if --allhomes is used.

dng2000 commented 2 years ago

That happens to me too when I manually run it with ‘sudo’ in Terminal. But running it outside of the user context as root via script (i.e. Jamf policy) works fine for my environment when I tested it last week.

David H. Ng Desktop Engineer | UCSF Information Technology Mission Center Building, Room MCB-316 San Francisco, CA 94143 Direct Phone: (415) 502-2382 Direct Email: @.*** https://www.ucsf.edu

From: Søren Theilgaard @.> Sent: Monday, April 11, 2022 7:32 AM To: kcrawford/dockutil @.> Cc: Subscribed @.***> Subject: Re: [kcrawford/dockutil] 3.0.2 Dockutil hangs when run as sudo (Issue #126)

I have the same problem: # /usr/local/bin/dockutil --add "/Applications/Microsoft Word.app" --after 'Microsoft Edge' -v verbose mode 1 Plist paths: ["/Users/st/Library/Preferences/com.apple.dock.plist"] processing /Users/st/Library/Preferences/com.apple.dock.plist ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization. ZjQcmQRYFpfptBannerEnd

I have the same problem:

/usr/local/bin/dockutil --add "/Applications/Microsoft Word.app" --after 'Microsoft Edge' -v

verbose mode 1

Plist paths: ["/Users/st/Library/Preferences/com.apple.dock.plist"]

processing /Users/st/Library/Preferences/com.apple.dock.plist

/Users/st/Library/Preferences/com.apple.dock.plist

Comparing /Users/st/Library/Preferences/com.apple.dock.plist to /Users/st/Library/Preferences/com.apple.dock.plist

^C

It just stalls on my MBP M1 on the comparing step. Alså if --allhomes is used.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/kcrawford/dockutil/issues/126*issuecomment-1095128126__;Iw!!LQC6Cpwp!vRXP6uNxF2LgDkUnJYnYlR1jMR5U26Z_RD1EOif7kgAxd-6GzC_1DFXx-Bpa1JEyLtFtV50V4cMUrnMrYxcozg$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ANKPKG2GWXQZZHXC6MAPOPLVEQZXNANCNFSM5QJI4P7A__;!!LQC6Cpwp!vRXP6uNxF2LgDkUnJYnYlR1jMR5U26Z_RD1EOif7kgAxd-6GzC_1DFXx-Bpa1JEyLtFtV50V4cMUrnOEqemdXw$. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

Theile commented 2 years ago

Thank you @dng2000, I will try again. I'm using Addigy, Mosyle and other MDMs (also Jamf), so I will verify if the others works the same way.

Theile commented 2 years ago

I had to specify the plist file directly for it to work. dockutil did finish, but without the direct link to the plist-file on the correct user, it would only find the root user, when using Addigy.

mallej commented 2 years ago

I have the same problem. Even if I run the script through Munki as a Post-Install-Script it hangs. But strangely, this does not happen on all my test VMs. I have 2 macOS 12.3.1 VMs and only on one dockutil hangs.

root@TEST-VM22-AutoPkg-Monterey ~ # /usr/local/bin/dockutil --add /Applications/Adobe\ Acrobat\ 2020/Adobe\ Acrobat.app --label 'Adobe Acrobat' --replacing 'Adobe Acrobat' --allhomes -v verbose mode 1 [file:///Users/.localized, file:///Users/Shared/, file:///Users/tadmin/] /Users/.localized/Library/Preferences /Users/Shared/Library/Preferences /Users/tadmin/Library/Preferences Plist paths: ["/Users/tadmin/Library/Preferences/com.apple.dock.plist"] processing /Users/tadmin/Library/Preferences/com.apple.dock.plist /Users/tadmin/Library/Preferences/com.apple.dock.plist Comparing /Users/tadmin/Library/Preferences/com.apple.dock.plist to /Users/tadmin/Library/Preferences/com.apple.dock.plist

TB-clientops commented 2 years ago

it looks like the defaults call on line 64 of Dock.swift is hanging without exit causing the whole thing to hang on the waitUntilExit() call. I'm not sure why defaults is hanging but that seems to be the holdup.

kcrawford commented 8 months ago

I think there is/was an Apple bug with defaults/cfpreferences that would cause it to hang. Has anyone reproduced this on Sonoma 14.2.1 or newer?

jonesiscoding commented 8 months ago

I have duplicated this using v3.0.2 on macOS 14.2.1, running as root. Using sudo -u <user> dockutil --list /Users/<user> works without issue.

It does not seem 100% consistent. In roughly 50 systems, I am seeing this on ~3.

Two things I should probably check when I have a free moment:

jonesiscoding commented 8 months ago

Just double-checked that it does not affect all users on the affected systems, just specific users. I don't see anything out of the ordinary in the plist, but I haven't done a careful inspection yet.