Skip to content

Enable the custom entrypoint script support added in #1964 to be run as root. #2039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

AkashiSN
Copy link

In #1964, the scripts were executed as $user by run_as, but for example, new packages could not be added with apt because they lacked root privileges.

Therefore, I have made changes to ensure that the custom scripts are executed with root privileges.

Also, as pointed out in the comments at #r1191243057, I have made sure that the custom scripts are executed with /bin/bash, even when they do not have execution permissions.

For example, when using a custom script in a k8s configmap, it is not possible to assign execution permissions, and chmod cannot be used because it is mounted as ReadOnly. There are cases where it is difficult to assign execution permissions, even when you want to add a custom script.

Ideally, I wanted to do . script(sourcing) like in docker-library/postgres#452, but since entrypoint.sh is executed with /bin/sh, I decided to launch a new /bin/bash shell and execute it for the sake of extensibility.

Additionally, for cases where you want to execute as the nextcloud user, I've made it so that you can reference:

user=$user /bin/bash "${script_file_path}"

inside the custom script with:

run_as() {
  su -p $user -s /bin/sh -c "$1"
}

My apologies for any awkward English as I am not a native speaker.

Best Regards.

@AkashiSN AkashiSN marked this pull request as ready for review July 26, 2023 14:33
Signed-off-by: AkashiSN <btorntireinvynriy@gmail.com>
@AkashiSN
Copy link
Author

AkashiSN commented Aug 5, 2023

As per #1964 (comment), this hook script is not intended to install packages and is running on www-data, so close this PR.

@AkashiSN AkashiSN closed this Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant