Bug 776 - Including file beginning with an "i" removed first 3 characters
Including file beginning with an "i" removed first 3 characters
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudo
1.8.19
PC Linux
: low low
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-02-13 13:18 MST by Robin James
Modified: 2017-05-10 10:35 MDT (History)
0 users

See Also:


Attachments
Fix for including files that start with the letter 'i' (15.10 KB, patch)
2017-02-13 13:36 MST, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robin James 2017-02-13 13:18:37 MST
If you add an include statement for a file beginning with the letter i the first 3 characters will be removed and a validation error will occur.

As an example, assume you create a file called /etc/itest and include it in your sudoers file using:
#include itest

If you add the above line using visudo it will prompt you to press enter to edit /etc/st.  When you edit the file it will save it to the prompted name and not the included file.

If you remove the /etc/st file then run a visudo -c it will print an error that file /etc/st file doesn't exist.  Running any of the commands in the included file will also fail and they won't display in a sudo -l.

If you add the same file to an included directory, e.g. /etc/sudoers.d, then the file will work as expected.

Tested against 1.8.6 & 1.8.19.
Comment 1 Todd C. Miller 2017-02-13 13:29:47 MST
Nice catch, I'm verifying a fix now.
Comment 2 Todd C. Miller 2017-02-13 13:36:21 MST
Created attachment 488 [details]
Fix for including files that start with the letter 'i'
Comment 3 Todd C. Miller 2017-02-13 13:42:28 MST
I've committed the fix:
https://www.sudo.ws/repos/sudo/rev/4d9691a43867
Comment 4 Robin James 2017-02-13 14:10:49 MST
Hi Todd,
   Yes, strange that this hasn't been reported before as I can't imagine I'm the first to encounter it.  Anyway, I've downloaded, compiled and tested the patch and I can confirm that the issue is resolved for me.  

Keep up the good work,
Robin
Comment 5 Todd C. Miller 2017-02-13 14:44:35 MST
Also, a workaround is to use a fully-qualified path, e.g.

#include /etc/itest
Comment 6 Todd C. Miller 2017-05-10 10:35:06 MDT
Fixed in sudo 1.8.20, available now.