[SPARK-43368] Use libnss_wrapper to fake passwd entry#45
[SPARK-43368] Use libnss_wrapper to fake passwd entry#45Yikun wants to merge 1 commit intoapache:masterfrom
libnss_wrapper to fake passwd entry#45Conversation
Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
|
cc @yosifkit Thanks for the solution! |
|
@HyukjinKwon @pan3793 Thanks, I will merge this soon. |
|
Merged. |
|
Hi @Yikun, Have you also tested your commands for the home directory? I tested the home directory with the following small Java class. I don't know how Spark evaluates this. The output of the small program returns the following, which is obviously incorrect. Is there a reason to evaluate the GECOS field later? |
|
Pull Request with a possible fix. #90 |
What changes were proposed in this pull request?
Use
libnss_wrapperto fake passwd entry instead of changing passwd to resolve random UID problem. And also we only attempt to setup fake passwd entry for driver/executor, but for cmd likebash, the fake passwd will not be set.Why are the changes needed?
In the past, we add the entry to
/etc/passwddirectly for current UID, it's mainly for OpenShift anonymous randomuidcase (See also in apache-spark-on-k8s/spark#404), but this way bring the pontential security issue about widely permision of/etc/passwd.According to DOI reviewer suggestion, we'd better to resolve this problem by using libnss_wrapper. It's a library to help set a fake passwd entry by setting
LD_PRELOAD,NSS_WRAPPER_PASSWD,NSS_WRAPPER_GROUP. Such as random UID is1000, the env will be:Does this PR introduce any user-facing change?
Yes, setup fake ENV rather than changing
/etc/passwd.How was this patch tested?
1. Without
attempt_setup_fake_passwd_entry, the user isI have no name!2. Mannual stub the
attempt_setup_fake_passwd_entry, the user isspark.2.1 Apply a tmp change to cmd
2.2 Build and run the image, specify a random UID/GID 1000
3. If specify current exsiting user (such as
spark,root), no fake setup