dockutil icon indicating copy to clipboard operation
dockutil copied to clipboard

3.0.2 Dockutil hangs when run as sudo

Open K1jaff opened this issue 2 years ago • 9 comments

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.

K1jaff avatar Mar 09 '22 11:03 K1jaff

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.

Theile avatar Apr 11 '22 14:04 Theile

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: @.@.>>

dng2000 avatar Apr 11 '22 17:04 dng2000

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 avatar Apr 12 '22 06:04 Theile

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.

Theile avatar Apr 12 '22 07:04 Theile

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

mallej avatar Apr 20 '22 12:04 mallej

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.

TB-clientops avatar Sep 06 '22 22:09 TB-clientops

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?

kcrawford avatar Jan 09 '24 04:01 kcrawford

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:

  • Does this happens with all users on the affected systems
  • Is there a common element in those user's com.apple.dock.plist that isn't found on the other ~47 systems.

jonesiscoding avatar Jan 11 '24 18:01 jonesiscoding

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.

jonesiscoding avatar Jan 11 '24 18:01 jonesiscoding