Bug 670

Summary: Segfault when sudo -i run from non-existent directory
Product: Sudo Reporter: rmull <rmmullen>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: normal    
Priority: low    
Version: 1.8.11   
Hardware: PC   
OS: Linux   
Attachments: Fix for crash when current working directory cannot be determined

Description rmull 2014-10-07 09:13:26 MDT
Hello,

I can reproduce a segfault with sudo, version:

Sudo version 1.8.11
Sudoers policy plugin version 1.8.11
Sudoers file grammar version 43
Sudoers I/O plugin version 1.8.11

configure options:

./configure --prefix=/usr --libexecdir=/usr/lib --mandir=/usr/man --with-logfac=auth --with-vardir=/var/lib/sudo --with-rundir=/var/run/sudo --without-pam --disable-nls --disable-shadow

Steps to reproduce:

As user:

mkdir ~/test
cd ~/test
rm -rf ../test
sudo -i

Output:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Segmentation fault


Let me know if there is anything else I can provide
Comment 1 Todd C. Miller 2014-10-07 12:25:13 MDT
Created attachment 432 [details]
Fix for crash when current working directory cannot be determined
Comment 2 rmull 2014-10-07 13:33:32 MDT
(In reply to Todd C Miller from comment #1)
> Created attachment 432 [details]
> Fix for crash when current working directory cannot be determined

Patch fixes the segfault for me. sudo -i prints the same shell-init and chdir messages, but instead of a segfault I get the root prompt and my cwd is /root.

Thanks for the quick turnaround.
Comment 3 Todd C. Miller 2014-10-08 02:34:52 MDT
Fixed in sudo 1.8.11p1, available now.