Debian Codegraph @

src/sudoers/test/mod.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#;
2
3 use superrust-analyzer cargo sudo-rs 0.2.14 sudoers/::astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/;
4 use superrust-analyzer cargo sudo-rs 0.2.14 sudoers/::char_streamrust-analyzer cargo sudo-rs 0.2.14 sudoers/char_stream/::CharStreamrust-analyzer cargo sudo-rs 0.2.14 sudoers/char_stream/CharStream#;
5 use superrust-analyzer cargo sudo-rs 0.2.14 sudoers/::*;
6 use basic_parserrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/::{parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval()., parse_linesrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_lines()., parse_stringrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_string().};
7
8 impl<T> Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#<T> {
9 pub fn as_allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[`Qualified<T>`]as_allow().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&T> {
10 if let Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[`Qualified<T>`]::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(v) = self {
11 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v)
12 } else {
13 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
14 }
15 }
16 }
17
18 impl<T> Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#<T> {
19 pub fn is_aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[`Meta<T>`]is_alias().(&self) -> bool {
20 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[`Meta<T>`]::Aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#Alias#(..))
21 }
22 }
23
24 impl Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo# {
25 pub fn is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().(&self) -> bool {
26 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]::Specrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#Spec#(..))
27 }
28
29 pub fn is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().(&self) -> bool {
30 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]::Declrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#Decl#(..))
31 }
32
33 pub fn is_line_commentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_line_comment().(&self) -> bool {
34 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]::LineCommentrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#LineComment#)
35 }
36
37 pub fn is_includerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include().(&self) -> bool {
38 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]::Includerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#Include#(..))
39 }
40
41 pub fn is_include_dirrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include_dir().(&self) -> bool {
42 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]::IncludeDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#IncludeDir#(..))
43 }
44
45 pub fn as_includerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]as_include().(&self) -> &str {
46 if let Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]::Includerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#Include#(v, _) = self {
47 v
48 } else {
49 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!()
50 }
51 }
52
53 pub fn as_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]as_spec().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&PermissionSpecrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/PermissionSpec#> {
54 if let Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]::Specrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#Spec#(v) = self {
55 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v)
56 } else {
57 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
58 }
59 }
60 }
61
62 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
63 struct Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#(&'static str);
64
65 fn dummy_cksumrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/dummy_cksum().(name: &str) -> u32 {
66 if name rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."root" {
67 0
68 } else {
69 1000 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().name.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fold().(0, |x, y| (x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().97 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add().y as u32) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Rem<Self>`]rem().1361)
70 }
71 }
72
73 impl UnixUserrust-analyzer cargo sudo-rs 0.2.14 system/interface/UnixUser# for Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named# {
74 fn has_namerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]has_name().(&self, name: &str) -> bool {
75 self.0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().name
76 }
77
78 fn has_uidrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]has_uid().(&self, uid: UserIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/UserId#) -> bool {
79 UserIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/UserId#::newrust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[UserId]new().(dummy_cksumrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/dummy_cksum().(self.0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#0.)) rust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[UserId][`PartialEq<Self>`]eq().==rust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[UserId][`PartialEq<Self>`]eq(). rust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[UserId][`PartialEq<Self>`]eq().uid
80 }
81
82 fn in_group_by_namerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]in_group_by_name().(&self, name: &CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#) -> bool {
83 self.has_namerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]has_name().(name.to_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
84 }
85
86 fn in_group_by_gidrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]in_group_by_gid().(&self, gid: GroupIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/GroupId#) -> bool {
87 GroupIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/GroupId#::newrust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[GroupId]new().(dummy_cksumrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/dummy_cksum().(self.0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#0.)) rust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[GroupId][`PartialEq<Self>`]eq().==rust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[GroupId][`PartialEq<Self>`]eq(). rust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[GroupId][`PartialEq<Self>`]eq().gid
88 }
89
90 fn is_rootrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]is_root().(&self) -> bool {
91 self.0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#0. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."root"
92 }
93 type Grouprust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]Group# = Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#;
94 fn grouprust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser]group().(&self) -> Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named# {
95 Selfrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixUser](self.0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#0.)
96 }
97 }
98
99 impl UnixGrouprust-analyzer cargo sudo-rs 0.2.14 system/interface/UnixGroup# for Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named# {
100 fn as_gidrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixGroup]as_gid().(&self) -> GroupIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/GroupId# {
101 GroupIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/GroupId#::newrust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[GroupId]new().(dummy_cksumrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/dummy_cksum().(self.0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#0.))
102 }
103 fn try_as_namerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixGroup]try_as_name().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
104 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#0.)
105 }
106 }
107
108 macro_rules! requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request! {
109 ($user:ident) => {
110 (&Named(stringify!($user)), &Named(stringify!($user)))
111 };
112 ($user:ident, $group:ident) => {
113 (&Named(stringify!($user)), &Named(stringify!($group)))
114 };
115 }
116
117 macro_rules! sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer! {
118 ($($e:expr),*) => {
119 parse_lines(&mut CharStream::new(&[$($e),*, ""].join("\n")))
120 .into_iter()
121 .map(|x| Ok::<_,basic_parser::Status>(x.unwrap()))
122 }
123 }
124
125 // alternative to parse_eval, but goes through sudoer! directly
126 #[must_use]
127 fn parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().(s: &str) -> Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo# {
128 sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer!![s].nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
129 }
130
131 /// Returns `None` if a syntax error is encountered
132 fn try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().(s: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#> {
133 parse_linesrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_lines().(&mut CharStreamrust-analyzer cargo sudo-rs 0.2.14 sudoers/char_stream/CharStream#::newrust-analyzer cargo sudo-rs 0.2.14 sudoers/char_stream/impl#[`CharStream<'a>`]new().(&[s, ""].joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().("")))
134 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
135 .nextrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/into_iter/impl#[`IntoIter<T, A>`][Iterator]next().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().
136 .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
137 }
138
139 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
140 fn ambiguous_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/ambiguous_spec().() {
141 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("marc, User_Alias ALL = ALL").is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().());
142 }
143
144 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
145 fn permission_testrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/permission_test().() {
146 let root = || (&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("root"), &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("root"));
147
148 let realpath =
149 |path: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#| craterust-analyzer cargo sudo-rs 0.2.14 crate/::commonrust-analyzer cargo sudo-rs 0.2.14 common/::resolverust-analyzer cargo sudo-rs 0.2.14 common/resolve/::canonicalizerust-analyzer cargo sudo-rs 0.2.14 common/resolve/canonicalize().(path).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(path.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().());
150
151 macro_rules! FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL! {
152 ([$($sudo:expr),*], $user:expr => $req:expr, $server:expr; $command:expr) => {
153 let (Sudoers { rules,aliases,settings, customisers }, _) = analyze(Path::new("/etc/fakesudoers"), sudoer![$($sudo),*]);
154 let cmdvec = $command.split_whitespace().map(OsString::from).collect::<Vec<_>>();
155 let req = Request { user: $req.0, group: $req.1, command: &realpath(cmdvec[0].as_ref()), arguments: &cmdvec[1..].to_vec() };
156 assert_eq!(Sudoers { rules, aliases, settings, customisers }.check(&Named($user), &system::Hostname::fake($server), req).flags, None);
157 }
158 }
159
160 macro_rules! passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass! {
161 ([$($sudo:expr),*], $user:expr => $req:expr, $server:expr; $command:expr $(=> [$($key:ident : $val:expr),*])?) => {
162 let (Sudoers { rules,aliases,settings, customisers }, _) = analyze(Path::new("/etc/fakesudoers"), sudoer![$($sudo),*]);
163 let cmdvec = $command.split_whitespace().map(OsString::from).collect::<Vec<_>>();
164 let req = Request { user: $req.0, group: $req.1, command: &realpath(cmdvec[0].as_ref()), arguments: &cmdvec[1..].to_vec() };
165 let result = Sudoers { rules, aliases, settings, customisers }.check(&Named($user), &system::Hostname::fake($server), req).flags;
166 assert!(!result.is_none());
167 $(
168 let result = result.unwrap();
169 $(assert_eq!(result.$key, $val);)*
170 )?
171 }
172 }
173 macro_rules! SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX! {
174 ([$sudo:expr]) => {
175 assert!(parse_string::<Sudo>($sudo).is_err())
176 };
177 }
178
179 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["ALL ALL = (;) ALL"]);
180 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(ALL:ALL) ALL"], "nobody" => root(), "server"; "/bin/hello");
181 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
182 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) /bin/foo"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nonerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#None#]);
183 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(ALL:ALL) /bin/foo"], "user" => root(), "server"; "/bin/hello");
184 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) PASSWD: /bin/foo"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Passwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Passwd#]);
185 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) NOPASSWD: PASSWD: /bin/foo"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Passwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Passwd#]);
186 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) PASSWD: NOPASSWD: /bin/foo"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#]);
187 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) /bin/foo, NOPASSWD: /bin/bar"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nonerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#None#]);
188 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) /bin/foo, NOPASSWD: /bin/bar"], "user" => root(), "server"; "/bin/bar" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#]);
189 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) NOPASSWD: /bin/foo, /bin/bar"], "user" => root(), "server"; "/bin/bar" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#]);
190 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) CWD=/ /bin/foo, /bin/bar"], "user" => root(), "server"; "/bin/bar" => [cwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#cwd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#::Pathrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#Path#("/".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))]);
191 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) CWD=/ /bin/foo, CWD=* /bin/bar"], "user" => root(), "server"; "/bin/bar" => [cwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#cwd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#::Anyrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#Any#)]);
192 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) CWD=/bin CWD=* /bin/foo"], "user" => root(), "server"; "/bin/foo" => [cwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#cwd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#::Anyrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#Any#)]);
193 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) CWD=/usr/bin NOPASSWD: /bin/foo"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#, cwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#cwd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#::Pathrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#Path#("/usr/bin".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))]);
194 //note: original sudo does not allow the below
195 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) NOPASSWD: CWD=/usr/bin /bin/foo"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#, cwdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#cwd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ChDirrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#::Pathrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/ChDir#Path#("/usr/bin".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))]);
196
197 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/e##o"], "user" => root(), "vm"; "/bin/e");
198 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["ALL ALL=(ALL) /bin/\n/echo"]);
199
200 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
201 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user laptop=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
202
203 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=!/bin/hello", "user ALL=/bin/hello"], "user" => root(), "server"; "/bin/hello");
204 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/hello", "user ALL=!/bin/hello"], "user" => root(), "server"; "/bin/hello");
205
206 for alias in [
207 "User_Alias GROUP=user1, user2",
208 "User_Alias GROUP=ALL,!user3",
209 ] {
210 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!([alias,"GROUP ALL=/bin/hello"], "user1" => root(), "server"; "/bin/hello");
211 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!([alias,"GROUP ALL=/bin/hello"], "user2" => root(), "server"; "/bin/hello");
212 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!([alias,"GROUP ALL=/bin/hello"], "user3" => root(), "server"; "/bin/hello");
213 }
214 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello arg"], "user" => root(), "server"; "/bin/hello arg");
215 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello arg"], "user" => root(), "server"; "/bin/hello arg");
216 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello arg"], "user" => root(), "server"; "/bin/hello arg");
217 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/hello arg"], "user" => root(), "server"; "/bin/hello boo");
218 // several test cases with globbing in the arguments are explicitly not supported by sudo-rs
219 //pass!(["user ALL=/bin/hello a*g"], "user" => root(), "server"; "/bin/hello aaaarg");
220 //FAIL!(["user ALL=/bin/hello a*g"], "user" => root(), "server"; "/bin/hello boo");
221 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello"], "user" => root(), "server"; "/bin/hello boo");
222 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/hello \"\""], "user" => root(), "server"; "/bin/hello boo");
223 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello \"\""], "user" => root(), "server"; "/bin/hello");
224 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel*"], "user" => root(), "server"; "/bin/hello");
225 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel*"], "user" => root(), "server"; "/bin/help");
226 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel*"], "user" => root(), "server"; "/bin/help me");
227 //pass!(["user ALL=/bin/hel* *"], "user" => root(), "server"; "/bin/help");
228 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/hel* me"], "user" => root(), "server"; "/bin/help");
229 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel* me"], "user" => root(), "server"; "/bin/help me");
230 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/hel* me"], "user" => root(), "server"; "/bin/help me please");
231 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/hel* me"], "user" => root(), "server"; "/bin/help only me");
232 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel*"], "user" => root(), "server"; "/bin/help me please");
233 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel* *"], "user" => root(), "server"; "/bin/help me please");
234 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel* me *"], "user" => root(), "server"; "/bin/help me please");
235 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hel* me please *"], "user" => root(), "server"; "/bin/help me please");
236
237 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) /bin/foo"], "user" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nonerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#None#]);
238 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["root ALL=(ALL:ALL) /bin/foo"], "root" => root(), "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#]);
239 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { user, user }, "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#]);
240 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:ALL) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { user, root }, "server"; "/bin/foo" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nonerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#None#]);
241
242 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("user").as_gidrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Named][UnixGroup]as_gid().(), GroupIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/GroupId#::newrust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[GroupId]new().(1466));
243 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["#1466 server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
244 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["%#1466 server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
245 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["#1466 server=(ALL:ALL) ALL"], "root" => root(), "server"; "/bin/hello");
246 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["%#1466 server=(ALL:ALL) ALL"], "root" => root(), "server"; "/bin/hello");
247 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["#1466,#1234,foo server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
248 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["#1234,foo,#1466 server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
249 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["foo,#1234,#1466 server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
250 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["foo,#1234,#1366 server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
251 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["#1366,#1234,foo server=(ALL:ALL) ALL"], "user" => root(), "server"; "/bin/hello");
252 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:#1466) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
253 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(ALL:#1466) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, other }, "server"; "/bin/foo");
254 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL:#1466) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, user }, "server"; "/bin/foo");
255 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(root,user:ALL) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, wheel }, "server"; "/bin/foo");
256 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(root,user:ALL) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { user, wheel }, "server"; "/bin/foo");
257 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(root,user:ALL) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, wheel }, "server"; "/bin/foo");
258 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(#0:wheel) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, wheel }, "server"; "/bin/foo");
259 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(#0:wheel) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
260 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(%#1466:wheel) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
261 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(%#1466:wheel) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { user, user }, "server"; "/bin/foo");
262
263 // tests with a 'singular' runas spec
264 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(ALL) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, wheel }, "server"; "/bin/foo");
265 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(ALL) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, sudo }, "server"; "/bin/foo");
266
267 // tests without a runas spec
268 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, sudo }, "server"; "/bin/foo");
269 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, root }, "server"; "/bin/foo");
270 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=/bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, sudo }, "server"; "/bin/foo");
271 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
272
273 // slightly counterintuitive test which simulates only -g being passed
274 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(sudo:sudo) /bin/foo"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { user, sudo }, "server"; "/bin/foo");
275
276 // tests with multiple runas specs
277 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(root) /bin/ls, (sudo) /bin/true"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root }, "server"; "/bin/ls");
278 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(root) NOPASSWD: /bin/ls, (sudo) /bin/true"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo }, "server"; "/bin/true" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#]);
279 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(root) /bin/ls, (sudo) /bin/true"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo }, "server"; "/bin/ls");
280 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["user ALL=(root) /bin/ls, (sudo) /bin/true"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root }, "server"; "/bin/true");
281 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=(root) NOPASSWD: /bin/ls, (sudo) /bin/ls, /bin/true"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo }, "server"; "/bin/true");
282
283 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["User_Alias, marc ALL = ALL"]);
284 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["Host_Alias CHROOT = server"]);
285 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["User_Alias CWD = user1"]);
286 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["User_Alias NOTAFTER = user1"]);
287 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["Runas_Alias NOTBEFORE = root"]);
288 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["Cmnd_Alias TIMEOUT = /bin/ls"]);
289 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["User_Alias ROLE = sudouser"]);
290 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["User_Alias TYPE = sudouser"]);
291
292 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["User_Alias FULLTIME=ALL,!marc","FULLTIME ALL=ALL"], "user" => root(), "server"; "/bin/bash");
293 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["User_Alias FULLTIME=ALL,!marc","FULLTIME ALL=ALL"], "marc" => root(), "server"; "/bin/bash");
294 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["User_Alias FULLTIME=ALL,!marc","ALL,!FULLTIME ALL=ALL"], "user" => root(), "server"; "/bin/bash");
295 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["User_Alias FULLTIME=ALL,!!!marc","ALL,!FULLTIME ALL=ALL"], "marc" => root(), "server"; "/bin/bash");
296 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Host_Alias MACHINE=laptop,server","user MACHINE=ALL"], "user" => root(), "server"; "/bin/bash");
297 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Host_Alias MACHINE=laptop,server","user MACHINE=ALL"], "user" => root(), "laptop"; "/bin/bash");
298 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["Host_Alias MACHINE=laptop,server","user MACHINE=ALL"], "user" => root(), "desktop"; "/bin/bash");
299 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Cmnd_Alias WHAT=/bin/dd, /bin/rm","user ALL=WHAT"], "user" => root(), "server"; "/bin/rm");
300 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Cmd_Alias WHAT=/bin/dd,/bin/rm","user ALL=WHAT"], "user" => root(), "laptop"; "/bin/dd");
301 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["Cmnd_Alias WHAT=/bin/dd,/bin/rm","user ALL=WHAT"], "user" => root(), "desktop"; "/bin/bash");
302
303 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["User_Alias A=B","User_Alias B=user","A ALL=ALL"], "user" => root(), "vm"; "/bin/ls");
304 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Host_Alias A=B","Host_Alias B=vm","ALL A=ALL"], "user" => root(), "vm"; "/bin/ls");
305 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Cmnd_Alias A=B","Cmnd_Alias B=/bin/ls","ALL ALL=A"], "user" => root(), "vm"; "/bin/ls");
306
307 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["Runas_Alias TIME=%wheel,!!sudo","user ALL=() ALL"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!!{ sudo, sudo }, "vm"; "/bin/ls");
308 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Runas_Alias TIME=%wheel,!!sudo","user ALL=(TIME) ALL"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, sudo }, "vm"; "/bin/ls");
309 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["Runas_Alias TIME=%wheel,!!sudo","user ALL=(:TIME) ALL"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { sudo, sudo }, "vm"; "/bin/ls");
310 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Runas_Alias TIME=%wheel,!!sudo","user ALL=(:TIME) ALL"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { user, sudo }, "vm"; "/bin/ls");
311 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Runas_Alias TIME=%wheel,!!sudo","user ALL=(TIME) ALL"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { wheel, wheel }, "vm"; "/bin/ls");
312
313 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["Runas_Alias \\"," TIME=%wheel \\",",sudo # hallo","user ALL \\","=(TIME) ALL"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { wheel, wheel }, "vm"; "/bin/ls");
314
315 // test the less-intuitive "substitution-like" alias mechanism
316 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["User_Alias FOO=!user", "ALL, FOO ALL=ALL"], "user" => root(), "vm"; "/bin/ls");
317 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["User_Alias FOO=!user", "!FOO ALL=ALL"], "user" => root(), "vm"; "/bin/ls");
318
319 // quoting
320 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["a\\,b ALL=ALL"], "a,b" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
321 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["\"a,b\" ALL=ALL"], "a,b" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
322 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["\"a\\b\" ALL=ALL"], "a\\b" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
323
324 // special chacters
325 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["[email protected] ALL=ALL"], "[email protected]" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
326 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["fnord$ ALL=ALL"], "fnord$" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/bin/foo");
327 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["ALL ALL=/foo/command --bar=1"], "user" => requestrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/request!! { root, root }, "server"; "/foo/command --bar=1");
328
329 // apparmor
330 #[cfg(feature = "apparmor")]
331 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["ALL ALL=(ALL:ALL) APPARMOR_PROFILE=unconfined ALL"], "user" => root(), "server"; "/bin/bar" => [apparmor_profilerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#apparmor_profile.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("unconfined".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())]);
332
333 // list
334 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["ALL ALL=(ALL:ALL) /bin/ls, list"], "user" => root(), "server"; "list");
335 FAILrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/FAIL!!(["ALL ALL=(ALL:ALL) ALL, !list"], "user" => root(), "server"; "list");
336
337 // line continuation
338 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello \\", "arg"], "user" => root(), "server"; "/bin/hello arg");
339 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello \\", "arg1 \\", "arg2"], "user" => root(), "server"; "/bin/hello arg1 arg2");
340 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(
341 ["user ALL=(root) NOPASSWD: /usr/bin/true \\", "arg1 \\", "arg2"],
342 "user" => root(), "server";
343 "/usr/bin/true arg1 arg2" => [authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Tag#authenticate.: Authenticaterust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#::Nopasswdrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Authenticate#Nopasswd#]
344 );
345 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(["user ALL=/bin/hello\\", "arg"], "user" => root(), "server"; "/bin/hello arg");
346 passrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/pass!!(
347 ["user ALL=/bin/hello \\", "\\", "arg"],
348 "user" => root(), "server";
349 "/bin/hello arg"
350 );
351 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["us\\\ner ALL=ALL"]);
352 SYNTAXrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/SYNTAX!!(["user ALL=/bin/hello\\"]);
353 }
354
355 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
356 fn default_bool_testrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/default_bool_test().() {
357 let (mut sudoers, _) = analyzerust-analyzer cargo sudo-rs 0.2.14 sudoers/analyze().(
358 Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/etc/fakesudoers"),
359 sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer!![
360 "Defaults env_editor",
361 "Defaults !use_pty",
362 "Defaults use_pty",
363 "Defaults !env_keep",
364 "Defaults !secure_path",
365 "Defaults !env_editor"
366 ],
367 );
368 sudoers.specify_host_user_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_host_user_runas().(
369 &systemrust-analyzer cargo sudo-rs 0.2.14 system/::Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("host"),
370 &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("user"),
371 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("root")),
372 );
373
374 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_editorrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_editor().());
375 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..use_ptyrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]use_pty().());
376 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
377 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
378 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_editorrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_editor().());
379 }
380
381 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
382 fn default_set_testrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/default_set_test().() {
383 let (mut sudoers, _) = analyzerust-analyzer cargo sudo-rs 0.2.14 sudoers/analyze().(
384 Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/etc/fakesudoers"),
385 sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer!![
386 "Defaults env_keep = \"FOO HUK BAR\"",
387 "Defaults env_keep -= HUK",
388 "Defaults !env_check",
389 "Defaults env_check += \"FOO\"",
390 "Defaults env_check += \"XYZZY\"",
391 "Defaults passwd_tries = 5",
392 "Defaults secure_path = /etc"
393 ],
394 );
395 sudoers.specify_host_user_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_host_user_runas().(
396 &systemrust-analyzer cargo sudo-rs 0.2.14 system/::Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("host"),
397 &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("user"),
398 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("root")),
399 );
400
401 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
402 sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().(),
403 &["FOO", "BAR"].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|x| x.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
404 );
405 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
406 sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_checkrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_check().(),
407 &["FOO", "XYZZY"]
408 .into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().()
409 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|x| x.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
410 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
411 );
412 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("/etc"));
413 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..passwd_triesrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]passwd_tries().(), 5);
414
415 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_stringrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_string().::<Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("Defaults verifypw = \"sometimes\"").is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
416 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_stringrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_string().::<Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("Defaults verifypw = sometimes").is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
417 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_stringrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_string().::<Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("Defaults verifypw = never").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
418
419 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_stringrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_string().::<Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("Defaults runcwd = *").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
420 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_stringrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_string().::<Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("Defaults runcwd = /usr/local").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
421 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_stringrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_string().::<Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("Defaults !runcwd").is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
422 }
423
424 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
425 fn default_multi_testrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/default_multi_test().() {
426 let (mut sudoers, _) = analyzerust-analyzer cargo sudo-rs 0.2.14 sudoers/analyze().(
427 Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/etc/fakesudoers"),
428 sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer!![
429 "Defaults !env_editor, use_pty, env_keep = \"FOO BAR\", env_keep -= BAR, secure_path=/etc"
430 ],
431 );
432 sudoers.specify_host_user_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_host_user_runas().(
433 &systemrust-analyzer cargo sudo-rs 0.2.14 system/::Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("host"),
434 &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("user"),
435 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("root")),
436 );
437
438 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_editorrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_editor().());
439 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..use_ptyrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]use_pty().());
440 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("/etc"));
441 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
442 sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().(),
443 &["FOO".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
444 );
445 }
446
447 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
448 #[should_panic]
449 fn invalid_directiverust-analyzer cargo sudo-rs 0.2.14 sudoers/test/invalid_directive().() {
450 parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("User_Alias, user Alias = user1, user2");
451 }
452
453 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
454 #[should_panic = "embedded $ in username"]
455 fn invalid_usernamerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/invalid_username().() {
456 parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("User_Alias FOO = $dollar");
457 }
458
459 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
460 #[should_panic = "wildcards are not allowed in command arguments"]
461 fn wildcard_in_argumentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/wildcard_in_argument().() {
462 parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("user ALL=/bin/hello w*");
463 }
464
465 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
466 fn inclusive_usernamerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/inclusive_username().() {
467 let UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#::Userrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#User#(Identifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Identifier#::Namerust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Identifier#Name#(sirin)) = parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#>("ÅŸirin")
468 else {
469 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!();
470 };
471
472 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sirin, "ÅŸirin");
473 }
474
475 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
476 fn sudoedit_recognizedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoedit_recognized().() {
477 let CommandSpecrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/CommandSpec#(_, Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#::Onlyrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#Only#((cmd, args)))) =
478 parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::CommandSpecrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/CommandSpec#>("sudoedit /etc/tmux.conf")
479 else {
480 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!();
481 };
482 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cmd.as_strrust-analyzer cargo glob 0.3.3 impl#[Pattern]as_str().(), "sudoedit");
483 let Argsrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Args#::Exactrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Args#Exact#(args) = args else { panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!() };
484 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T, A>`][`AsRef<T>`]as_ref().(), &["/etc/tmux.conf"][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().);
485 }
486
487 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
488 #[should_panic = "list does not take arguments"]
489 fn list_does_not_take_argsrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/list_does_not_take_args().() {
490 parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::CommandSpecrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/CommandSpec#>("list /etc/tmux.conf");
491 }
492
493 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
494 fn directive_testrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/directive_test().() {
495 let y = parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<Specrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Spec#<UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#>>;
496 match parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("User_Alias HENK = user1, user2") {
497 Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#::Declrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#Decl#(Directiverust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Directive#::UserAliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Directive#UserAlias#(defs)) => {
498 let [Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#(name, list)] = &defs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). else {
499 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("incorrectly parsed")
500 };
501 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(name, "HENK");
502 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().list, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![y("user1"), y("user2")]);
503 }
504 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("incorrectly parsed"),
505 }
506
507 match parse_evalrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/parse_eval().::<astrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/::Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#>("Runas_Alias FOO = foo : BAR = bar") {
508 Sudorust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#::Declrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Sudo#Decl#(Directiverust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Directive#::RunasAliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Directive#RunasAlias#(defs)) => {
509 let [Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#(name1, list1), Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#(name2, list2)] = &defs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). else {
510 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("incorrectly parsed")
511 };
512 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(name1, "FOO");
513 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().list1, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![y("foo")]);
514 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(name2, "BAR");
515 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().list2, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![y("bar")]);
516 }
517 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("incorrectly parsed"),
518 }
519 }
520
521 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
522 // the overloading of '#' causes a lot of issues
523 fn hashsign_testrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/hashsign_test().() {
524 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#42 ALL=ALL").is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().());
525 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("ALL ALL=(#42) ALL").is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().());
526 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("ALL ALL=(%#42) ALL").is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().());
527 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("ALL ALL=(:#42) ALL").is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().());
528 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("User_Alias FOO=#42, %#0, #3").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
529 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("").is_line_commentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_line_comment().());
530 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#this is a comment").is_line_commentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_line_comment().());
531 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#include foo").is_includerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include().());
532 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#includedir foo").is_include_dirrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include_dir().());
533 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("foo bar", parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#include \"foo bar\"").as_includerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]as_include().());
534 // this is fine
535 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#inlcudedir foo").is_line_commentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_line_comment().());
536 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("@include foo").is_includerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include().());
537 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("@includedir foo").is_include_dirrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include_dir().());
538 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("foo bar", parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("@include \"foo bar\"").as_includerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]as_include().());
539 }
540
541 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
542 fn gh674_at_include_quoted_backslashrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/gh674_at_include_quoted_backslash().() {
543 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().(r#"@include "/etc/sudo\ers" "#).is_includerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include().());
544 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().(r#"@includedir "/etc/sudo\ers.d" "#).is_include_dirrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_include_dir().());
545 }
546
547 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
548 fn gh676_percent_h_escape_unsupportedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/gh676_percent_h_escape_unsupported().() {
549 let (_, errs) = analyzerust-analyzer cargo sudo-rs 0.2.14 sudoers/analyze().(
550 Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/etc/fakesudoers"),
551 sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer!!(r#"@includedir "/etc/%h" "#),
552 );
553 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(errs.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1);
554 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
555 errs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..messagerust-analyzer cargo sudo-rs 0.2.14 sudoers/Error#message.,
556 "cannot open sudoers file /etc/%h: percent escape %h in includedir is unsupported"
557 );
558 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
559 errs[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..locationrust-analyzer cargo sudo-rs 0.2.14 sudoers/Error#location.,
560 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Spanrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/Span# {
561 startrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/Span#start.: (1, 2),
562 endrust-analyzer cargo sudo-rs 0.2.14 sudoers/basic_parser/Span#end.: (1, 23)
563 })
564 );
565 }
566
567 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
568 fn gh1295_escaped_equal_argument_okrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/gh1295_escaped_equal_argument_ok().() {
569 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Cmd_Alias FOO_CMD = /bin/foo --bar=1").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
570 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().(r"Cmd_Alias FOO_CMD = /bin/foo --bar\=1").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
571 }
572
573 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
574 fn gh1466_hostname_cannot_be_iprust-analyzer cargo sudo-rs 0.2.14 sudoers/test/gh1466_hostname_cannot_be_ip().() {
575 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 192.168.0.foo=ALL").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
576 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 1ba.168.0.0=ALL").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
577 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 192.168.0.1.5=ALL").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
578 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 192.1682.0.1=ALL").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
579 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 192.168.0.1=ALL").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
580 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 192.168.0=ALL").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
581 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 192.168=ALL").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
582 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ALL 192=ALL").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
583 }
584
585 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
586 fn hashsign_errorrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/hashsign_error().() {
587 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#include foo bar").is_line_commentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_line_comment().());
588 }
589
590 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
591 fn include_regressionrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/include_regression().() {
592 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("#4,#include foo").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
593 }
594
595 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
596 fn nullbyte_regressionrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/nullbyte_regression().() {
597 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("ferris ALL=(ALL:ferris\0) ALL").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
598 }
599
600 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
601 fn reserved_alias_names_are_rejected_for_alias_definitionsrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/reserved_alias_names_are_rejected_for_alias_definitions().() {
602 for line in [
603 "User_Alias ALL = sudouser",
604 "User_Alias CWD = sudouser",
605 "Host_Alias CHROOT = server",
606 "Cmnd_Alias TIMEOUT = /bin/ls",
607 "Runas_Alias NOTBEFORE = root",
608 "User_Alias NOTAFTER = sudouser",
609 ] {
610 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().(line).is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().(), "{line}");
611 }
612 }
613
614 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
615 fn defaults_regressionrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/defaults_regression().() {
616 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults .mymachine=ALL").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().())
617 }
618
619 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
620 fn user_id_regressionrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/user_id_regression().() {
621 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#499999999999 ALL=ALL").is_line_commentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_line_comment().());
622 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#49999999999 ALL=ALL").is_line_commentrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_line_comment().());
623 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults:#49999999999 use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
624 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults:#4999999999 use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
625 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("#1999999999 ALL=ALL").is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().());
626 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults:#1999999999 use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
627 }
628
629 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
630 fn specific_defaultsrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/specific_defaults().() {
631 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults !use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
632 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults!use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
633 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults!/bin/bash !use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
634 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults!/bin/bash!use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
635 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults !/bin/bash !use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
636 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults !/bin/bash").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
637 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults@host !use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
638 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults@host!use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
639 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults@host,!host2 !use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
640 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults@!host,host2!use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
641 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults @host!use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
642 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults @host !use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
643 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults:user !use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
644 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults:user!use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
645 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults :user!use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
646 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults :user !use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
647 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults>user !use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
648 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults>user!use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
649 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults >user!use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
650 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults >user !use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
651 }
652
653 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
654 fn defaults_hostname_shenanigansrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/defaults_hostname_shenanigans().() {
655 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults@ hostname use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
656 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(try_parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/try_parse_line().("Defaults@ # comment\n use_pty").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
657 /* ogsudo also rejects the following, probably due to hack in the parser
658 not too dissimilar from ours -- but sudo-rs has no problems with these */
659 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults@\\\nhost use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
660 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults:\\\nuser use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
661 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults>\\\nuser use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
662 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults!\\\nCMD use_pty").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
663 }
664
665 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
666 fn at_sign_ambiguityrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/at_sign_ambiguity().() {
667 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("Defaults@host env_keep=ALL").is_declrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_decl().());
668 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("defaults@host env_keep=ALL").is_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]is_spec().());
669 }
670
671 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
672 fn default_specific_testrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/default_specific_test().() {
673 let sudoers = || {
674 analyzerust-analyzer cargo sudo-rs 0.2.14 sudoers/analyze().(
675 Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/etc/fakesudoers"),
676 sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer!![
677 "Defaults!RR use_pty",
678 "Defaults env_editor",
679 "Defaults@host !env_editor",
680 "Defaults !use_pty",
681 "Defaults:user use_pty",
682 "Defaults !secure_path",
683 "Defaults>runas secure_path=\"/bin\"",
684 "Defaults!/bin/foo !env_keep",
685 "Cmnd_Alias RR=/usr/bin/rr twice"
686 ],
687 )
688 };
689
690 let (mut base_sudoers, _) = sudoers();
691 base_sudoers.specify_host_user_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_host_user_runas().(
692 &systemrust-analyzer cargo sudo-rs 0.2.14 system/::Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("generic"),
693 &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("generic"),
694 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("generic")),
695 );
696
697 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(base_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_editorrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_editor().());
698 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().base_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..use_ptyrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]use_pty().());
699 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(base_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().().containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("COLORS"));
700 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(base_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
701
702 let (mut mod_sudoers, _) = sudoers();
703 mod_sudoers.specify_host_user_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_host_user_runas().(
704 &systemrust-analyzer cargo sudo-rs 0.2.14 system/::Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("host"),
705 &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("user"),
706 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("root")),
707 );
708 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_editorrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_editor().());
709 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..use_ptyrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]use_pty().());
710 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().().containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("COLORS"));
711 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
712
713 let (mut mod_sudoers, _) = sudoers();
714 mod_sudoers.specify_host_user_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_host_user_runas().(
715 &systemrust-analyzer cargo sudo-rs 0.2.14 system/::Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("machine"),
716 &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("admin"),
717 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("runas")),
718 );
719 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_editorrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_editor().());
720 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..use_ptyrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]use_pty().());
721 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().().containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("COLORS"));
722 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("/bin"));
723 mod_sudoers.specify_commandrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_command().(Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/bin/foo"), &["".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "a".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
724 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
725
726 let (mut mod_sudoers, _) = sudoers();
727 mod_sudoers.specify_host_user_runasrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_host_user_runas().(
728 &systemrust-analyzer cargo sudo-rs 0.2.14 system/::Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("machine"),
729 &Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("admin"),
730 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&Namedrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Named#("self")),
731 );
732 mod_sudoers.specify_commandrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_command().(Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/usr/bin/rr"), &["thrice".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
733 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_editorrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_editor().());
734 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..use_ptyrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]use_pty().());
735 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().().containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().("COLORS"));
736 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
737
738 let (mut mod_sudoers, _) = sudoers();
739 mod_sudoers.specify_commandrust-analyzer cargo sudo-rs 0.2.14 sudoers/impl#[Sudoers]specify_command().(Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/usr/bin/rr"), &["twice".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()]);
740 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(mod_sudoers.settingsrust-analyzer cargo sudo-rs 0.2.14 sudoers/Sudoers#settings..use_ptyrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]use_pty().());
741 }
742
743 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
744 fn useralias_underscore_regressionrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/useralias_underscore_regression().() {
745 let sudo = parse_linerust-analyzer cargo sudo-rs 0.2.14 sudoers/test/parse_line().("FOO_BAR ALL=ALL");
746 let spec = sudo.as_specrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[Sudo]as_spec().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("`Sudo::Spec`");
747 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
748 spec.usersrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/PermissionSpec#users.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().
749 .as_allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[`Qualified<T>`]as_allow().()
750 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("`Qualified::Allow`")
751 .is_aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/impl#[`Meta<T>`]is_alias().()
752 );
753 }
754
755 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
756 fn regression_check_recursionrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/regression_check_recursion().() {
757 let (_, error) = analyzerust-analyzer cargo sudo-rs 0.2.14 sudoers/analyze().(
758 Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("/etc/fakesudoers"),
759 sudoerrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/sudoer!!["User_Alias A=user, B", "User_Alias B=A"],
760 );
761
762 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().error.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
763 }
764
765 fn test_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_sort().(n: usize) {
766 let alias = |s: &str| Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#::<UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#>::Aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#Alias#(s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()));
767 let stop = || Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#::<UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#>::Allrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#All#);
768 type Elemrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Elem# = Specrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Spec#<UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#>;
769 let test_case = |x1: Elemrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Elem#, x2: Elemrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Elem#, x3: Elemrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/Elem#| {
770 let table = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
771 Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#("AAP".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![x1]),
772 Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#("NOOT".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![x2]),
773 Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#("MIES".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![x3]),
774 ];
775 let mut err = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
776 let order = sanitize_alias_tablerust-analyzer cargo sudo-rs 0.2.14 sudoers/sanitize_alias_table().(&table, &mut err);
777 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().());
778 let mut seen = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().();
779 for Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#(id, defns) in order.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|&i| &table[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().) {
780 if defns.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|spec| {
781 let Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#::Aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#Alias#(id2)) = spec else {
782 return false;
783 };
784 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().seen.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(id2)
785 }) {
786 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("forward reference encountered after sorting");
787 }
788 seen.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(id);
789 }
790 };
791 match n {
792 0 => test_case(alias("AAP"), alias("NOOT"), stop()),
793 1 => test_case(alias("AAP"), stop(), alias("NOOT")),
794 2 => test_case(alias("NOOT"), alias("AAP"), stop()),
795 3 => test_case(alias("NOOT"), stop(), alias("AAP")),
796 4 => test_case(stop(), alias("AAP"), alias("NOOT")),
797 5 => test_case(stop(), alias("NOOT"), alias("AAP")),
798 _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("error in test case"),
799 }
800 }
801
802 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
803 fn test_topo_positiverust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_positive().() {
804 test_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_sort().(3);
805 test_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_sort().(4);
806 }
807
808 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
809 #[should_panic]
810 fn test_topo_fail0rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_fail0().() {
811 test_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_sort().(0);
812 }
813 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
814 #[should_panic]
815 fn test_topo_fail1rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_fail1().() {
816 test_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_sort().(1);
817 }
818 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
819 #[should_panic]
820 fn test_topo_fail2rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_fail2().() {
821 test_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_sort().(2);
822 }
823 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
824 #[should_panic]
825 fn test_topo_fail5rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_fail5().() {
826 test_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/test_topo_sort().(5);
827 }
828
829 fn fuzz_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/fuzz_topo_sort().(siz: usize) {
830 for mut n in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#siz).reducerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#reduce().(|x, y| x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().y).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() {
831 let name = |s: u8| stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&[65 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().s]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
832 let alias = |s: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#| Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#::<UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#>::Aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#Alias#(s));
833 let stop = || Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#::<UserSpecifierrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/UserSpecifier#>::Allrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#All#);
834
835 let mut data = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#siz rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1)
836 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| alias(name(i as u8)))
837 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
838 data.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(stop());
839
840 for i in (1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#siz).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() {
841 data.swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]swap().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1, n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().i);
842 n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`DivAssign<Self>`]div_assign()./=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`DivAssign<Self>`]div_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`DivAssign<Self>`]div_assign().i;
843 }
844
845 let table = data
846 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
847 .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().()
848 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(i, x)| Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#(name(i as u8), vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![x]))
849 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
850
851 let mut err = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
852 let order = sanitize_alias_tablerust-analyzer cargo sudo-rs 0.2.14 sudoers/sanitize_alias_table().(&table, &mut err);
853 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().err.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
854 return;
855 }
856
857 let mut seen = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().();
858 for Defrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Def#(id, defns) in order.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|&i| &table[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().) {
859 if defns.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|spec| {
860 let Qualifiedrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#::Allowrust-analyzer cargo sudo-rs 0.2.14 sudoers/ast/Qualified#Allow#(Metarust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#::Aliasrust-analyzer cargo sudo-rs 0.2.14 sudoers/tokens/Meta#Alias#(id2)) = spec else {
861 return false;
862 };
863 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().seen.containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(id2)
864 }) {
865 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("forward reference encountered after sorting");
866 }
867 seen.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(id);
868 }
869 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(seen.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().() == siz);
870 }
871 }
872
873 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
874 fn fuzz_topo_sort7rust-analyzer cargo sudo-rs 0.2.14 sudoers/test/fuzz_topo_sort7().() {
875 fuzz_topo_sortrust-analyzer cargo sudo-rs 0.2.14 sudoers/test/fuzz_topo_sort().(7)
876 }