kcrawford / dockutil

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

sudo used when not required resulting in an error for non-admin users #137

Open davidbpirie opened 2 years ago

davidbpirie commented 2 years ago

When running dockutil 3.0.2 on macOS 12.4 as a non-admin user with --add or --remove, an error of:

<username> is not in the sudoers file. This incident will be reported.

To aid in troubleshooting, adding a relatively-harmless temporary sudoers entry of:

<username> ALL=() NOPASSWD: /bin/ls

and then re-running dockutil as \<username> provides greater insight:

Sorry, user <username> is not allowed to execute '/usr/bin/defaults import /Users/<username>/Library/Preferences/com.apple.dock.plist -' as <username> on <hostname>.local.

My conclusion is that sudo is being used when not required ie when a user is trying to edit their own com.apple.dock.plist file.

As a temporary work-around, adding a sudoers file eg /private/etc/sudoers.d/dockutil as:

ALL ALL=() NOPASSWD: /usr/bin/defaults

allows dockutil to operate as expected, however I believe this work-around should not be required.

kylejericson commented 1 year ago

You can run this command to fix this. echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee "/private/etc/sudoers.d/dockutil"

kylejericson commented 1 year ago

Could we get this issue fixed the workaround is not a good thing to do. @kcrawford

mvught commented 1 year ago

Use a script to do this admin is not needed

kcrawford commented 7 months ago

This should be fixed in 3.1.1. Please test and confirm here if you can. Thanks for reporting the issue.