@@ -1048,13 +1048,12 @@ pub fn setgid(gid: Gid) -> Result<()> {
10481048
10491049/// Get the list of supplementary group IDs of the calling process.
10501050///
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- ///
10571051/// [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" ) ) ) ]
10581057pub fn getgroups ( ) -> Result < Vec < Gid > > {
10591058 // First get the number of groups so we can size our Vec
10601059 let ret = unsafe { libc:: getgroups ( 0 , std:: ptr:: null_mut ( ) ) } ;
@@ -1091,13 +1090,12 @@ pub fn getgroups() -> Result<Vec<Gid>> {
10911090
10921091/// Set the list of supplementary group IDs for the calling process.
10931092///
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- ///
10991093/// [Further reading](http://man7.org/linux/man-pages/man2/getgroups.2.html)
11001094///
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+ ///
11011099/// # Examples
11021100///
11031101/// `setgroups` can be used when dropping privileges from the root user to a
@@ -1111,6 +1109,7 @@ pub fn getgroups() -> Result<Vec<Gid>> {
11111109/// setgid(gid)?;
11121110/// setuid(uid)?;
11131111/// ```
1112+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
11141113pub fn setgroups ( groups : & [ Gid ] ) -> Result < ( ) > {
11151114 cfg_if ! {
11161115 if #[ cfg( any( target_os = "dragonfly" ,
@@ -1141,6 +1140,10 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
11411140///
11421141/// [Further reading](http://man7.org/linux/man-pages/man3/getgrouplist.3.html)
11431142///
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+ ///
11441147/// # Errors
11451148///
11461149/// Although the `getgrouplist()` call does not return any specific
@@ -1150,6 +1153,7 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
11501153/// and `setgroups()`. Additionally, while some implementations will return a
11511154/// partial list of groups when `NGROUPS_MAX` is exceeded, this implementation
11521155/// will only ever return the complete list or else an error.
1156+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
11531157pub fn getgrouplist ( user : & CStr , group : Gid ) -> Result < Vec < Gid > > {
11541158 let ngroups_max = match sysconf ( SysconfVar :: NGROUPS_MAX ) {
11551159 Ok ( Some ( n) ) => n as c_int ,
@@ -1208,6 +1212,10 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
12081212///
12091213/// [Further reading](http://man7.org/linux/man-pages/man3/initgroups.3.html)
12101214///
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+ ///
12111219/// # Examples
12121220///
12131221/// `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>> {
12231231/// setgid(gid)?;
12241232/// setuid(uid)?;
12251233/// ```
1234+ #[ cfg( not( any( target_os = "ios" , target_os = "macos" ) ) ) ]
12261235pub fn initgroups ( user : & CStr , group : Gid ) -> Result < ( ) > {
12271236 cfg_if ! {
12281237 if #[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ] {
0 commit comments