This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 5ed56770d47 [bugfix](external) Prevent multiple `fs` from being 
generated (#39663) (#39870)
5ed56770d47 is described below

commit 5ed56770d47a64a4d86486266e4c052453b5f8ae
Author: Mingyu Chen <morning...@163.com>
AuthorDate: Sat Aug 24 14:17:26 2024 +0800

    [bugfix](external) Prevent multiple `fs` from being generated (#39663) 
(#39870)
    
    bp #39663
    
    Co-authored-by: wuwenchi <wuwenchi...@hotmail.com>
---
 .../common/security/authentication/HadoopUGI.java  | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-common/src/main/java/org/apache/doris/common/security/authentication/HadoopUGI.java
 
b/fe/fe-common/src/main/java/org/apache/doris/common/security/authentication/HadoopUGI.java
index d04d772728b..2f73440ecfa 100644
--- 
a/fe/fe-common/src/main/java/org/apache/doris/common/security/authentication/HadoopUGI.java
+++ 
b/fe/fe-common/src/main/java/org/apache/doris/common/security/authentication/HadoopUGI.java
@@ -61,7 +61,27 @@ public class HadoopUGI {
                 throw new RuntimeException(e);
             }
         } else {
-            return new HadoopSimpleAuthenticator((SimpleAuthenticationConfig) 
config).getUGI();
+            String hadoopUserName = ((SimpleAuthenticationConfig) 
config).getUsername();
+            if (hadoopUserName == null) {
+                hadoopUserName = "hadoop";
+                ((SimpleAuthenticationConfig) 
config).setUsername(hadoopUserName);
+                LOG.debug(AuthenticationConfig.HADOOP_USER_NAME + " is unset, 
use default user: hadoop");
+            }
+
+            UserGroupInformation ugi;
+            try {
+                ugi = UserGroupInformation.getLoginUser();
+                if (ugi.getUserName().equals(hadoopUserName)) {
+                    return ugi;
+                }
+            } catch (IOException e) {
+                LOG.warn("A SecurityException occurs with simple, do login 
immediately.", e);
+            }
+
+            ugi = UserGroupInformation.createRemoteUser(hadoopUserName);
+            UserGroupInformation.setLoginUser(ugi);
+            LOG.debug("Login by proxy user, hadoop.username: {}", 
hadoopUserName);
+            return ugi;
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to