@@ -45,21 +45,21 @@ impl NetworkdBackend {
4545 . output ( )
4646 . await ;
4747
48- if let Ok ( pkexec_out) = pkexec_out {
49- if pkexec_out. status . success ( ) {
50- return Ok ( CommandResult {
51- program : "networkctl" . to_string ( ) ,
52- args : vec ! [ "renew ". to_string( ) , iface . to_string ( ) ] ,
53- used_sudo : true ,
54- status : pkexec_out . status . code ( ) . unwrap_or ( 0 ) ,
55- stdout : String :: from_utf8_lossy ( & pkexec_out. stdout )
56- . trim ( )
57- . to_string ( ) ,
58- stderr : String :: from_utf8_lossy ( & pkexec_out . stderr )
59- . trim ( )
60- . to_string ( ) ,
61- } ) ;
62- }
48+ if let Ok ( pkexec_out) = pkexec_out
49+ && pkexec_out. status . success ( )
50+ {
51+ return Ok ( CommandResult {
52+ program : "networkctl ". to_string ( ) ,
53+ args : vec ! [ "renew" . to_string ( ) , iface . to_string ( ) ] ,
54+ used_sudo : true ,
55+ status : pkexec_out. status . code ( ) . unwrap_or ( 0 ) ,
56+ stdout : String :: from_utf8_lossy ( & pkexec_out . stdout )
57+ . trim ( )
58+ . to_string ( ) ,
59+ stderr : String :: from_utf8_lossy ( & pkexec_out . stderr )
60+ . trim ( )
61+ . to_string ( ) ,
62+ } ) ;
6363 }
6464
6565 let sudo_out = Command :: new ( "sudo" )
@@ -142,27 +142,27 @@ impl NetworkdBackend {
142142 . output ( )
143143 . await ;
144144
145- if let Ok ( pkexec_out) = pkexec_out {
146- if pkexec_out. status . success ( ) {
147- return Ok ( CommandResult {
148- program : "ip" . to_string ( ) ,
149- args : vec ! [
150- "link" . to_string ( ) ,
151- "set ". to_string( ) ,
152- "dev ". to_string( ) ,
153- iface . to_string( ) ,
154- state_arg . to_string( ) ,
155- ] ,
156- used_sudo : true ,
157- status : pkexec_out . status . code ( ) . unwrap_or ( 0 ) ,
158- stdout : String :: from_utf8_lossy ( & pkexec_out. stdout )
159- . trim ( )
160- . to_string ( ) ,
161- stderr : String :: from_utf8_lossy ( & pkexec_out . stderr )
162- . trim ( )
163- . to_string ( ) ,
164- } ) ;
165- }
145+ if let Ok ( pkexec_out) = pkexec_out
146+ && pkexec_out. status . success ( )
147+ {
148+ return Ok ( CommandResult {
149+ program : "ip" . to_string ( ) ,
150+ args : vec ! [
151+ "link ". to_string( ) ,
152+ "set ". to_string( ) ,
153+ "dev" . to_string( ) ,
154+ iface . to_string( ) ,
155+ state_arg . to_string ( ) ,
156+ ] ,
157+ used_sudo : true ,
158+ status : pkexec_out. status . code ( ) . unwrap_or ( 0 ) ,
159+ stdout : String :: from_utf8_lossy ( & pkexec_out . stdout )
160+ . trim ( )
161+ . to_string ( ) ,
162+ stderr : String :: from_utf8_lossy ( & pkexec_out . stderr )
163+ . trim ( )
164+ . to_string ( ) ,
165+ } ) ;
166166 }
167167
168168 let sudo_out = Command :: new ( "sudo" )
@@ -226,6 +226,12 @@ impl NetworkdBackend {
226226 }
227227}
228228
229+ impl Default for NetworkdBackend {
230+ fn default ( ) -> Self {
231+ Self :: new ( )
232+ }
233+ }
234+
229235impl EthernetBackend for NetworkdBackend {
230236 fn list_ifaces ( & self ) -> Result < Vec < EthernetIface > > {
231237 list_ethernet_ifaces ( )
0 commit comments