Regex in Sudoers File?

10,541

sudo does not support regexps, but only file globbing.

See https://www.sudo.ws/man/sudoers.man.html#Wildcards

Share:
10,541
baeckerman83
Author by

baeckerman83

Updated on June 23, 2022

Comments

  • baeckerman83
    baeckerman83 almost 2 years

    I've a regex and want to use it in a sudoers file. But I couldn't get it work.

    \/test\/([0-9a-zA-Z\/]+\.[0-9a-zA-Z]+)+
    

    I found that it must be

    \\/test\\/([0-9a-zA-Z\/]+\.[0-9a-zA-Z]+)+
    

    But I didn't know how to use the regex after /([...

    Can I use the plus for 1 to n? What must I escape? And how?

  • rrauenza
    rrauenza almost 2 years
    FYI: Starting with version 1.9.10, it is possible to use regular expressions for path names and command line arguments.