-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Allow custom SSH user in UI for built-in SSH server (#2617) #2678
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2678 +/- ##
==========================================
- Coverage 27.38% 27.38% -0.01%
==========================================
Files 86 86
Lines 17010 17014 +4
==========================================
+ Hits 4658 4659 +1
- Misses 11673 11675 +2
- Partials 679 680 +1
Continue to review full report at Codecov.
|
LGTM |
It's not format well |
@lunny You mean I need to run gofmt? |
@geek1011 You can use |
Shouldn't that user be verified in the builtin ssh-server as well? |
@bkcsoft no, that would introduce compatibility issues and an unnecessary check. The SSH user for the built-in SSH server has no real meaning. |
I did make fmt. |
Can this be merged now? |
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.
Some suggestions
modules/setting/setting.go
Outdated
@@ -720,6 +722,8 @@ func NewContext() { | |||
SSH.StartBuiltinServer = false | |||
} | |||
|
|||
SSH.BuiltinServerUser = sec.Key("BUILTIN_SSH_USER").MustString("") |
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.
Can this be changed to SSH.BuiltinServerUser = sec.Key("BUILTIN_SSH_USER").MustString(RunUser)
?
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 set to the runuser if blank a bit further down. I cannot combine them because this one requires the server sec variable, and the runuser is set further down. (Line 922)
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, I saw that line. Can you move this setup line down as BuiltinSSHServerUser
is not used between lines 725 and 922?
modules/setting/setting.go
Outdated
@@ -104,6 +105,7 @@ var ( | |||
}{ | |||
Disabled: false, | |||
StartBuiltinServer: false, | |||
BuiltinServerUser: "", |
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.
Why setting default string value?
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'll remove that.
conf/app.ini
Outdated
@@ -113,6 +113,8 @@ LOCAL_ROOT_URL = %(PROTOCOL)s://%(HTTP_ADDR)s:%(HTTP_PORT)s/ | |||
DISABLE_SSH = false | |||
; Whether use builtin SSH server or not. | |||
START_SSH_SERVER = false | |||
; Username to use for builtin SSH server. If blank, then it is the value of RUN_USER. | |||
BUILTIN_SSH_USER = |
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.
IMO is better to use name like BUILTIN_SSH_SERVER_USER
.
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.
Should I change it?
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 have changed it.
- Renamed config to BUILTIN_SSH_SERVER_USER - Removed unnecessary default string value for config item
modules/setting/setting.go
Outdated
@@ -915,6 +918,10 @@ func NewContext() { | |||
} | |||
} | |||
|
|||
if SSH.BuiltinSSHServerUser == "" { | |||
SSH.BuiltinSSHServerUser = RunUser |
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.
Couldn't we do simply SSH.BuiltinSSHServerUser = sec.Key("BUILTIN_SSH_USER").MustString(RunUser) here ?
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.
@sapk That's my question :D
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.
@Morlinest sorry I haven't look at others reviews. just quickly look at it ^^
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.
So my code is fine?
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 we suggest is that you move (and add the RunUser as default) L724 SSH.BuiltinSSHServerUser = sec.Key("BUILTIN_SSH_USER").MustString(RunUser)
in place of L921-924
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.
@sapk It cannot happen because sec is redefined in between those spots. That's why I have the two lines.
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.
Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
?
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.
@Morlinest I didn't know about that one. Thanks. I'll try it.
@sapk @Morlinest I have updated according to your review. |
modules/setting/setting.go
Outdated
@@ -915,6 +916,8 @@ func NewContext() { | |||
} | |||
} | |||
|
|||
SSH.BuiltinSSHServerUser = Cfg.Section("server").Key("BUILTIN_SSH_USER").MustString(RunUser) |
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.
BUILTIN_SSH_SERVER_USER
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.
Oops
modules/setting/setting.go
Outdated
@@ -90,6 +90,7 @@ var ( | |||
SSH = struct { | |||
Disabled bool `ini:"DISABLE_SSH"` | |||
StartBuiltinServer bool `ini:"START_SSH_SERVER"` | |||
BuiltinSSHServerUser string `ini:"BUILTIN_SSH_SERVER_USER"` |
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.
Idea: What about changing BuiltinSSHServerUser
to BuiltinServerUser
. Then reading config inside go setting.SSH.BuiltinServerUser
. Also "builtin" word can be removed so it would be more consistent with other ssh settings. What do you think?
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'll remove the SSH from the var name. Since this user only applies to the internal server, I'll keep the Builtin
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.
Good point. The last thing: SSH_BUILTIN_SERVER_USER
instead of BUILTIN_SSH_SERVER_USER
?
@Morlinest should be fixed now. |
@Morlinest need your approval |
@lafriks Waiting for response (last thing), I think |
@Morlinest how many times do you have to change your mind? |
@Morlinest I think current is better as SSH_BUILTIN_SERVER_USER does not sound correct in English |
@lafriks I meant |
@geek1011 I was asking about another idea after accepting your opinion. I don't see anything bad on it. |
@lafriks Same as |
@Morlinest not really: |
@lafriks OK, I accept your interpretation. LGTM |
Make LG-TM work again |
This allows a custom username to be set for the built-in SSH server.
It adds the config option
BUILTIN_SSH_USER
in the[server]
section. If this option is missing or empty, it defaults to theRUN_USER
(which was the default before), and it it is present and the built-in SSH server is enabled, then it uses the custom user for the built-in SSH server.This does not introduce any compatibility issues with old versions.
I have tested this feature.
See issue #2617