Sudoers does not recognise templates on rights

Posted on

I have configured "grep" inside sudoers for a user, but it does not seem to recognise regular expressions.

[user1@server1:~] sudo /usr/bin/grep dummy /var/log/httpd/access_log |wc -l
9868
[user1@server1:~] sudo /usr/bin/grep dummy /var/log/httpd/a* |wc -l
/usr/bin/grep: /var/log/httpd/a*: No such file or directory
0

I am guessing the expansion of the regular expression is being done under the rights of "user1" rather than the target user. Is there a workaround for this?

sudo -l
User user1 may run the following commands on server1:
(root) EXEC: NOPASSWD: /usr/bin/vim /var/log/httpd/*, /usr/bin/cat, /usr/bin/tail, /usr/bin/more, /usr/bin/ls -al *, /usr/bin/gunzip, /usr/bin/gzip,
/usr/bin/vi /var/log/httpd/*, /usr/bin/grep * /var/log/httpd/*

Responses