Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ZEPPELIN-6094] Fix broken impersonation
### What is this PR for? A few sentences describing the overall goals of the pull request's commits. The issue stems from the way the interpreter.sh script handles the ZEPPELIN_IMPERSONATE_CMD and constructs the command to be executed. Specifically, the command string passed to bash -c is not being properly formed as a single string, causing exec to fail when it tries to execute the impersonation command. 1. Command Construction: When ZEPPELIN_IMPERSONATE_CMD is set, the script attempts to build an array INTERPRETER_RUN_COMMAND that includes this command. However, if ZEPPELIN_IMPERSONATE_CMD is a string, it gets added as a single element to the array, leading to incorrect command parsing. 2. bash -c Behavior: The -c option in bash expects a single string argument that contains the command to execute. If this command is split into multiple array elements, bash misinterprets it, causing failures when it encounters shell built-ins like source. 3. exec Execution: The exec command replaces the shell with the specified command. If the command is not correctly formatted, exec cannot find it, resulting in errors like exec: sudo -H -u rfialkovskii bash -c: not found. To fix the issue needs to adjust how the command is constructed in interpreter.sh when ZEPPELIN_IMPERSONATE_CMD is used. Specifically, the command string passed to bash -c is a single, properly formatted string. Needs: Define ZEPPELIN_IMPERSONATE_CMD as an Array. Modify interpreter.sh to Build a Single Command String: ### What type of PR is it? Bug Fix ### What is the Jira issue? [* Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/ (https://issues.apache.org/jira/browse/ZEPPELIN-6094) ### How should this be tested? Enable shiro auth, configure impersonation and try to run any interpreter under impersonated user ### Screenshots (if appropriate) <img width="583" alt="Screenshot 2024-09-19 at 01 46 38" src="https://github.com/user-attachments/assets/d0bcb703-c43d-476f-9ea5-61aaef433a09"> ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? Yes, needs to change env from: export ZEPPELIN_IMPERSONATE_CMD='sudo -H -u "${ZEPPELIN_IMPERSONATE_USER}" bash -c' to: export ZEPPELIN_IMPERSONATE_CMD=(sudo -H -u "${ZEPPELIN_IMPERSONATE_USER}" bash -c) * Does this needs documentation? Yes Closes apache#4835 from ruslanfialkovskii/ZEPPELIN-6094-Fix-broken-impersonation. Signed-off-by: Cheng Pan <[email protected]>
- Loading branch information