0

The following man page states that, "sudo allows shell-style wildcards (aka meta or glob characters) to be used in host names, path names and command line arguments in the sudoers file."

https://linux.die.net/man/5/sudoers

I've added the following to my sudoers file which allows the support user to start the Postfix service.

support     ALL=NOPASSWD: /bin/systemctl start postfix

Instead of adding multiple commands for each start, stop, restart action, I thought that I'd try to use globbing to match each case. Using https://www.digitalocean.com/community/tools/glob I came up with the glob string below.

enter image description here

Unfortunately this doesn't work. No syntax errors are generated, so that's good.

Does anyone have any ideas that I could try?

3
  • You are not asking this, but the reason what you're trying does not work is that what you're trying is an extended globbing pattern, whereas the type of patterns that are valid in the sudoers file are standard globbing patterns (not ?(...), *(...), +(...), @(...)).
    – Kusalananda
    Feb 8 at 7:41
  • Thanks for the info. You're welcome to post that as the answer and I'll accept it. Using your answers I've found sudo.ws/pipermail/sudo-users/2022-March/006477.html which mentions that "beginning with version 1.9.10, sudo supports POSIX regular expressions". Perhaps I'll upgrade the package and try that.
    – user559831
    Feb 8 at 7:50
  • You may post a self-answer if you wish. I did not write an answer because your question was not about why but about how, which my comment does not answer.
    – Kusalananda
    Feb 8 at 8:14

1 Answer 1

0

The sudoers file only supports standard globbing, not extended globbing. See the following thread for more detail.

https://www.sudo.ws/pipermail/sudo-users/2022-March/006475.html

1
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Feb 8 at 8:57

You must log in to answer this question.