Skip to content

Allow space between Defaults@ and hostname list#1509

Open
squell wants to merge 3 commits intomainfrom
papercut-hostname-default
Open

Allow space between Defaults@ and hostname list#1509
squell wants to merge 3 commits intomainfrom
papercut-hostname-default

Conversation

@squell
Copy link
Member

@squell squell commented Mar 11, 2026

Closes #1508

Needs regression tests in sudoers/test/mod.rs to also check edge cases such as:

Defaults@\
  ALL lecture

are accepted (edit ogsudo rejects these too) and that

Defaults@# a comment ALL lecture

and

Defaults@# a comment
ALL lecture

and

Defaults@# a comment \
ALL lecture

are rejected

@squell squell marked this pull request as draft March 11, 2026 09:10
@squell squell added the C-parser Parser/AST label Mar 11, 2026
@squell squell force-pushed the papercut-hostname-default branch from b2943c0 to a5f2dfb Compare March 11, 2026 21:18
@squell
Copy link
Member Author

squell commented Mar 11, 2026

Note: commit 516334e is debatable; ogsudo doesn't allow line continuations at all in host/user/...-specific defaults (it would be interesting to look at how their parser solves the conundrum). We used to not allow it only in @ because of the stream.get_pos().0 == begin_pos.0 check (which checks we are still on the same line), but for Defaults@ it's superfluous.

During early sudo-rs development I've often had discussions with @rnijveld where he expressed severe doubts if we could manage to parse /etc/sudoers with a relatively textbook look-ahead-1 recursive descent parser. Turns out that we still can.. more or less. (Maybe you could argue resetting the parsing position is definitely a form of backtracking; but I think it's an implementation trick only... maybe; this would be a nice topic for a bachelor's thesis in theoretical computer science)

@squell squell marked this pull request as ready for review March 11, 2026 21:36
@squell squell requested a review from bjorn3 March 19, 2026 15:01
@squell squell force-pushed the papercut-hostname-default branch 2 times, most recently from 04a9b54 to fea55d0 Compare March 24, 2026 10:40
@squell squell force-pushed the papercut-hostname-default branch from fea55d0 to e9c2b44 Compare March 24, 2026 10:45
@squell
Copy link
Member Author

squell commented Mar 24, 2026

Note: b294cba can add the strictness here that ogsudo has (but it introduces a little bit extra complexity to a delicate part). I think if we're going to go one way or the other for Defaults@ it should at least be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-parser Parser/AST

Projects

None yet

Development

Successfully merging this pull request may close these issues.

does not work for Defaults@ Host_List

2 participants