don't fail upon error while chdir()ing *before* loading config #3237
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.
When gunicorn is invoked by
root
using# su -m <nonprivileged_user> -c gunicorn --config <absolute_path_to_config_file> --chdir <some_world_accessible_directory>
, the following sequence of steps occurs:su
runsgunicorn
as the<nonprivileged_user>
, BUT withPWD=/root
due to the-m
flagPWD
envvar (QUESTION: is this the right behaviour? It seems to me thatgunicorn
should just useos.getcwd()
every time.)cfg.chdir = <some_world_accessible_directory>
, but hasn't yet setself.cfg = cfg
self.chdir: ERROR: permission denied
after trying tochdir()
to/root
This patch makes this event a warning instead of a failure and continues onwards with searching for the config file. Afterwards, we will
chdir()
to the correct user-configured location as normal.