Bug 373 - Bad file number with nested included files
Bad file number with nested included files
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Visudo
1.7.1
IBM AIX
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-11 08:49 MST by fg_bijlenga
Modified: 2010-06-18 16:15 MDT (History)
0 users

See Also:


Attachments
Fix for visudo "Bad file descriptor" error in bug #373 (1.11 KB, patch)
2010-06-10 16:43 MDT, Todd C. Miller
Details | Diff
Example wrong sudoers file opened (28.58 KB, image/png)
2010-06-11 05:05 MDT, fg_bijlenga
Details

Note You need to log in before you can comment on or make changes to this bug.
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.