mbr_check_membership.3 [plain text]
.\" Copyright (c) 2005-2011 Apple Inc
.\" All rights reserved.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of Apple Computer nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.Dd November 5, 2011
.Dt MBR_CHECK_MEMBERSHIP 3
.Os "Mac OS X"
.Nd check whether a user is a member of a group or service ACL
.Fn mbr_check_membership "uuid_t user" "uuid_t group" "int *ismember"
.Fn mbr_check_service_membership "uuid_t user" "const char *service" "int *ismember"
tests if a given user is a member of a group (either direct or indirect via a
is set to 1 if the user is a member or 0 if not a member of the group.
similarly tests if a given user is a member of a service ACL group. Service
ACLs are special groups defined with the prefix "com.apple.access_". The
service is then prefixed (e.g., "afp" would check "com.apple.access_afp").
There is a special group that grants accessto all services called
Users may belong to any number of groups.
should always be used to check group membership, rather than calling
.Xr getgroups 2
.Xr getgrouplist 2 .
.Xr setgroups 2
.Xr getgroups 2
routines are limited to a fixed number of gids,
and so may not include all of a user's groups.
There are two special cases.
If the two uuids are equal, then
is set to 1.
uuid is equal to the reserved "everyone" uuid (ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C), then
will be set to 1 for any valid user.
Group membership information is managed by
.Xr opendirectoryd 8 .
.Sh RETURN VALUES
does not test whether
exists or not.
Querying membership for a nonexistent group will result in
being set to 0. The function returns 0 on success or one of the following error
codes on failure:
.Bl -tag -width Er
.It Bq Er EIO
.Xr openditectoryd 8
.It Bq Er ENOENT
can not be found.
is identical to
except that ENOENT means no service ACL has been defined.
.Sh SEE ALSO
.Xr odutil 1 ,
.Xr setgroups 2 ,
.Xr getgroups 2 ,
.Xr mbr_uid_to_uuid 3 ,
.Xr opendirectoryd 8