|
@@ -37,7 +37,7 @@ public class ProxyUsers {
|
|
public static final String CONF_GROUPS = ".groups";
|
|
public static final String CONF_GROUPS = ".groups";
|
|
public static final String CONF_HADOOP_PROXYUSER = "hadoop.proxyuser.";
|
|
public static final String CONF_HADOOP_PROXYUSER = "hadoop.proxyuser.";
|
|
public static final String CONF_HADOOP_PROXYUSER_RE = "hadoop\\.proxyuser\\.";
|
|
public static final String CONF_HADOOP_PROXYUSER_RE = "hadoop\\.proxyuser\\.";
|
|
- private static Configuration conf=null;
|
|
|
|
|
|
+ private static boolean init = false;
|
|
// list of groups and hosts per proxyuser
|
|
// list of groups and hosts per proxyuser
|
|
private static Map<String, Collection<String>> proxyGroups =
|
|
private static Map<String, Collection<String>> proxyGroups =
|
|
new HashMap<String, Collection<String>>();
|
|
new HashMap<String, Collection<String>>();
|
|
@@ -47,9 +47,17 @@ public class ProxyUsers {
|
|
/**
|
|
/**
|
|
* reread the conf and get new values for "hadoop.proxyuser.*.groups/hosts"
|
|
* reread the conf and get new values for "hadoop.proxyuser.*.groups/hosts"
|
|
*/
|
|
*/
|
|
- public static synchronized void refreshSuperUserGroupsConfiguration(Configuration cn) {
|
|
|
|
- conf = cn;
|
|
|
|
|
|
+ public static void refreshSuperUserGroupsConfiguration() {
|
|
|
|
+ //load server side configuration;
|
|
|
|
+ refreshSuperUserGroupsConfiguration(new Configuration());
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * refresh configuration
|
|
|
|
+ * @param conf
|
|
|
|
+ */
|
|
|
|
+ public static synchronized void refreshSuperUserGroupsConfiguration(Configuration conf) {
|
|
|
|
+
|
|
// remove alle existing stuff
|
|
// remove alle existing stuff
|
|
proxyGroups.clear();
|
|
proxyGroups.clear();
|
|
proxyHosts.clear();
|
|
proxyHosts.clear();
|
|
@@ -69,6 +77,8 @@ public class ProxyUsers {
|
|
proxyHosts.put(entry.getKey(),
|
|
proxyHosts.put(entry.getKey(),
|
|
StringUtils.getStringCollection(entry.getValue()));
|
|
StringUtils.getStringCollection(entry.getValue()));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ init = true;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -102,8 +112,8 @@ public class ProxyUsers {
|
|
public static synchronized void authorize(UserGroupInformation user,
|
|
public static synchronized void authorize(UserGroupInformation user,
|
|
String remoteAddress, Configuration newConf) throws AuthorizationException {
|
|
String remoteAddress, Configuration newConf) throws AuthorizationException {
|
|
|
|
|
|
- if(conf == null) {
|
|
|
|
- refreshSuperUserGroupsConfiguration(newConf);
|
|
|
|
|
|
+ if(!init) {
|
|
|
|
+ refreshSuperUserGroupsConfiguration();
|
|
}
|
|
}
|
|
|
|
|
|
if (user.getRealUser() == null) {
|
|
if (user.getRealUser() == null) {
|
|
@@ -116,7 +126,7 @@ public class ProxyUsers {
|
|
Collection<String> allowedUserGroups = proxyGroups.get(
|
|
Collection<String> allowedUserGroups = proxyGroups.get(
|
|
getProxySuperuserGroupConfKey(superUser.getShortUserName()));
|
|
getProxySuperuserGroupConfKey(superUser.getShortUserName()));
|
|
|
|
|
|
- if (!allowedUserGroups.isEmpty()) {
|
|
|
|
|
|
+ if (allowedUserGroups != null && !allowedUserGroups.isEmpty()) {
|
|
for (String group : user.getGroupNames()) {
|
|
for (String group : user.getGroupNames()) {
|
|
if (allowedUserGroups.contains(group)) {
|
|
if (allowedUserGroups.contains(group)) {
|
|
groupAuthorized = true;
|
|
groupAuthorized = true;
|
|
@@ -133,7 +143,7 @@ public class ProxyUsers {
|
|
Collection<String> ipList = proxyHosts.get(
|
|
Collection<String> ipList = proxyHosts.get(
|
|
getProxySuperuserIpConfKey(superUser.getShortUserName()));
|
|
getProxySuperuserIpConfKey(superUser.getShortUserName()));
|
|
|
|
|
|
- if (!ipList.isEmpty()) {
|
|
|
|
|
|
+ if (ipList != null && !ipList.isEmpty()) {
|
|
for (String allowedHost : ipList) {
|
|
for (String allowedHost : ipList) {
|
|
InetAddress hostAddr;
|
|
InetAddress hostAddr;
|
|
try {
|
|
try {
|