sudo hangs before password

macOS Sierra

Version: 10.12.4 (16E195)


After updating today my OS, in a terminal when doing:

sudo ls

it hangs for a minute before showing the password.


What is going on?

How to debug this?

MacBook Pro, Mac OS X (10.7.5)

Posted on Mar 29, 2017 2:19 PM

Reply
38 replies

Apr 14, 2017 9:40 AM in response to Christian Hahn1

My bug report at Apple was finally looked at after 15 calendar days ⚠.


Apple closed it as "duplicate" so it is useless to update it. The duplicate bug number cannot be found (by me). So:

(a) any updates I do would be to my close bug, which would be useless.

(b) I have no idea what Apple is doing or will do since no response was added of any kind other than my bug marked as "Duplicate of 30585368 (Open)".


Very annoying to go to the trouble, wait 15 days, then get zero feedback and be locked out of knowing status (because I cannot find or see #30585368. At least not after trying many times.


https://macperformanceguide.com/blog/2017/20170328_1326-macOS-10_12_4-sudo-broke n.html

Apr 24, 2017 3:34 AM in response to oscahie

UPDATE:


Much prior to the Sierra update when i installed my system under el-capitan, I have added a custom Group (using System Preferences) and assigned my User to that Group so i did not have to put it in the OS X admin group.

(Strict separation of privileges)


I then added this custom group "%mygroup ALL=(ALL) ALL" to sudoers file because i trust sudo more than OSX to handle privilege escalation (also sudo asks for the login password).


This has worked well until the last system update.


I have now found out that the latest update must have REMOVED this custom group ENTIRELY.

Which explains why sudo runs in to a >5 minute timeout - it simply cannot resolve the Group name!

(sudo binary hangs doing rpc calls to localhost which are dropped by OS X default)


The "Workround" ealier removed all group references, including the one to this group that is no longer there.


The FIX - at least in my case - is supposed to be simple:


Just add the group again and restore my sudoers file...


*BAM*


System Preferences hangs.


Fortunately only for a minute, and if one does not Force-kill it, the group is finally back and sudo works with custom groups again...


tl'dr: Bug is in custom group handling, custom groups were removed by this update, screwing up sudo.

Apr 24, 2017 3:36 AM in response to oscahie

Please disregard my previous reply, I was wrong. It's not the presence of the NOPASSWD attribute alone that triggers the issue but the fact that it appears on a group entry (i.e. a line that begins with %). I was furthermore using a non-existing group, which might have contributed to the issue. I've now added a user entry instead, with NOPASSWD, and it works fine.


edit: nice timing of your response J46256 🙂 It's clear now what the issue actually was: a non-existing group name!

Apr 24, 2017 8:11 PM in response to DEVToboggan

I also have the same problem. My macbook air updated to 10.12.4 a day or two ago and I came to use sudo for the first time today and found that it just hangs for 5 or so minutes before it completes the action.


I finally got into my sudoers file but I do not have the "%users ALL= NOPASSWD: /sbin/kextload, /sbin/kextunload" line. All I had was this:


root ALL=(ALL) ALL

%admin ALL=(ALL) ALL

%DOMAIN\\Domain\ Admins ALL=(ALL) ALL


I had a hunch and commented out the domain admins line, and it now works fine. I haven't recently been on the network that has the AD controller that my account is on (the account is set as a mobile account so I can use it away from the network) but this hasn't been an issue until this update to 10.12.4.

Apr 25, 2017 12:32 AM in response to GGendron

GGendron wrote:


Please advise: is the "%" indicative of a Group? and there is no Group with my personal username?

Yes, %groupname references a Usergroup.

Can be local but also from a remote directory service (Apple Directory, NIS, Microsoft AD, LDAP ...)


The Bug seems to be that a Group name that is not a local group (check the file /etc/groups or SystemPreferences -> Users&Groups -> Groups list below the listed users) than "sudo" hangs with very long timeouts trying to resolve that group over dysfunctional RPC methods (a trace shows RPC calls over network against localhost that are not answered because there is no such RPC service running on a client).


Note that the group "admin" should always exist, as this is a fundamental part of Mac OS X user concept!

Only other (custom) groups appear to habe been deleted with the last update, breaking sudo.

Apr 27, 2017 9:55 AM in response to J46256

Thanks for the fix, Juergen!


I found that removing the reference to the ONE group that did not exist in /etc/group fixed the problem for me.


I had a row in /etc/sudoers.d/alan that said "%sudo ALL=(ALL) NOPASSWD: ALL", but there was no group called "sudo". When I commented out that one line, the 4.5 minute delay went away.

My /etc/sudoers file still contains a group line for the "admin" group, which does exist in /etc/group.


Alan

Jul 31, 2017 10:26 AM in response to DEVToboggan

I was also facing this issue for almost 3-4 months, It was bugging me a lot. It made me almost mad. Yesterday i decided to sit down and fix this issue once and for all.


After lot of reading and all i found that AMPPS entry in sudoers file is culprit.


open sudoers file using sudo visudo command (take backup of sudoers file before making changes and also read guide to use "visodo" )


I commented 2 lines in my sudoers file and everything is fine now.


#%amit ALL= NOPASSWD: /Applications/AMPPS/Ampps.app

#%amit ALL= NOPASSWD: /Applications/AMPPS/ampps


Similar experience/solution has been shared by this blogger here, https://macperformanceguide.com/blog/2017/20170407_1157-macOS-10_12_4-sudo-broke n-fix.html


You might not be having AMPPS on your machine so what worked for me, might not work for you.


Point to highlight is "There is something in there in your sudoers file which is causing issue, just find that line"

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

sudo hangs before password

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.