File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -212,8 +212,17 @@ fn group_cmd_specs_per_runas<'a>(
212212 let mut last_runas = None ;
213213 let mut collected_specs = vec ! [ ] ;
214214
215+ // `distribute_tags` will have given every spec a reference to the "runas specification"
216+ // that applies to it. The output of sudo --list splits the CmndSpec list based on that:
217+ // every line only has a single "runas" specifier. So we need to combine them for that.
218+ //
219+ // But sudo --list also outputs lines that are from different lines in the sudoers file on
220+ // different lines in the output of sudo --list, so we cannot compare "by value". Luckily,
221+ // once a RunAs is parsed, it will have a unique identifier in the form of its address.
222+ let origin = |runas : Option < & RunAs > | runas. map ( |r| r as * const _ ) ;
223+
215224 for ( runas, ( tag, spec) ) in cmnd_specs {
216- if runas . map ( |r| r as * const _ ) != last_runas . map ( |r| r as * const _ ) {
225+ if origin ( runas ) != origin ( last_runas ) {
217226 if !collected_specs. is_empty ( ) {
218227 entries. push ( Entry :: new (
219228 last_runas,
You can’t perform that action at this time.
0 commit comments