@@ -1048,13 +1048,12 @@ pub fn setgid(gid: Gid) -> Result<()> {
1048
1048
1049
1049
/// Get the list of supplementary group IDs of the calling process.
1050
1050
///
1051
- /// *Note:* On macOS, `getgroups()` behavior differs somewhat from other Unix
1052
- /// platforms. It returns the current group access list for the user associated
1053
- /// with the effective user id of the process; the group access list may change
1054
- /// over the lifetime of the process, and it is not affected by calls to
1055
- /// `setgroups()`.
1056
- ///
1057
1051
/// [Further reading](http://pubs.opengroup.org/onlinepubs/009695399/functions/getgroups.html)
1052
+ ///
1053
+ /// **Note:** This function is not available for Apple platforms. On those
1054
+ /// platforms, checking group membership should be achieved via communication
1055
+ /// with the `opendirectoryd` service.
1056
+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1058
1057
pub fn getgroups ( ) -> Result < Vec < Gid > > {
1059
1058
// First get the number of groups so we can size our Vec
1060
1059
let ret = unsafe { libc:: getgroups ( 0 , std:: ptr:: null_mut ( ) ) } ;
@@ -1091,13 +1090,12 @@ pub fn getgroups() -> Result<Vec<Gid>> {
1091
1090
1092
1091
/// Set the list of supplementary group IDs for the calling process.
1093
1092
///
1094
- /// *Note:* On macOS, `getgroups()` may not return the same group list set by
1095
- /// calling `setgroups()`. The use of `setgroups()` on macOS is 'highly
1096
- /// discouraged' by Apple. Developers are referred to the `opendirectoryd`
1097
- /// daemon and its set of APIs.
1098
- ///
1099
1093
/// [Further reading](http://man7.org/linux/man-pages/man2/getgroups.2.html)
1100
1094
///
1095
+ /// **Note:** This function is not available for Apple platforms. On those
1096
+ /// platforms, group membership management should be achieved via communication
1097
+ /// with the `opendirectoryd` service.
1098
+ ///
1101
1099
/// # Examples
1102
1100
///
1103
1101
/// `setgroups` can be used when dropping privileges from the root user to a
@@ -1111,6 +1109,7 @@ pub fn getgroups() -> Result<Vec<Gid>> {
1111
1109
/// setgid(gid)?;
1112
1110
/// setuid(uid)?;
1113
1111
/// ```
1112
+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1114
1113
pub fn setgroups ( groups : & [ Gid ] ) -> Result < ( ) > {
1115
1114
cfg_if ! {
1116
1115
if #[ cfg( any( target_os = "dragonfly" ,
@@ -1141,6 +1140,10 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
1141
1140
///
1142
1141
/// [Further reading](http://man7.org/linux/man-pages/man3/getgrouplist.3.html)
1143
1142
///
1143
+ /// **Note:** This function is not available for Apple platforms. On those
1144
+ /// platforms, checking group membership should be achieved via communication
1145
+ /// with the `opendirectoryd` service.
1146
+ ///
1144
1147
/// # Errors
1145
1148
///
1146
1149
/// Although the `getgrouplist()` call does not return any specific
@@ -1150,6 +1153,7 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
1150
1153
/// and `setgroups()`. Additionally, while some implementations will return a
1151
1154
/// partial list of groups when `NGROUPS_MAX` is exceeded, this implementation
1152
1155
/// will only ever return the complete list or else an error.
1156
+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1153
1157
pub fn getgrouplist ( user : & CStr , group : Gid ) -> Result < Vec < Gid > > {
1154
1158
let ngroups_max = match sysconf ( SysconfVar :: NGROUPS_MAX ) {
1155
1159
Ok ( Some ( n) ) => n as c_int ,
@@ -1208,6 +1212,10 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
1208
1212
///
1209
1213
/// [Further reading](http://man7.org/linux/man-pages/man3/initgroups.3.html)
1210
1214
///
1215
+ /// **Note:** This function is not available for Apple platforms. On those
1216
+ /// platforms, group membership management should be achieved via communication
1217
+ /// with the `opendirectoryd` service.
1218
+ ///
1211
1219
/// # Examples
1212
1220
///
1213
1221
/// `initgroups` can be used when dropping privileges from the root user to
@@ -1223,6 +1231,7 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
1223
1231
/// setgid(gid)?;
1224
1232
/// setuid(uid)?;
1225
1233
/// ```
1234
+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
1226
1235
pub fn initgroups ( user : & CStr , group : Gid ) -> Result < ( ) > {
1227
1236
cfg_if ! {
1228
1237
if #[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ] {
0 commit comments