Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockutil 3 hangs #160

Open
bryanzak opened this issue Feb 9, 2024 · 4 comments
Open

dockutil 3 hangs #160

bryanzak opened this issue Feb 9, 2024 · 4 comments

Comments

@bryanzak
Copy link

bryanzak commented Feb 9, 2024

We use dockutil with Munki. All of our app installs via Munki have a postinstall script that basically does the same thing:

#!/bin/bash
	
itemToAdd="/Applications/appwejustadded.app"
itemLabel='appwejustadded'

for user in $(ls /Users/); do
	if [ -f "/Users/${user}/Library/Preferences/com.apple.dock.plist" ]; then  # make sure this is really a valid user
	
		/usr/local/bin/dockutil --add "$itemToAdd" --label "$itemLabel" --section apps "/Users/${user}"
	fi
done

# ensure icon is added to default user template for future users logging in
/usr/local/bin/dockutil --add "${itemToAdd}" --label "${itemLabel}" --section apps '/System/Library/User Template/English.lproj'

This has worked for us for many years, since 2014, with various updates to dockutil over the years (thanks!). We've installed hundreds of apps and web shortcuts into the Docks of thousands of macs over the years.

But sometimes dockutil hangs and I've never been able to track down what the exact cause is.

For example I just created a simple shell script

#!/bin/bash
	
itemToAdd="/Applications/ADP.webloc"
itemLabel="ADP"

for user in $(ls /Users/); do
	if [ -f "/Users/${user}/Library/Preferences/com.apple.dock.plist" ]; then
		echo "adding ${itemLabel} to /Users/${user} dock"
		sudo /usr/local/bin/dockutil --add "${itemToAdd}" --label "${itemLabel}" --verbose  --section apps "/Users/${user}"
	fi
done

and ran it and get this

adding ADP to /Users/epietrb111 dock
Password:
verbose mode 1
Plist paths: ["/Users/epietrb111"]
processing /Users/epietrb111
/Users/epietrb111 is a directory
/Users/epietrb111/Library/Preferences/com.apple.dock.plist
Ignoring case, /Users/epietrb111/Library/Preferences/com.apple.dock.plist and /Users/epietrb111/Library/Preferences/com.apple.dock.plist are the same so this dock is the logged in user's dock
Reading dock using defaults command

That's it - it never finishes. It's stuck reading the dock somehow?

I stopped using allhomes a while back due to some oddbug, but if I try it with this

#!/bin/bash
	
itemToAdd="/Applications/ADP.webloc"
itemLabel="ADP"


sudo /usr/local/bin/dockutil --add "${itemToAdd}" --label "${itemLabel}" --verbose  --section apps --allhomes

hangs in the same way:

Password:
verbose mode 1
[file:///Users/.localized, file:///Users/student/, file:///Users/Shared/, file:///Users/epietrb111/, file:///Users/fs/, file:///Users/teacher/]
/Users/.localized/Library/Preferences
/Users/student/Library/Preferences
/Users/Shared/Library/Preferences
/Users/epietrb111/Library/Preferences
/Users/fs/Library/Preferences
/Users/teacher/Library/Preferences
Plist paths: ["/Users/student/Library/Preferences/com.apple.dock.plist", "/Users/epietrb111/Library/Preferences/com.apple.dock.plist", "/Users/fs/Library/Preferences/com.apple.dock.plist", "/Users/teacher/Library/Preferences/com.apple.dock.plist"]
processing /Users/student/Library/Preferences/com.apple.dock.plist
/Users/student/Library/Preferences/com.apple.dock.plist
Ignoring case, /Users/epietrb111/Library/Preferences/com.apple.dock.plist and /Users/student/Library/Preferences/com.apple.dock.plist are different so this dock is not the logged in user's dock
Reading dock using defaults command
App is symlink: false
adding /Applications/ADP.webloc
Optional("Office 365 Login (Chrome)")
Optional("Google Chrome")
Optional("Safari")
Optional("Microsoft Edge")
Optional("Firefox")
Optional("Office 365 Login")
Optional("Microsoft Word")
Optional("Microsoft Excel")
Optional("Microsoft PowerPoint")
Optional("Microsoft Teams classic")
Optional("Safe2Help")
Optional("Wilson LS Launch Page")
Optional("Moof Documentation")
Optional("OPS Help Desk")
Optional("IPEVO Annotator")
Optional("Campus Parent")
Optional("Minecraft Education")
Optional("Zoom.us")
Optional("DIBS for Kids")
Optional("Canva")
Optional("Creative Cloud")
Optional("Canvas")
Optional("Kindergarten Roundup 2024")
Optional("My ADP")
Optional("Documents")
Optional("Downloads")
adding Optional("/Applications/ADP.webloc")
appending item to end of dock
Ignoring case, /Users/epietrb111/Library/Preferences/com.apple.dock.plist and /Users/student/Library/Preferences/com.apple.dock.plist are different so this dock is not the logged in user's dock
Handling dock while running as root
Using sudo to run defaults to write to dock as user 503
0
Ignoring case, /Users/epietrb111/Library/Preferences/com.apple.dock.plist and /Users/student/Library/Preferences/com.apple.dock.plist are different so this dock is not the logged in user's dock
processing /Users/epietrb111/Library/Preferences/com.apple.dock.plist
/Users/epietrb111/Library/Preferences/com.apple.dock.plist
Ignoring case, /Users/epietrb111/Library/Preferences/com.apple.dock.plist and /Users/epietrb111/Library/Preferences/com.apple.dock.plist are the same so this dock is the logged in user's dock
Reading dock using defaults command

I am using the recent 3.1.3 package and no change, this still happens

@kcrawford
Copy link
Owner

Thanks for reporting the issue. On which OS version(s) are you seeing the issue?

@kcrawford
Copy link
Owner

Are you modifying sudoers or otherwise requiring a password for certain sudo commands?
When the issue occurs, are you able to run sudo -u epietrb111 -H defaults read /Users/epietrb111/Library/Preferences/com.apple.dock.plist or sudo -u epietrb111 -H whoami?
Some macOS versions reportedly can get hung reading preferences though I don't know the details.

@bryanzak
Copy link
Author

Thanks for reporting the issue. On which OS version(s) are you seeing the issue?

This particular example was on 13.6.4, but I've seen it on a range of macOS versions over the past couple of years.

@bryanzak
Copy link
Author

Are you modifying sudoers or otherwise requiring a password for certain sudo commands? When the issue occurs, are you able to run sudo -u epietrb111 -H defaults read /Users/epietrb111/Library/Preferences/com.apple.dock.plist or sudo -u epietrb111 -H whoami? Some macOS versions reportedly can get hung reading preferences though I don't know the details.

I've been looking into this a bit the past few days and of course I can't trigger it on demand. I did find that once the problem happens, the "solution" seems to be to manually edit the dock - drag something on or off, or move an item's location. If I kill the stuck dockutil process, the next time dockutil runs it works as expected. So I'm thinking maybe this is some kind of cfprefsd caching issue where defaults is blocking and can't read the plist. Or something. I'll try the recommend command once I can trigger this issue again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants