Skip to content
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

Fix ~git/.ssh/environment file owner problem using in docker. #7597

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lliding
Copy link

@lliding lliding commented Nov 11, 2023

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

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code or have provided the test plan.

Test plan

You can test the code inside a gogs docker container by running these bash commands:

USER=git
gosu "$USER" touch ~git/.ssh/environment_test
gosu "$USER" echo "GOGS_CUSTOM=${GOGS_CUSTOM}" > ~git/.ssh/environment_test

Below is what I tested:

ba2e12b10e0f:/data/git# USER=git
ba2e12b10e0f:/data/git# gosu "$USER" touch ~git/.ssh/environment_test
ba2e12b10e0f:/data/git# gosu "$USER" echo "GOGS_CUSTOM=${GOGS_CUSTOM}" > ~git/.ssh/environment_test
ba2e12b10e0f:/data/git# ls -l ~git/.ssh/environment_test 
-rw-r--r--    1 git      git             23 Nov 11 16:09 /data/git/.ssh/environment_test

Besides, inside the same container, you can find the ~git/.ssh/environment file is owned by root:root ls -l ~git/.ssh/environment.

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.

None yet

1 participant