Score:0

Sudo: Using arguments in /etc/sudoers.d/ file, particularly with mount (visudo rejects syntax)

sr flag

I have a syntax wrangling problem with sudo that may not be solvable.

I know I know, OpenBSD's new doas is better than sudo, but it is not available on CentOS 7 or Rocky 8. So we're stuck with sudo for a while, girls and guys.

If I add the following line with visudo -f /etc/sudoers.d/custom it works, and visudo doesn't complain about it:

%[email protected] *=(root) NOPASSWD: /usr/bin/mount -a

However, if I then add the following:

%[email protected] *=(root) NOPASSWD: /usr/bin/mount -o remount,rw nfs-server.domain.com:/nfs3 /mnt/nfs3

Then visudo consistently rejects it with: syntax error near line 41 (indeed it is line 41). I have tried various alternations of the above.

Any ideas why, or what would work?

Thank you

Score:0
sr flag

Solution was to read man sudoers as apparently some characters need escaping. Curiously the humble comma is one of them (not usually a sensitive character).

Extract:

 Note that the following characters must be escaped with a ‘\’
 if they are used in command arguments: ‘,’, ‘:’, ‘=’, ‘\’. 
Ginnungagap avatar
gu flag
The comma is how you separate a list of commands, it seems reasonable that it should be escaped to not mean that you're starting a new command to allow...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.