Fix ~git/.ssh/environment file owner problem using in docker. #7597
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.
Describe the pull request
I thought that you want to use
gosu "$USER" echo "GOGS_CUSTOM=${GOGS_CUSTOM}" > ~git/.ssh/environment
to create a ~git/.ssh/environment file owned by $USER and then write something to it when the s6 boots gogs service in a docker container. This gosu command is located in here.But this command will actually create a ~git/.ssh/environment file owned by root:root. Because on the right side of the pip, the ~git/.ssh/environment is actually created by the current user (root), not $USER.
To have it the right owner (maybe git:git) the file should be
touch
(created) by $USER before use it. That is what I do.Link to the issue: n/a
Checklist
Test plan
You can test the code inside a gogs docker container by running these bash commands:
Below is what I tested:
Besides, inside the same container, you can find the ~git/.ssh/environment file is owned by root:root
ls -l ~git/.ssh/environment
.