From 84ebda7d76184963f298f061ae15fc13a9ce1646 Mon Sep 17 00:00:00 2001
From: Martin Durant <martin.durant@utoronto.ca>
Date: Tue, 9 Jan 2018 13:39:34 -0500
Subject: [PATCH] RpcChannelImpl::buildConnectionContext fix

---
 libhdfs3/src/rpc/RpcChannel.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libhdfs3/src/rpc/RpcChannel.cpp b/libhdfs3/src/rpc/RpcChannel.cpp
index 4e9b758..d261322 100644
--- a/libhdfs3/src/rpc/RpcChannel.cpp
+++ b/libhdfs3/src/rpc/RpcChannel.cpp
@@ -761,8 +761,8 @@ void RpcChannelImpl::buildConnectionContext(
     std::string euser = key.getAuth().getUser().getEffectiveUser();
     std::string ruser = key.getAuth().getUser().getRealUser();
 
-    if (!euser.empty())
-        user->set_effectiveuser(euser);
+    if (!key.getAuth().getUser().hasEffectiveUser())
+        euser = principal;
 
     if (auth.getMethod() != AuthMethod::TOKEN) {
         UserInformationProto * user = connectionContext.mutable_userinfo();
@@ -775,7 +775,6 @@ void RpcChannelImpl::buildConnectionContext(
         }
     }
 }
-
 void RpcChannelImpl::sendConnectionContent(const RpcAuth & auth) {
     WriteBuffer buffer;
     IpcConnectionContextProto connectionContext;
