Regex in Sudoers File? [closed]
Asked Answered
F

1

5

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?

Footie answered 22/3, 2016 at 12:29 Comment(2)
IIRC sudo does not support regexps, but only file globbingMobcap
Ok thank you! Than we use Cmnd_Alias CUSTCHMOD = /bin/chmod * \\/test\\/*, ! /bin/chmod * ..Footie
M
11

sudo does not support regexps, but only file globbing.

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

Update: Starting from 1.9.10 sudo also supports regular expressions: https://www.sudo.ws/docs/man/sudoers.man/#Regular_expressions

Mobcap answered 22/3, 2016 at 15:48 Comment(1)
FYI: Starting with version 1.9.10, it is possible to use regular expressions for path names and command line arguments.Slapup

© 2022 - 2024 — McMap. All rights reserved.