-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[WIP] Rootless docker #7129
[WIP] Rootless docker #7129
Conversation
@@ -1,5 +1,6 @@ | |||
#!/bin/bash | |||
|
|||
#TODO maybe /data/git/.ssh not needed anymore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If docker user internal SSH server, it's not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it is not needed for the single process setup, removing it would break existing setups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@das7pad yes but it is for the setup part so if we don't need it anymore we don't need to create it if it doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For folks who backup the entire /data/git directory it is not a problem. But for those who just backup non-generated files, read only the repositories directory, the .ssh directory would be missing upon restore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the internal sshserver doesn't use the .ssh directory...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the third example in #7129 (review).
I know that the files in the .ssh directory are only needed to get the spawned sshd-childs talk with the correct gitea instance.
Codecov Report
@@ Coverage Diff @@
## master #7129 +/- ##
==========================================
- Coverage 41.57% 41.57% -0.01%
==========================================
Files 446 446
Lines 60848 60841 -7
==========================================
- Hits 25299 25295 -4
+ Misses 32265 32264 -1
+ Partials 3284 3282 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks almost every usage of the docker image.
Some broken usage examples:
- all of the 'official' docker-compose configs
https://docs.gitea.io/en-us/install-with-docker/ docker run -d -p 80:3000 -p 2222:22 gitea/gitea
- running sshd in the container to get the gitea binary
- run gitea with git user
- run sshd with root
if ! [[ $(ls -ld /data/git | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/git; fi | ||
chmod 0755 /data/gitea /app/gitea /data/git | ||
chmod 0755 /data/gitea /data/git | ||
#chmod 0755 /app/gitea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/app/gitea
is owned by root.
#chmod 0755 /app/gitea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and I don't think it is a problem. I will recheck but that a good point that the process inside the containre couldn't change content inside /app/gitea
models/ssh_key.go
Outdated
return "", errors.New("not enough output for calculating fingerprint: " + stdout) | ||
} | ||
return strings.Split(stdout, " ")[1], nil | ||
return ssh.FingerprintSHA256(pk), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be an unrelated change. Can we move the change into a new PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a needed change because openssh does un-needed system check (that fail in this configuration with --user flag) for calculating the fingerprint of the key. I allready separate this in an other PR #7128
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What system check is failing for you?
I setup a test with alpine and the --user
flag, but can not see any error.
https://gist.github.com/das7pad/62b58bfb67da516542992d8bf5744446
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you pass an uid/gid (numerical) that doesn't exist inside the container it should failed.
modules/setting/setting.go
Outdated
@@ -436,7 +436,7 @@ func forcePathSeparator(path string) { | |||
// This check is ignored under Windows since SSH remote login is not the main | |||
// method to login on Windows. | |||
func IsRunUserMatchCurrentUser(runUser string) (string, bool) { | |||
if IsWindows { | |||
if IsWindows || SSH.StartBuiltinServer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be a bug fix? Let's move it into a new PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #7215
@@ -1,5 +1,6 @@ | |||
#!/bin/bash | |||
|
|||
#TODO maybe /data/git/.ssh not needed anymore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it is not needed for the single process setup, removing it would break existing setups.
How about adding a new image variant for the proposed changes? For example This would allow any existing deployment to stay as is. And folks which require additional hardening of the container can use the new variant. With a reasonable delay we can eventually swap the default tag: |
@das7pad the docs will need to be updated to follow some changed needed to the run command in some cases but it should be able to reuse the same data folder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual ownership changes to the ssh directory in the data volume are needed.
|
||
chown root:root /data/ssh/* | ||
chmod 0700 /data/ssh | ||
chmod 0600 /data/ssh/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ssh-hostkeys are owned by root and locked down to root only read access. The internal ssh-server will not be able to read them as git user.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions. |
Rather than try and maintain/rebase this separate branch, would it be easier to:
|
@westurner I would suggest more to define a rootless tagged image that could become the main later but would ease the transition and allow us to break some pattern existing in the current image. |
I like this idea. When the rootless image is working (i.e. two months without new issues on the rootless image) the 'legacy root' image could show a warning in the frontend (i.e. |
Yes and this transition duration would help us write a migration guide (like changing owner, possible change of key signature of ssh server, ...) |
I will send another PR that will replace this one for a image tagged rootless |
The fixes related to help remove external deps (openssh) are already merged (in separe PR) and the rootless part of this PR is moved to a new PR (non breaking by using an other tag -rootless) |
Following #4749
Currently work with the default user git pid (1000)
The main blocking adjustment to use the --user docker flag to adjust running user is various check of the user by gitea but also by sub process like ssh-keygen in #7128