File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -731,22 +731,18 @@ fn test_file_owned_by_egid() {
731731 // /tmp directory will have a different gid than the current egid (due to
732732 // the sticky bit set on the /tmp directory). Fix this before running the
733733 // test command.
734- use std:: ffi:: CString ;
735- use std:: os:: unix:: ffi:: OsStrExt ;
736734 use std:: os:: unix:: fs:: MetadataExt ;
737- use uucore:: process:: getegid;
738735 let scene = TestScenario :: new ( util_name ! ( ) ) ;
739736 let at = & scene. fixtures ;
740737
741738 let metadata = at. metadata ( "regular_file" ) ;
742- let file_gid = metadata. gid ( ) ;
743- let user_gid = getegid ( ) ;
739+ let file_gid = rustix :: fs :: Gid :: from_raw ( metadata. gid ( ) ) ;
740+ let user_gid = rustix :: process :: getegid ( ) ;
744741
745742 if user_gid != file_gid {
746- let file_metadata_uid = metadata. uid ( ) ;
747- let path = CString :: new ( at. plus ( "regular_file" ) . as_os_str ( ) . as_bytes ( ) ) . expect ( "bad path" ) ;
748- let r = unsafe { libc:: chown ( path. as_ptr ( ) , file_metadata_uid, user_gid) } ;
749- assert_ne ! ( r, -1 ) ;
743+ let file_uid = rustix:: fs:: Uid :: from_raw ( metadata. uid ( ) ) ;
744+ let path = at. plus ( "regular_file" ) ;
745+ rustix:: fs:: chown ( & path, Some ( file_uid) , Some ( user_gid) ) . expect ( "chown failed" ) ;
750746 }
751747
752748 scene. ucmd ( ) . args ( & [ "-G" , "regular_file" ] ) . succeeds ( ) ;
You can’t perform that action at this time.
0 commit comments