How to prevent access an expected file using the wildcard('*') in sudoers.

Solution Verified - Updated -

Issue

  • In sudoers, I want to allow access to multiple files by using the wildcard('*') in the command list.

    testuser ALL = /bin/cat /var/log/messages*
    
  • However, this rule allows to access an unexpected file in the second file while still having root privileges. Is it possible to prevent it?

    ### OK
    $ sudo cat /var/log/messages-20200522
    
    ### NG
    $ sudo cat /var/log/messages /etc/shadow
    

Environment

  • Red Hat Enterprise Linux
  • sudo

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content