File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,29 @@ mod linux_android {
104
104
}
105
105
}
106
106
107
+ #[ test]
108
+ // `getgroups()` and `setgroups()` do not behave as expected on Apple platforms
109
+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
110
+ fn test_setgroups ( ) {
111
+ // Skip this test when not run as root as `setgroups()` requires root.
112
+ if !Uid :: current ( ) . is_root ( ) {
113
+ return
114
+ }
115
+
116
+ // Save the existing groups
117
+ let old_groups = getgroups ( ) . unwrap ( ) ;
118
+
119
+ // Set some new made up groups
120
+ let groups = [ Gid :: from_raw ( 123 ) , Gid :: from_raw ( 456 ) ] ;
121
+ setgroups ( & groups) . unwrap ( ) ;
122
+
123
+ let new_groups = getgroups ( ) . unwrap ( ) ;
124
+ assert_eq ! ( new_groups, groups) ;
125
+
126
+ // Revert back to the old groups
127
+ setgroups ( & old_groups) . unwrap ( ) ;
128
+ }
129
+
107
130
macro_rules! execve_test_factory(
108
131
( $test_name: ident, $syscall: ident, $exe: expr) => (
109
132
#[ test]
You can’t perform that action at this time.
0 commit comments