Skip to content

Commit 031bbdd

Browse files
committed
recognize the ^...$ syntax introduced by recent ogsudo and give an error message
1 parent d437fdc commit 031bbdd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/sudoers/tokens.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,13 @@ impl Token for Command {
185185
// if no arguments are mentioned, anything is allowed
186186
None
187187
} else {
188-
if args.last().map(|x| -> &str { x }) == Some("\"\"") {
188+
if args.first().is_some_and(|x| x.starts_with('^')) {
189+
// regular expressions are not supported, give an error message. If there is only a
190+
// terminating '$', this is not treated as a malformed regex by millersudo, so we
191+
// can ignore that.
192+
return Err("regular expressions in sudoers rules are not supported".to_string());
193+
}
194+
if args.last().is_some_and(|x| x == "\"\"") {
189195
// if the magic "" appears, no (further) arguments are allowed
190196
args.pop();
191197
}

0 commit comments

Comments
 (0)