@@ -53,8 +53,8 @@ struct Options {
53
53
///
54
54
/// The `spec` must be of the form `[USER][:[GROUP]]`, otherwise an
55
55
/// error is returned.
56
- fn parse_userspec ( spec : & str ) -> UResult < UserSpec > {
57
- Ok ( match spec. split_once ( ':' ) {
56
+ fn parse_userspec ( spec : & str ) -> UserSpec {
57
+ match spec. split_once ( ':' ) {
58
58
// ""
59
59
None if spec. is_empty ( ) => UserSpec :: NeitherGroupNorUser ,
60
60
// "usr"
@@ -67,10 +67,7 @@ fn parse_userspec(spec: &str) -> UResult<UserSpec> {
67
67
Some ( ( usr, "" ) ) => UserSpec :: UserOnly ( usr. to_string ( ) ) ,
68
68
// "usr:grp"
69
69
Some ( ( usr, grp) ) => UserSpec :: UserAndGroup ( usr. to_string ( ) , grp. to_string ( ) ) ,
70
- // BUG: this would never be reached. Should we check for another ':', or some invalid characters?
71
- // everything else
72
- // _ => Err(ChrootError::InvalidUserspec(spec.to_string()).into()),
73
- } )
70
+ }
74
71
}
75
72
76
73
// Pre-condition: `list_str` is non-empty.
@@ -145,10 +142,9 @@ impl Options {
145
142
}
146
143
} ;
147
144
let skip_chdir = matches. get_flag ( options:: SKIP_CHDIR ) ;
148
- let userspec = match matches. get_one :: < String > ( options:: USERSPEC ) {
149
- None => None ,
150
- Some ( s) => Some ( parse_userspec ( s) ?) ,
151
- } ;
145
+ let userspec = matches
146
+ . get_one :: < String > ( options:: USERSPEC )
147
+ . map ( |s| parse_userspec ( s) ) ;
152
148
Ok ( Self {
153
149
newroot,
154
150
skip_chdir,
0 commit comments