Skip to content

Commit cf833b3

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

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sudoers/tokens.rs

Lines changed: 9 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 don't
191+
// need to seperately check for that
192+
return Err("regular expressions 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
}
@@ -227,6 +233,8 @@ impl Token for SimpleCommand {
227233
return cvt_err(glob::Pattern::new(&cmd));
228234
} else if cmd.starts_with("sha") {
229235
return Err("digest specifications are not supported".to_string());
236+
} else if cmd.starts_with('^') {
237+
return Err("regular expressions are not supported".to_string());
230238
} else if !cmd.starts_with('/') {
231239
return Err("fully qualified path needed".to_string());
232240
}

0 commit comments

Comments
 (0)