From e346c2f4e08a38a80c7f505d8a8f3554b408e997 Mon Sep 17 00:00:00 2001 From: Boris Shkolnik Date: Wed, 26 May 2010 18:35:50 +0000 Subject: [PATCH] HADOOP-6644. util.Shell getGROUPS_FOR_USER_COMMAND method name - should use common naming convention git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@948528 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +++ .../apache/hadoop/security/ShellBasedUnixGroupsMapping.java | 2 +- .../security/authorize/ServiceAuthorizationManager.java | 6 +++--- src/java/org/apache/hadoop/util/Shell.java | 4 ++-- .../org/apache/hadoop/fs/FileContextPermissionBase.java | 2 +- .../org/apache/hadoop/fs/TestLocalFileSystemPermission.java | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 84e52ef1d4..431e02bdc1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,6 +3,9 @@ Hadoop Change Log Trunk (unreleased changes) IMPROVEMENTS + HADOOP-6644. util.Shell getGROUPS_FOR_USER_COMMAND method name + - should use common naming convention (boryas) + HADOOP-6778. add isRunning() method to AbstractDelegationTokenSecretManager (for HDFS-1044) (boryas) diff --git a/src/java/org/apache/hadoop/security/ShellBasedUnixGroupsMapping.java b/src/java/org/apache/hadoop/security/ShellBasedUnixGroupsMapping.java index cc4caa2e6b..fe170ce00d 100644 --- a/src/java/org/apache/hadoop/security/ShellBasedUnixGroupsMapping.java +++ b/src/java/org/apache/hadoop/security/ShellBasedUnixGroupsMapping.java @@ -60,7 +60,7 @@ public List getGroups(String user) throws IOException { private static List getUnixGroups(final String user) throws IOException { String result = ""; try { - result = Shell.execCommand(Shell.getGROUPS_FOR_USER_COMMAND(user)); + result = Shell.execCommand(Shell.getGroupsForUserCommand(user)); } catch (ExitCodeException e) { // if we didn't get the group - just return empty list; LOG.warn("got exception trying to get groups for user " + user, e); diff --git a/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java b/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java index dbb29b5e3a..619f21ae72 100644 --- a/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java +++ b/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java @@ -48,7 +48,7 @@ public class ServiceAuthorizationManager { public static final String SERVICE_AUTHORIZATION_CONFIG = "hadoop.security.authorization"; - public static final Log auditLOG = + public static final Log AUDITLOG = LogFactory.getLog("SecurityLogger."+ServiceAuthorizationManager.class.getName()); private static final String AUTHZ_SUCCESSFULL_FOR = "Authorization successfull for "; @@ -83,12 +83,12 @@ public static void authorize(UserGroupInformation user, } if((clientPrincipal != null && !clientPrincipal.equals(user.getUserName())) || !acl.isUserAllowed(user)) { - auditLOG.warn(AUTHZ_FAILED_FOR + user + " for protocol="+protocol); + AUDITLOG.warn(AUTHZ_FAILED_FOR + user + " for protocol="+protocol); throw new AuthorizationException("User " + user + " is not authorized for protocol " + protocol); } - auditLOG.info(AUTHZ_SUCCESSFULL_FOR + user + " for protocol="+protocol); + AUDITLOG.info(AUTHZ_SUCCESSFULL_FOR + user + " for protocol="+protocol); } public static synchronized void refresh(Configuration conf, diff --git a/src/java/org/apache/hadoop/util/Shell.java b/src/java/org/apache/hadoop/util/Shell.java index 683577e41d..e1b2154977 100644 --- a/src/java/org/apache/hadoop/util/Shell.java +++ b/src/java/org/apache/hadoop/util/Shell.java @@ -44,11 +44,11 @@ abstract public class Shell { /** a Unix command to get the current user's name */ public final static String USER_NAME_COMMAND = "whoami"; /** a Unix command to get the current user's groups list */ - public static String[] getGROUPS_COMMAND() { + public static String[] getGroupsCommand() { return new String[]{"bash", "-c", "groups"}; } /** a Unix command to get a given user's groups list */ - public static String[] getGROUPS_FOR_USER_COMMAND(final String user) { + public static String[] getGroupsForUserCommand(final String user) { //'groups username' command return is non-consistent across different unixes return new String [] {"bash", "-c", "id -Gn " + user}; } diff --git a/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java b/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java index 1e8497206b..cd326b21ef 100644 --- a/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java +++ b/src/test/core/org/apache/hadoop/fs/FileContextPermissionBase.java @@ -165,7 +165,7 @@ public void testSetOwner() throws IOException { static List getGroups() throws IOException { List a = new ArrayList(); - String s = Shell.execCommand(Shell.getGROUPS_COMMAND()); + String s = Shell.execCommand(Shell.getGroupsCommand()); for(StringTokenizer t = new StringTokenizer(s); t.hasMoreTokens(); ) { a.add(t.nextToken()); } diff --git a/src/test/core/org/apache/hadoop/fs/TestLocalFileSystemPermission.java b/src/test/core/org/apache/hadoop/fs/TestLocalFileSystemPermission.java index f68cdb66cd..d76d27e01b 100644 --- a/src/test/core/org/apache/hadoop/fs/TestLocalFileSystemPermission.java +++ b/src/test/core/org/apache/hadoop/fs/TestLocalFileSystemPermission.java @@ -144,7 +144,7 @@ public void testLocalFSsetOwner() throws IOException { static List getGroups() throws IOException { List a = new ArrayList(); - String s = Shell.execCommand(Shell.getGROUPS_COMMAND()); + String s = Shell.execCommand(Shell.getGroupsCommand()); for(StringTokenizer t = new StringTokenizer(s); t.hasMoreTokens(); ) { a.add(t.nextToken()); }