From commits-return-7222-archive-asf-public=cust-asf.ponee.io@kudu.apache.org Fri Mar 29 04:18:48 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3FB0E18076D for ; Fri, 29 Mar 2019 05:18:48 +0100 (CET) Received: (qmail 77798 invoked by uid 500); 29 Mar 2019 04:18:47 -0000 Mailing-List: contact commits-help@kudu.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@kudu.apache.org Delivered-To: mailing list commits@kudu.apache.org Received: (qmail 77761 invoked by uid 99); 29 Mar 2019 04:18:46 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Mar 2019 04:18:46 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id F1D5085B3E; Fri, 29 Mar 2019 04:18:45 +0000 (UTC) Date: Fri, 29 Mar 2019 04:18:47 +0000 To: "commits@kudu.apache.org" Subject: [kudu] 02/03: KUDU-2717. Add an environment variable override for username MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: adar@apache.org In-Reply-To: <155383312588.23983.11723576752428359772@gitbox.apache.org> References: <155383312588.23983.11723576752428359772@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: kudu X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 20a3976d7eafc038f2b118d53066c26ddd2d4903 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20190329041845.F1D5085B3E@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. adar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git commit 20a3976d7eafc038f2b118d53066c26ddd2d4903 Author: Todd Lipcon AuthorDate: Wed Feb 27 15:19:34 2019 -0800 KUDU-2717. Add an environment variable override for username This adds a KUDU_USER_NAME environment variable which overrides the lookup of the local unix user. This is a client-side identity which is easy to spoof anyway (eg via LD_PRELOAD) so providing such an override doesn't harm any security. But, it adds a certain amount of convenience when trying to use kudu tools against an insecure cluster. No tests are added since this is pretty trivial code, but I tested manually that I was able to call 'kudu master set_flags' against a remote cluster after specifying KUDU_USER_NAME=kudu Change-Id: I9d42a3efbf26882f086046c276d5f9965a4068f5 Reviewed-on: http://gerrit.cloudera.org:8080/12627 Tested-by: Kudu Jenkins Reviewed-by: Grant Henke --- src/kudu/util/user.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/kudu/util/user.cc b/src/kudu/util/user.cc index f44e040..abea3e6 100644 --- a/src/kudu/util/user.cc +++ b/src/kudu/util/user.cc @@ -18,12 +18,14 @@ #include "kudu/util/user.h" #include +#include #include #include #include #include #include +#include #include #include @@ -40,6 +42,13 @@ namespace kudu { namespace { Status DoGetLoggedInUser(string* user_name) { + const char* override_username = getenv("KUDU_USER_NAME"); + if (override_username && strlen(override_username)) { + VLOG(1) << "Overriding logged-in user name to " << override_username; + *user_name = override_username; + return Status::OK();; + } + DCHECK(user_name != nullptr); struct passwd pwd;