Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

On a Ubuntu 9 64bit Linux machine, sudo takes longer time to start. "sudo echo hi" takes 2-3 minutes. strace on sudo tells poll("/etc/pam.d/system-auth", POLLIN) timesout after 5 seconds and there are multiple calls(may be a loop) to same system call (which causes 2-3min delay).

Any idea why sudo has to wait for /etc/pam.d/system-auth? Any tunable to make sudo to timeout faster?

Thanks Samuel

share|improve this question

migrated from stackoverflow.com May 10 '10 at 7:25

This question came from our site for professional and enthusiast programmers.

    
How responsive is your LDAP server? What is in /etc/pam.d/system-auth? –  Kevin M Jun 13 '10 at 11:46

3 Answers 3

The largest cause of sudo being slow is the system not being able to resolve it's own hostname. Do you have your local hostname included in /etc/hosts? If not I would recommend adding it with the IP 127.0.1.1 which is what I do on all my systems. I add the entry with both the short hostname and the full qualified domain name (FQDN). This then removes the delay in sudo access calls 9 out of 10 times.

share|improve this answer

I can't help but think that the poll() call may be a red herring.

Whenever I have seen sudo being exceptionally slow, it has always been DNS that is at fault. Whether it's old, dead servers listed in /etc/resolv.conf or a misconfigured firewall that's blocking port 53 outbound or something else entirely, I have always found that dig google.com is slow when sudo echo foo is slow.

Even if it is not DNS, I suspect the slowness is network related and possibly authentication related (as Kevin M suggested) in which case the poll() call may not be a red herring after all.

Try running a tcpdump while trying to run sudo and see what shows up.

share|improve this answer

What is /etc/pam.d/system-auth? Is it a file? Does it exist? Is it a socket?

The docs say:

Now look at the last auth line:

auth       required     pam_stack.so service=system-auth

The pam_stack module runs all the modules in the file listed after service= (another PAM config file), and returns whatever result that file's modules return.

The line says that the user can use the hwbrowser command if they pass all the auth modules listed in the PAM configuration file "system-auth". This is a Red Hat thing. The folks at Red Hat decided to centralize a lot of security policies into that one file. If you look at some other configuration files in /etc/pam.d on a Red Hat based system you will see the same line. (Note this file is over-written each time the "authconfig" command is run, so it is important to keep a backup copy of this file handy, especially if you edit it manually.) Centralizing your default access policy in one PAM configuration file is a good idea, so if and when it changes you need only update that one file.

If the file exists, there might be a problem with your harddisk.

share|improve this answer
    
Going straight from if it exists to problem with HDD? Might there not be a problem with the file? –  Kevin M Jun 13 '10 at 11:45
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. –  kasperd Aug 1 at 11:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.