@@ -50,17 +50,17 @@ impl ElevationStrategy {
5050 pub fn resolve ( & self ) -> Result < OsString > {
5151 match self {
5252 ElevationStrategy :: Auto => Self :: choice ( ) ,
53- ElevationStrategy :: Prefer ( program) => {
54- which ( program) . map ( |x| x. into_os_string ( ) ) . or_else ( |_| {
53+ ElevationStrategy :: Prefer ( program) => which ( program)
54+ . map ( std:: path:: PathBuf :: into_os_string)
55+ . or_else ( |_| {
5556 let auto = Self :: choice ( ) ?;
5657 warn ! (
5758 "{} not found. Using {} instead" ,
5859 program. to_string_lossy( ) ,
5960 auto. to_string_lossy( )
6061 ) ;
6162 Ok ( auto)
62- } )
63- }
63+ } ) ,
6464 ElevationStrategy :: Force ( program) => Ok ( program. into ( ) ) ,
6565 }
6666 }
@@ -81,7 +81,7 @@ impl ElevationStrategy {
8181 ///
8282 /// The logic for choosing this order is that a person with `doas` installed is more likely
8383 /// to be using it as their main privilege elevation program.
84- /// `run0` and `pkexec` are preinstalled in any NixOS system with polkit support installed,
84+ /// `run0` and `pkexec` are preinstalled in any ` NixOS` system with polkit support installed,
8585 /// so they have been placed lower as it's easier to deactivate sudo than it is to remove
8686 /// `run0`/`pkexec`
8787 ///
@@ -304,14 +304,18 @@ impl Command {
304304
305305 // Insert 'env' command to explicitly pass environment variables to the elevated command
306306 cmd = cmd. arg ( "env" ) ;
307- for arg in self . env_vars . iter ( ) . flat_map ( |( key, action) | match action {
308- EnvAction :: Set ( value) => Some ( format ! ( "{key}={value}" ) ) ,
309- EnvAction :: Preserve => match std:: env:: var ( key) {
310- Ok ( value) => Some ( format ! ( "{key}={value}" ) ) ,
311- Err ( _) => None ,
312- } ,
313- EnvAction :: Remove => None ,
314- } ) {
307+ for arg in self
308+ . env_vars
309+ . iter ( )
310+ . filter_map ( |( key, action) | match action {
311+ EnvAction :: Set ( value) => Some ( format ! ( "{key}={value}" ) ) ,
312+ EnvAction :: Preserve => match std:: env:: var ( key) {
313+ Ok ( value) => Some ( format ! ( "{key}={value}" ) ) ,
314+ Err ( _) => None ,
315+ } ,
316+ EnvAction :: Remove => None ,
317+ } )
318+ {
315319 cmd = cmd. arg ( arg) ;
316320 }
317321
0 commit comments