Bug 373

Summary: Bad file number with nested included files
Product: Sudo Reporter: fg_bijlenga
Component: VisudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: normal    
Priority: low    
Version: 1.7.1   
Hardware: IBM   
OS: AIX   
Attachments: Fix for visudo "Bad file descriptor" error in bug #373
Example wrong sudoers file opened

Description fg_bijlenga 2009-11-11 08:49:18 MST
If you edit a sudoers file with an included sudoers file and that file have also an included sudoers file (nested include file) you get following error if you are redirected to edit first include file (which contains the nested include file):
visudo: can't stat /etc/sudoers.xxxxxx: Bad file number

If there are more included files in the sudoers file and one file contains also an included file visudo has an unpredictable behavior by starting sudoers file in stange order and with wrong content (content is belonging to other sudoers file
Comment 1 Todd C. Miller 2010-06-10 16:43:20 MDT
Created attachment 273 [details]
Fix for visudo "Bad file descriptor" error in bug #373

I've attached a fix for the first problem but have not been able to reproduce the second one.  I may have misunderstood your description of the problem, though.
Comment 2 fg_bijlenga 2010-06-11 05:05:59 MDT
Created attachment 275 [details]
Example wrong sudoers file opened
Comment 3 fg_bijlenga 2010-06-11 05:15:43 MDT
Second issue can be reproduced by:

Following include entries in /etc/sudoers:
#include        /var/frits/test/sudoers.fb
#include        /var/frits/test/sudoers1.fb

sudoers.fb contain also an include statement:
#include        /var/frits/test/sudoers2.fb

sudoers1.fb and sudoers2.fb doesn't have include files.

Starting visudo opens first /etc/sudoers (normal)
seconds it indicate to open /var/frits/test/sudoers.fb bu in fact it opens
/var/frits/test/sudoers1.fb
See attachement 275
Comment 4 Todd C. Miller 2010-06-11 09:49:38 MDT
The second problem has the same root cause as the first and the patch I attached fixes it as well.
Comment 5 Todd C. Miller 2010-06-18 16:15:28 MDT
Fixed in sudo 1.7.3.  Beta versions are out now, GA is due at the end of June.