Author: jitendra
Date: Wed Jan 25 21:18:02 2012
New Revision: 1235955

URL: http://svn.apache.org/viewvc?rev=1235955&view=rev
Log:
Merged r1235951 from branch-1 for HADOOP-7987.

Added:
    
hadoop/common/branches/branch-1.0/src/test/org/apache/hadoop/security/TestUserFromEnv.java
      - copied unchanged from r1235951, 
hadoop/common/branches/branch-1/src/test/org/apache/hadoop/security/TestUserFromEnv.java
Modified:
    hadoop/common/branches/branch-1.0/CHANGES.txt
    
hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/security/UserGroupInformation.java

Modified: hadoop/common/branches/branch-1.0/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/CHANGES.txt?rev=1235955&r1=1235954&r2=1235955&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.0/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1.0/CHANGES.txt Wed Jan 25 21:18:02 2012
@@ -8,6 +8,8 @@ Release 1.0.1 - unreleased
 
     MAPREDUCE-3607. Port missing new API mapreduce lib classes to 1.x. 
(tomwhite)
 
+    HADOOP-7987. Support setting the run-as user in unsecure mode. (jitendra)
+
   BUG FIXES
 
     HADOOP-7964. Deadlock in NetUtils and SecurityUtil class initialization.

Modified: 
hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/security/UserGroupInformation.java
URL: 
http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/security/UserGroupInformation.java?rev=1235955&r1=1235954&r2=1235955&view=diff
==============================================================================
--- 
hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/security/UserGroupInformation.java
 (original)
+++ 
hadoop/common/branches/branch-1.0/src/core/org/apache/hadoop/security/UserGroupInformation.java
 Wed Jan 25 21:18:02 2012
@@ -71,6 +71,7 @@ public class UserGroupInformation {
    * Percentage of the ticket window to use before we renew ticket.
    */
   private static final float TICKET_RENEW_WINDOW = 0.80f;
+  static final String HADOOP_USER_NAME = "HADOOP_USER_NAME";
   
   /**
    * A login module that looks at the Kerberos, Unix, or Windows principal and
@@ -111,7 +112,16 @@ public class UserGroupInformation {
           LOG.debug("using kerberos user:"+user);
         }
       }
-      // if we don't have a kerberos user, use the OS user
+      //If we don't have a kerberos user and security is disabled, check
+      //if user is specified in the environment or properties
+      if (!isSecurityEnabled() && (user == null)) {
+        String envUser = System.getenv(HADOOP_USER_NAME);
+        if (envUser == null) {
+          envUser = System.getProperty(HADOOP_USER_NAME);
+        }
+        user = envUser == null ? null : new User(envUser);
+      }
+      // use the OS user
       if (user == null) {
         user = getCanonicalUser(OS_PRINCIPAL_CLASS);
         if (LOG.isDebugEnabled()) {


Reply via email to