Package org.apache.hadoop.security
Class JniBasedUnixGroupsNetgroupMapping
java.lang.Object
org.apache.hadoop.security.JniBasedUnixGroupsMapping
org.apache.hadoop.security.JniBasedUnixGroupsNetgroupMapping
- All Implemented Interfaces:
GroupMappingServiceProvider
@LimitedPrivate({"HDFS","MapReduce"})
@Evolving
public class JniBasedUnixGroupsNetgroupMapping
extends JniBasedUnixGroupsMapping
A JNI-based implementation of
GroupMappingServiceProvider
that invokes libC calls to get the group
memberships of a given user.-
Field Summary
Fields inherited from interface org.apache.hadoop.security.GroupMappingServiceProvider
GROUP_MAPPING_CONFIG_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheGroupsAdd(List<String> groups) Add a group to cache, only netgroups are cachedvoidRefresh the netgroup cacheGets unix groups and netgroups for the user.getUsersForNetgroup(String netgroup) Calls JNI function to get users for a netgroup, since C functions are not reentrant we need to make this synchronized (see documentation for setnetgrent, getnetgrent and endnetgrent)Methods inherited from class org.apache.hadoop.security.JniBasedUnixGroupsMapping
getGroupsSet
-
Constructor Details
-
JniBasedUnixGroupsNetgroupMapping
public JniBasedUnixGroupsNetgroupMapping()
-
-
Method Details
-
getGroups
Gets unix groups and netgroups for the user. It gets all unix groups as returned by id -Gn but it only returns netgroups that are used in ACLs (there is no way to get all netgroups for a given user, see documentation for getent netgroup)- Specified by:
getGroupsin interfaceGroupMappingServiceProvider- Overrides:
getGroupsin classJniBasedUnixGroupsMapping- Parameters:
user- User's name- Returns:
- group memberships of user
- Throws:
IOException- raised on errors performing I/O.
-
cacheGroupsRefresh
Refresh the netgroup cache- Specified by:
cacheGroupsRefreshin interfaceGroupMappingServiceProvider- Overrides:
cacheGroupsRefreshin classJniBasedUnixGroupsMapping- Throws:
IOException- raised on errors performing I/O.
-
cacheGroupsAdd
Add a group to cache, only netgroups are cached- Specified by:
cacheGroupsAddin interfaceGroupMappingServiceProvider- Overrides:
cacheGroupsAddin classJniBasedUnixGroupsMapping- Parameters:
groups- list of group names to add to cache- Throws:
IOException- raised on errors performing I/O.
-
getUsersForNetgroup
Calls JNI function to get users for a netgroup, since C functions are not reentrant we need to make this synchronized (see documentation for setnetgrent, getnetgrent and endnetgrent)- Parameters:
netgroup- return users for this netgroup- Returns:
- list of users for a given netgroup
-