Debian Codegraph @

src/sudo/env/tests.rs

raw symbols SCIP
1 use 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/::CurrentUserrust-analyzer cargo sudo-rs 0.2.14 common/resolve/CurrentUser#;
2 use craterust-analyzer cargo sudo-rs 0.2.14 crate/::commonrust-analyzer cargo sudo-rs 0.2.14 common/::{CommandAndArgumentsrust-analyzer cargo sudo-rs 0.2.14 common/command/CommandAndArguments#, Contextrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#};
3 use craterust-analyzer cargo sudo-rs 0.2.14 crate/::sudorust-analyzer cargo sudo-rs 0.2.14 sudo/::{
4 clirust-analyzer cargo sudo-rs 0.2.14 sudo/cli/::{SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#, SudoRunOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#},
5 envrust-analyzer cargo sudo-rs 0.2.14 sudo/env/::environmentrust-analyzer cargo sudo-rs 0.2.14 sudo/env/environment/::{Environmentrust-analyzer cargo sudo-rs 0.2.14 sudo/env/environment/Environment#, get_target_environmentrust-analyzer cargo sudo-rs 0.2.14 sudo/env/environment/get_target_environment().},
6 };
7 use craterust-analyzer cargo sudo-rs 0.2.14 crate/::systemrust-analyzer cargo sudo-rs 0.2.14 system/::interfacerust-analyzer cargo sudo-rs 0.2.14 system/interface/::{GroupIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/GroupId#, UserIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/UserId#};
8 use craterust-analyzer cargo sudo-rs 0.2.14 crate/::systemrust-analyzer cargo sudo-rs 0.2.14 system/::{Grouprust-analyzer cargo sudo-rs 0.2.14 system/Group#, Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#, Userrust-analyzer cargo sudo-rs 0.2.14 system/User#};
9 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#, HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#};
10
11 const TESTSrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/TESTS.: &str = "
12 > env
13 FOO=BAR
14 HOME=/home/test
15 HOSTNAME=test-ubuntu
16 LANG=en_US.UTF-8
17 LANGUAGE=en_US.UTF-8
18 LC_ALL=en_US.UTF-8
19 LS_COLORS=cd=40;33;01:*.jpg=01;35:*.mp3=00;36:
20 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
21 PWD=/home/test
22 SHLVL=0
23 TERM=xterm
24 _=/usr/bin/sudo
25 > sudo env
26 HOSTNAME=test-ubuntu
27 LANG=en_US.UTF-8
28 LANGUAGE=en_US.UTF-8
29 LC_ALL=en_US.UTF-8
30 LS_COLORS=cd=40;33;01:*.jpg=01;35:*.mp3=00;36:
31 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
32 SHELL=/bin/bash
33 SUDO_COMMAND=/usr/bin/env
34 SUDO_GID=1000
35 SUDO_UID=1000
36 SUDO_USER=test
37 SUDO_HOME=/home/test
38 HOME=/root
39 LOGNAME=root
40 USER=root
41 TERM=xterm
42 > sudo -u test env
43 HOSTNAME=test-ubuntu
44 LANG=en_US.UTF-8
45 LANGUAGE=en_US.UTF-8
46 LC_ALL=en_US.UTF-8
47 LS_COLORS=cd=40;33;01:*.jpg=01;35:*.mp3=00;36:
48 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
49 SHELL=/bin/sh
50 SUDO_COMMAND=/usr/bin/env
51 SUDO_GID=1000
52 SUDO_UID=1000
53 SUDO_USER=test
54 SUDO_HOME=/home/test
55 HOME=/home/test
56 LOGNAME=test
57 USER=test
58 TERM=xterm
59 ";
60
61 fn parse_env_commandsrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/parse_env_commands().(input: &str) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&str, Environmentrust-analyzer cargo sudo-rs 0.2.14 sudo/env/environment/Environment#)> {
62 input
63 .trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().()
64 .splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().("> ")
65 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|l| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().l.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().())
66 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|e| {
67 let (cmd, vars) = e.split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('\n').unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
68
69 let vars = vars
70 .linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().()
71 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|line| line.trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().().split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('=').unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().())
72 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (k.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), v.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
73 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
74
75 (cmd, vars)
76 })
77 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
78 }
79
80 fn create_test_contextrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/create_test_context().(sudo_options: SudoRunOptionsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#) -> Contextrust-analyzer cargo sudo-rs 0.2.14 common/context/Context# {
81 let path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
82 let command = CommandAndArgumentsrust-analyzer cargo sudo-rs 0.2.14 common/command/CommandAndArguments#::build_from_argsrust-analyzer cargo sudo-rs 0.2.14 common/command/impl#[CommandAndArguments]build_from_args().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, sudo_options.positional_argsrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#positional_args., &path);
83
84 let current_user = CurrentUserrust-analyzer cargo sudo-rs 0.2.14 common/resolve/CurrentUser#::fakerust-analyzer cargo sudo-rs 0.2.14 common/resolve/impl#[CurrentUser]fake().(Userrust-analyzer cargo sudo-rs 0.2.14 system/User# {
85 uidrust-analyzer cargo sudo-rs 0.2.14 system/User#uid.: UserIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/UserId#::newrust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[UserId]new().(1000),
86 gidrust-analyzer cargo sudo-rs 0.2.14 system/User#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().(1000),
87
88 namerust-analyzer cargo sudo-rs 0.2.14 system/User#name.: "test".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
89 homerust-analyzer cargo sudo-rs 0.2.14 system/User#home.: "/home/test".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
90 shellrust-analyzer cargo sudo-rs 0.2.14 system/User#shell.: "/bin/sh".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
91 groupsrust-analyzer cargo sudo-rs 0.2.14 system/User#groups.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
92 });
93
94 let current_group = Grouprust-analyzer cargo sudo-rs 0.2.14 system/Group# {
95 gidrust-analyzer cargo sudo-rs 0.2.14 system/Group#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().(1000),
96 namerust-analyzer cargo sudo-rs 0.2.14 system/Group#name.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
97 };
98
99 let root_user = Userrust-analyzer cargo sudo-rs 0.2.14 system/User# {
100 uidrust-analyzer cargo sudo-rs 0.2.14 system/User#uid.: UserIdrust-analyzer cargo sudo-rs 0.2.14 system/interface/UserId#::ROOTrust-analyzer cargo sudo-rs 0.2.14 system/interface/impl#[UserId]ROOT.,
101 gidrust-analyzer cargo sudo-rs 0.2.14 system/User#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().(0),
102 namerust-analyzer cargo sudo-rs 0.2.14 system/User#name.: "root".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
103 homerust-analyzer cargo sudo-rs 0.2.14 system/User#home.: "/root".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
104 shellrust-analyzer cargo sudo-rs 0.2.14 system/User#shell.: "/bin/bash".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
105 groupsrust-analyzer cargo sudo-rs 0.2.14 system/User#groups.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
106 };
107
108 let root_group = Grouprust-analyzer cargo sudo-rs 0.2.14 system/Group# {
109 gidrust-analyzer cargo sudo-rs 0.2.14 system/Group#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().(0),
110 namerust-analyzer cargo sudo-rs 0.2.14 system/Group#name.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()),
111 };
112
113 Contextrust-analyzer cargo sudo-rs 0.2.14 common/context/Context# {
114 hostnamerust-analyzer cargo sudo-rs 0.2.14 common/context/Context#hostname.: Hostnamerust-analyzer cargo sudo-rs 0.2.14 system/Hostname#::fakerust-analyzer cargo sudo-rs 0.2.14 system/impl#[Hostname]fake().("test-ubuntu"),
115 commandrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#command.,
116 current_userrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#current_user.: current_user.clonerust-analyzer cargo sudo-rs 0.2.14 common/resolve/impl#[CurrentUser][Clone]clone().(),
117 target_userrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#target_user.: if sudo_options.userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#user..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test") {
118 current_user.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
119 } else {
120 root_user
121 },
122 target_grouprust-analyzer cargo sudo-rs 0.2.14 common/context/Context#target_group.: if sudo_options.userrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#user..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test") {
123 current_group
124 } else {
125 root_group
126 },
127 launchrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#launch.: craterust-analyzer cargo sudo-rs 0.2.14 crate/::commonrust-analyzer cargo sudo-rs 0.2.14 common/::contextrust-analyzer cargo sudo-rs 0.2.14 common/context/::LaunchTyperust-analyzer cargo sudo-rs 0.2.14 common/context/LaunchType#::Directrust-analyzer cargo sudo-rs 0.2.14 common/context/LaunchType#Direct#,
128 chdirrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#chdir.: sudo_options.chdirrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#chdir.,
129 askpassrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#askpass.: sudo_options.askpassrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#askpass.,
130 stdinrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#stdin.: sudo_options.stdinrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#stdin.,
131 promptrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#prompt.: sudo_options.promptrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#prompt.,
132 non_interactiverust-analyzer cargo sudo-rs 0.2.14 common/context/Context#non_interactive.: sudo_options.non_interactiverust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoRunOptions#non_interactive.,
133 use_session_recordsrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#use_session_records.: false,
134 bellrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#bell.: false,
135 backgroundrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#background.: false,
136 files_to_editrust-analyzer cargo sudo-rs 0.2.14 common/context/Context#files_to_edit.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
137 }
138 }
139
140 fn environment_to_setrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/environment_to_set().(environment: Environmentrust-analyzer cargo sudo-rs 0.2.14 sudo/env/environment/Environment#) -> HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
141 HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S>`][`FromIterator<T>`]from_iter().(
142 environment
143 .into_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][IntoIterator]into_iter().()
144 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}={}", k.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), v.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().())),
145 )
146 }
147
148 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
149 fn test_environment_variable_filteringrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/test_environment_variable_filtering().() {
150 let mut parts = parse_env_commandsrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/parse_env_commands().(TESTSrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/TESTS.);
151 let initial_env = parts.removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]remove().(0).1;
152
153 for (cmd, expected_env) in parts {
154 let options = SudoActionrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/SudoAction#::try_parse_fromrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/impl#[SudoAction]try_parse_from().(cmd.split_whitespacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_whitespace().())
155 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
156 .try_into_runrust-analyzer cargo sudo-rs 0.2.14 sudo/cli/tests/impl#[SudoAction]try_into_run().()
157 .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
158 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
159 let settings = craterust-analyzer cargo sudo-rs 0.2.14 crate/::defaultsrust-analyzer cargo sudo-rs 0.2.14 defaults/::Settingsrust-analyzer cargo sudo-rs 0.2.14 defaults/Settings#::defaultrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings][Default]default().();
160 let context = create_test_contextrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/create_test_context().(options);
161 let resulting_env = get_target_environmentrust-analyzer cargo sudo-rs 0.2.14 sudo/env/environment/get_target_environment().(
162 initial_env.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`][Clone]clone().(),
163 HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(),
164 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
165 &context,
166 &craterust-analyzer cargo sudo-rs 0.2.14 crate/::sudoersrust-analyzer cargo sudo-rs 0.2.14 sudoers/::Restrictionsrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions# {
167 env_keeprust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#env_keep.: settings.env_keeprust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_keep().(),
168 env_checkrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#env_check.: settings.env_checkrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]env_check().(),
169 pathrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#path.: settings.secure_pathrust-analyzer cargo sudo-rs 0.2.14 defaults/impl#[Settings]secure_path().(),
170 use_ptyrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#use_pty.: true,
171 chdirrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#chdir.: craterust-analyzer cargo sudo-rs 0.2.14 crate/::sudoersrust-analyzer cargo sudo-rs 0.2.14 sudoers/::DirChangerust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/DirChange#::Strictrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/DirChange#Strict#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
172 trust_environmentrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#trust_environment.: false,
173 umaskrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#umask.: craterust-analyzer cargo sudo-rs 0.2.14 crate/::execrust-analyzer cargo sudo-rs 0.2.14 exec/::Umaskrust-analyzer cargo sudo-rs 0.2.14 exec/Umask#::Preserverust-analyzer cargo sudo-rs 0.2.14 exec/Umask#Preserve#,
174 #[cfg(feature = "apparmor")]
175 apparmor_profilerust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#apparmor_profile.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
176 noexecrust-analyzer cargo sudo-rs 0.2.14 sudoers/policy/Restrictions#noexec.: false,
177 },
178 )
179 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
180
181 let resulting_env = environment_to_setrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/environment_to_set().(resulting_env);
182 let expected_env = environment_to_setrust-analyzer cargo sudo-rs 0.2.14 sudo/env/tests/environment_to_set().(expected_env);
183 let mut diff = resulting_env
184 .symmetric_differencerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]symmetric_difference().(&expected_env)
185 .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#<_>>();
186
187 diff.sortrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort().();
188
189 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
190 diff.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().(),
191 "\"{cmd}\" results in an environment mismatch:\n{diff:#?}",
192 );
193 }
194 }