[KYUUBI #6588] Get effective USER if env var is unavailable
# 🔍 Description In some cases, env var USER is unavailable, for example, docker container, we should evaluate it via `id -nu` ref: https://github.com/apache/hadoop/blob/rel/release-3.4.0/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh#L893-L896 ## Types of changes 🔖 - [x] Bugfix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan 🧪 ``` $ docker run -t -i ubuntu:latest root1dbeaefd6cd4:/# echo $USER root1dbeaefd6cd4:/# id -nu root root1dbeaefd6cd4:/# exit ``` --- # Checklist 📝 - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6588 from pan3793/USER. Closes #6588 a79786347 [Cheng Pan] Get effective USER if env var is unavailable Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
parent
49d224e002
commit
b90063942a
@ -35,6 +35,11 @@ if [[ "$*" = *--help ]] || [[ "$*" = *-h ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# if for some reason the shell doesn't have $USER defined
|
||||
# (e.g., ssh'd in to execute a command)
|
||||
# let's get the effective username and use that
|
||||
USER=${USER:-$(id -nu)}
|
||||
|
||||
function kyuubi_logo() {
|
||||
source ${KYUUBI_HOME}/bin/kyuubi-logo
|
||||
}
|
||||
|
||||
@ -30,7 +30,10 @@ echo_build_properties() {
|
||||
echo kyuubi_hadoop_version="$7"
|
||||
echo kyuubi_flink_version="$8"
|
||||
echo kyuubi_trino_version="$9"
|
||||
echo user="$USER"
|
||||
# if for some reason the shell doesn't have $USER defined
|
||||
# (e.g., ssh'd in to execute a command)
|
||||
# let's get the effective username and use that
|
||||
echo user="${USER:-$(id -nu)}"
|
||||
echo revision=$(git rev-parse HEAD)
|
||||
echo revision_time=$(git show -s --format=%ci HEAD)
|
||||
echo branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user