diff --git a/bin/interpreter.sh b/bin/interpreter.sh index aaa9b0a15a0..cf8501bb3cf 100755 --- a/bin/interpreter.sh +++ b/bin/interpreter.sh @@ -247,13 +247,19 @@ addJarInDirForIntp "${LOCAL_INTERPRETER_REPO}" if [[ -n "$ZEPPELIN_IMPERSONATE_USER" ]]; then if [[ "${INTERPRETER_ID}" != "spark" || "$ZEPPELIN_IMPERSONATE_SPARK_PROXY_USER" == "false" ]]; then - suid="$(id -u "${ZEPPELIN_IMPERSONATE_USER}")" - if [[ -n "${suid}" || -z "${SPARK_SUBMIT}" ]]; then - INTERPRETER_RUN_COMMAND+=("${ZEPPELIN_IMPERSONATE_RUN_CMD[@]}") - if [[ -f "${ZEPPELIN_CONF_DIR}/zeppelin-env.sh" ]]; then - INTERPRETER_RUN_COMMAND+=("source" "${ZEPPELIN_CONF_DIR}/zeppelin-env.sh;") - fi + # Build the command string + COMMAND_STRING="" + if [[ -f "${ZEPPELIN_CONF_DIR}/zeppelin-env.sh" ]]; then + COMMAND_STRING+="source ${ZEPPELIN_CONF_DIR}/zeppelin-env.sh; " fi + + # Add interpreter command to the command string + IFS=' ' read -r -a JAVA_INTP_OPTS_ARRAY <<< "${JAVA_INTP_OPTS}" + IFS=' ' read -r -a ZEPPELIN_INTP_MEM_ARRAY <<< "${ZEPPELIN_INTP_MEM}" + COMMAND_STRING+="${ZEPPELIN_RUNNER} ${JAVA_INTP_OPTS_ARRAY[@]} ${ZEPPELIN_INTP_MEM_ARRAY[@]} -cp '${ZEPPELIN_INTP_CLASSPATH_OVERRIDES}:${ZEPPELIN_INTP_CLASSPATH}' ${ZEPPELIN_SERVER} ${CALLBACK_HOST} ${PORT} ${INTP_GROUP_ID} ${INTP_PORT}" + + # Set INTERPRETER_RUN_COMMAND with the impersonation command and command string + INTERPRETER_RUN_COMMAND=("${ZEPPELIN_IMPERSONATE_CMD[@]}" "${COMMAND_STRING}") fi fi diff --git a/conf/zeppelin-env.sh.template b/conf/zeppelin-env.sh.template index 9c228cbadbc..f3484db98d8 100644 --- a/conf/zeppelin-env.sh.template +++ b/conf/zeppelin-env.sh.template @@ -108,5 +108,5 @@ # export HBASE_CONF_DIR= # (optional) Alternatively, configuration directory can be set to point to the directory that has hbase-site.xml #### Zeppelin impersonation configuration -# export ZEPPELIN_IMPERSONATE_CMD # Optional, when user want to run interpreter as end web user. eg) 'sudo -H -u ${ZEPPELIN_IMPERSONATE_USER} bash -c ' +# export ZEPPELIN_IMPERSONATE_CMD # Optional, when user want to run interpreter as end web user. eg) (sudo -H -u "${ZEPPELIN_IMPERSONATE_USER}" bash -c) # export ZEPPELIN_IMPERSONATE_SPARK_PROXY_USER #Optional, by default is true; can be set to false if you don't want to use --proxy-user option with Spark interpreter when impersonation enabled diff --git a/docs/usage/interpreter/user_impersonation.md b/docs/usage/interpreter/user_impersonation.md index 722f89f2668..6572161a98f 100644 --- a/docs/usage/interpreter/user_impersonation.md +++ b/docs/usage/interpreter/user_impersonation.md @@ -47,7 +47,7 @@ cat ~/.ssh/id_rsa.pub | ssh user1@localhost 'cat >> .ssh/authorized_keys' Alternatively instead of password-less, user can override ZEPPELIN_IMPERSONATE_CMD in zeppelin-env.sh ```bash -export ZEPPELIN_IMPERSONATE_CMD='sudo -H -u ${ZEPPELIN_IMPERSONATE_USER} bash -c ' +export ZEPPELIN_IMPERSONATE_CMD=(sudo -H -u "${ZEPPELIN_IMPERSONATE_USER}" bash -c) ```