File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed
Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -255,26 +255,21 @@ fn edit_sudoers_file(
255255
256256 let host_name = Hostname :: resolve ( ) ;
257257
258- let Some ( editor_path ) = ( if existed {
258+ if existed {
259259 // If the sudoers file existed, read its contents and write them into the temporary file.
260260 sudoers_file. read_to_end ( & mut sudoers_contents) ?;
261261 // Rewind the sudoers file so it can be written later.
262262 sudoers_file. rewind ( ) ?;
263263 // Write to the temporary file.
264264 tmp_file. write_all ( & sudoers_contents) ?;
265+ }
265266
266- let ( sudoers, _errors) = Sudoers :: read ( sudoers_contents. as_slice ( ) , sudoers_path) ?;
267-
268- sudoers
269- } else {
270- Default :: default ( )
271- } )
272- . visudo_editor_path ( & host_name, & current_user, & current_user) else {
273- return Err ( io:: Error :: new (
274- io:: ErrorKind :: NotFound ,
275- "no usable editor could be found" ,
276- ) ) ;
277- } ;
267+ let editor_path = Sudoers :: read ( sudoers_contents. as_slice ( ) , sudoers_path) ?
268+ . 0
269+ . visudo_editor_path ( & host_name, & current_user, & current_user)
270+ . ok_or_else ( || {
271+ io:: Error :: new ( io:: ErrorKind :: NotFound , "no usable editor could be found" )
272+ } ) ?;
278273
279274 loop {
280275 Command :: new ( & editor_path)
You can’t perform that action at this time.
0 commit comments