Bug 140 - sudo goes into loop closing invalid file descriptors at startup
sudo goes into loop closing invalid file descriptors at startup
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.6.7
Sun All
: normal normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-05-20 16:06 MDT by Theo Van Dinter
Modified: 2004-06-30 17:10 MDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Theo Van Dinter 2004-05-20 16:06:58 MDT
This afternoon I found that I couldn't run sudo in a way that worked last week.  Now, when 
a command is run, sudo would hang at startup. This is on a Solaris 7 machine, BTW.   
Doing some debugging, I found that sudo was sitting in a close() loop (seen below).  
Doing a search on Google, I found in the release notes for 1.6.2 that this was an issue on 
AIX if the limit for # of open files was "unlimited".  Sure enough, when I checked, "ulimit -
n" reported "unlimited".  If I set the number to an actual value, sudo ran the command 
without any hang as expected.

I can reproduce this repeatedly, and here's a summary of my test/debug procedure:

in one window:
(\#) \u@\h: \w $ uname -a
SunOS wile 5.7 Generic_106541-29 sun4u sparc SUNW,Ultra-250
(\#) \u@\h: \w $ sudo -l
User foo may run the following commands on this host:
    (root) NOPASSWD: ALL
(\#) \u@\h: \w $ ulimit -n      
unlimited                       
(\#) \u@\h: \w $ sudo uname -a
[hang]

from another window:
[ran ps|grep to find the sudo pid is 26995 in the first window]
$ sudo truss -p 26995
[...]
close(2116394580)                               Err#9 EBADF
close(2116394579)                               Err#9 EBADF
close(2116394578)                               Err#9 EBADF
close(2116394577)                               Err#9 EBADF
close(2116394576)                               Err#9 EBADF
close(2116394575)                               Err#9 EBADF
close(2116394574)                               Err#9 EBADF
close(2116394573)                               Err#9 EBADF
close(2116394572)                               Err#9 EBADF
close(2116394571)                               Err#9 EBADF
close(2116394570)                               Err#9 EBADF
close(2116394569)                               Err#9 EBADF
[...]
$ sudo kill 26995

back to first window: 
Terminated
(\#) \u@\h: \w $ (\#) \u@\h: \w $ ulimit -n 64
(\#) \u@\h: \w $ sudo uname -a
SunOS wile 5.7 Generic_106541-29 sun4u sparc SUNW,Ultra-250
(\#) \u@\h: \w $ sudo -V
Sudo version 1.6.7p5


I did several searches for the original bug for AIX/1.6.2, but couldn't find it, so I'm opening 
a new ticket about this.
Comment 1 Todd C. Miller 2004-05-20 16:27:50 MDT
Fixed in sudo 1.6.8 (which uses closefrom(3)).  There's a beta out now you can try if you wish.
Comment 2 Todd C. Miller 2004-06-30 13:10:53 MDT
Fixed in sudo 1.6.8.