trifectatechfoundation / sudo-rs

A memory safe implementation of sudo and su.
Other
2.87k stars 76 forks source link

Stray escape sequence #836

Open Timmmm opened 5 months ago

Timmmm commented 5 months ago

I get this complaint from sudo-rs and not sudo:

/etc/sudoers.d/lx-srv-admins:1:14: stray escape sequence
%MYCOMPANY.COM\\lx-srv-admins ALL=(ALL)       NOPASSWD: ALL

I didn't write that file but based on other comments on the internet it seems legal to have \\ or other backslashes in that file. sudo-rs only allows \n:

            // line continuations
            if accept_if(|c| c == '\\', stream).is_some() {
                // do the equivalent of expect_syntax('\n', stream)?, without recursion
                if accept_if(|c| c == '\n', stream).is_none() {
                    unrecoverable!(stream, "stray escape sequence")
                }
squell commented 5 months ago

Your analysis is correct; and this is related to issue #17 (the resolution of that would also close this issue, but I'd prefer to keep this open as it gives a demonstration of a use case); in Todd Miller's sudo you can probably also write

"%MYCOMPANY.COM\lx-srv-admins" ALL=(ALL) NOPASSWD: ALL but not (yet) in sudo-rs.