File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -405,7 +405,14 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
405405 } else {
406406 match usr2uid ( & owner) {
407407 Ok ( u) => Some ( u) ,
408- Err ( _) => return Err ( InstallError :: InvalidUser ( owner. clone ( ) ) . into ( ) ) ,
408+ // When using -o500 option and there's no user with uid 500 on the system
409+ // usr2uid returns an Err value and the whole install operation fails.
410+ // GNU coreutils installs a file with uid 500 in the same situation
411+ // so just return the supplied owner as uid if it's an integer value
412+ Err ( _) => match owner. parse :: < u32 > ( ) {
413+ Ok ( u) => Some ( u) ,
414+ Err ( _) => return Err ( InstallError :: InvalidUser ( owner. clone ( ) ) . into ( ) ) ,
415+ } ,
409416 }
410417 } ;
411418
@@ -419,7 +426,14 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
419426 } else {
420427 match grp2gid ( & group) {
421428 Ok ( g) => Some ( g) ,
422- Err ( _) => return Err ( InstallError :: InvalidGroup ( group. clone ( ) ) . into ( ) ) ,
429+ // When using -g500 option and there's no group with gid 500 on the system
430+ // grp2gid returns an Err value and the whole install operation fails.
431+ // GNU coreutils installs a file with gid 500 in the same situation
432+ // so just return the supplied group as gid if it's an integer value
433+ Err ( _) => match group. parse :: < u32 > ( ) {
434+ Ok ( g) => Some ( g) ,
435+ Err ( _) => return Err ( InstallError :: InvalidGroup ( group. clone ( ) ) . into ( ) ) ,
436+ } ,
423437 }
424438 } ;
425439
You can’t perform that action at this time.
0 commit comments