You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@zeppelin.apache.org by "ruslanfialkovskii (via GitHub)" <gi...@apache.org> on 2024/09/18 23:38:36 UTC

[PR] ZEPPELIN-6094 fixed broken impersonation [zeppelin]

ruslanfialkovskii opened a new pull request, #4835:
URL: https://github.com/apache/zeppelin/pull/4835

   ### 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
   
   ### Todos
   * [ ] - Task
   
   ### What is the Jira issue?
   [* Open an issue on Jira https://issues.apache.org/jira/browse/ZEPPELIN/
   * Put link here, and add [ZEPPELIN-*Jira number*] in PR title, eg. [ZEPPELIN-533]](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)
   
   ### 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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "ruslanfialkovskii (via GitHub)" <gi...@apache.org>.
ruslanfialkovskii commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360989374

   @Reamer yes, I set up  a user for each LDAP user on the system, which is then addressed via sudo.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360699543

   @ruslanfialkovskii I tend to accept this change as it recovers a broken feature, but the differences in the process's hierarchy between impersonate enabled and disabled might break some assumptions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360740189

   If I understand correctly, after ZEPPELIN-5070, with impersonation disabled, the process's hierarchy looks like below?
   ```
   Zeppelin Server Process (Parent)
       └── Interpreter Process (e.g., Spark, Flink, etc.)
           └── [Optional] Interpreter Subprocesses (e.g., Spark driver, executors)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "ruslanfialkovskii (via GitHub)" <gi...@apache.org>.
ruslanfialkovskii commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360525836

   Also, this fix enables impersonation permanently if ZEPPELIN_IMPERSONATE_CMD exists in env file. I appreciate to point on the clue on how to enable it only if the option "Set impersonation" is active. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fix broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2362592725

   @ruslanfialkovskii thanks, merged to master for 0.12. Given it involves a breaking change - user should update the default value, I only merge this to the master for the next feature version


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "ruslanfialkovskii (via GitHub)" <gi...@apache.org>.
ruslanfialkovskii commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360654321

   @pan3793 maybe you are right, I don't know well zeppelin's process architecture but the change just formats an impersonate command for running the interpreter in the right way nothing else. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360736386

   If the user impersonation works again with these corrections, that's fine by me. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360702062

   cc @Reamer, you may have the context to evaluate the impact of different process's hierarchy


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fix broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 merged PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360732927

   In general, I am not a friend of user impersonation. In my opinion, both the attempt with `sudo` and `ssh` are hacked solutions.
   In general, there are such approaches that the running program changes the user. This can be seen, for example, with the Apache web server, which changes from `root` to `www-data`. As far as I know, this is done because Apache opens privileged ports (<1024). In the case of Apache, this is usually 80 or 443.
   Zeppelin is already running on a high port e.g. 8080, so it is not necessary to change the user here, but you can start directly with an unprivileged user.
   
   Both ssh and sudo may have problems passing signals to the JVM. This can lead to the Zeppelin interpreter not shutting down properly.
   
   I had the signal problem in K8s, which is why I switched to `exec`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "ruslanfialkovskii (via GitHub)" <gi...@apache.org>.
ruslanfialkovskii commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360482379

   @pan3793 Yes, when impersonation is enabled in Apache Zeppelin, it creates subprocesses to execute the interpreter under the impersonated user’s identity. 
   Zeppelin Server Process (Parent)
       └── interpreter.sh (Interpreter Launch Script)
           └── sudo (or ssh) as ZEPPELIN_IMPERSONATE_CMD (Switches User Context)
               └── Interpreter Process (e.g., Spark, Flink, etc.)
                   └── [Optional] Interpreter Subprocesses (e.g., Spark driver, executors)
                   
   Nothing new, this is a fix for what worked before.
   It doesn't interfere into process work, it just fixed the command format. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360399590

   will it create subprocesses when impersonation is enabled? if yes, what's the hierarchy?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360495095

   I think ZEPPELIN-5070 changed the process's hierarchy, at least for impersonation-disabled cases.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "Reamer (via GitHub)" <gi...@apache.org>.
Reamer commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360819256

   If you need to separate the processes, I recommend using Docker, Kubernetes or the YARN launcher.
   Have you set up a user for each LDAP user on the system, which is then addressed via sudo or ssh?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360856147

   Hmm... I believe I understand why [gosu](https://github.com/tianon/gosu) present and is adopted widely now, maybe we can explore leverage it to avoid creating subporcess, though this might be out of the scope of this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [ZEPPELIN-6094] Fixed broken impersonation [zeppelin]

Posted by "ruslanfialkovskii (via GitHub)" <gi...@apache.org>.
ruslanfialkovskii commented on PR #4835:
URL: https://github.com/apache/zeppelin/pull/4835#issuecomment-2360769359

   Hi @Reamer, the point of using impersonation is running interpreters under specific authenticated users (in my case by ldap)
   It is a security team request. Zeppelin server of course is already running under Zeppelin system user (zeppelin) but I need to configure it to run a specific interpreter under a specific user in a separate isolated process. 
   <img width="599" alt="Screenshot 2024-09-19 at 13 44 30" src="https://github.com/user-attachments/assets/d55f830f-16e6-4816-80df-e04335b26df9">
   because running interpreter under system user gives too wide permissions in my case. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org