Bugzilla – Bug 558
Rule with wildcard in path takes forever due to stat
Last modified: 2012-06-07 13:29:53 MDT
If I have rules, for example jlewing ALL = NOPASSWD: /*/jlewing/cdpinfo.pl jlewing ALL = NOPASSWD: /*/*/jlewing/cdpinfo.pl due to a variation of home directories across a large number of systems (and I use the same rules across all for ease of administration) and I enter sudo /home/jlewing/cdpinfo.pl the command takes an immense amount of time to complete. I have noticed that a stat is being done on all file systems and if one of those should hang then I am dead in the water. The fact that I have specified the full path to the command, to me, should programitically match with the first entry without doing a stat on every file system other than the one specified.
If you are going to use patterns like that in sudoers you probably want to enable the fast_glob option which causes sudo to use the fnmatch() function instead of glob(). Sudo matches commands by inode, which is why you are seeing all those stats. This is the only way to safely handle '!' rules and to consistently support things like "sudo ./command".