[SPARK-43368] Use libnss_wrapper to fake passwd entry
#45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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