Bug 552

Summary: sudo 1.8.4 hangs on AIX 6.1 if no TTY is available
Product: Sudo Reporter: Paul Donohue <sudo-bugs>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: high CC: huncraft
Priority: low    
Version: 1.8.4   
Hardware: IBM   
OS: AIX   
Attachments: Patch to open /proc/ppid/fd/[0-2] in non-blocking mode

Description Paul Donohue 2012-04-09 16:28:42 MDT
On AIX 6.1, sudo 1.8.4 will always hang (even just 'sudo -V' or 'sudo -h' hangs) if it is run without a TTY (for example, if it is run from a cron job or from a script executed using 'ssh -T ...').

This seems to be caused by the following change:
http://www.sudo.ws/repos/sudo/rev/b9dfce12af85

Here is a stack trace from a hung sudo process:
#0  0xd013087c in open () from /usr/lib/libc.a(shr.o)
#1  0xd013019c in open64 () from /usr/lib/libc.a(shr.o)
#2  0x1000b430 in get_process_ttyname () at ./ttyname.c:168
#3  0x1000952c in get_user_info.constprop.11 () at ./sudo.c:469
#4  0x10000578 in main (argc=2, argv=<incomplete type>, envp=<incomplete type>) at  _start_ :198

It looks like calling open() on /proc/<parent PID>/fd/1 under AIX simply hangs forever.
Comment 1 Todd C. Miller 2012-04-10 09:12:59 MDT
Created attachment 339 [details]
Patch to open /proc/ppid/fd/[0-2] in non-blocking mode

I'm unable to reproduce this behavior on AIX 6.1 but opening the file in non-blocking mode should help.  Please try the attached patch.  If that doesn't help I have a test program I'll ask you to run under truss.
Comment 2 Todd C. Miller 2012-04-10 16:59:26 MDT
Can you try the current beta version of sudo 1.8.5?  I've rewritten the tty fallback code for systems with an SVR4-style /proc (like AIX).  See http://www.sudo.ws/devel.html
Comment 3 Paul Donohue 2012-04-16 13:20:06 MDT
Sorry for the delay in responding.

I just tried 1.8.5rc1, and everything seems to work fine.  I have not tried the non-blocking patch ... it looks like you've replaced all that code now anyway.

Thank you very much!
Comment 4 Todd C. Miller 2012-05-24 10:37:27 MDT
*** Bug 557 has been marked as a duplicate of this bug. ***