Fixed ssh crash when username in URI is null
This commit is contained in:
parent
1a523d04ef
commit
804b83769f
@ -34,8 +34,15 @@ class GRemoteSession @Inject constructor(
|
||||
fun setup(uri: URIish) {
|
||||
val session = processSession.get()
|
||||
session.setOptions(LibSshOptions.SSH_OPTIONS_HOST, uri.host)
|
||||
session.setOptions(LibSshOptions.SSH_OPTIONS_USER, uri.user)
|
||||
session.setOptions(LibSshOptions.SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES, "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss")
|
||||
|
||||
uri.user?.let {
|
||||
session.setOptions(LibSshOptions.SSH_OPTIONS_USER, uri.user)
|
||||
}
|
||||
|
||||
session.setOptions(
|
||||
LibSshOptions.SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES,
|
||||
"ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss"
|
||||
)
|
||||
session.loadOptionsFromConfig()
|
||||
|
||||
session.connect()
|
||||
|
@ -17,7 +17,7 @@ class LibSshSession @Inject constructor() {
|
||||
}
|
||||
|
||||
fun loadOptionsFromConfig() {
|
||||
checkValidResult(sshLib.ssh_options_parse_config(session, null))
|
||||
checkValidResult("loadOptionsFromConfig", sshLib.ssh_options_parse_config(session, null))
|
||||
}
|
||||
|
||||
fun connect() {
|
||||
|
@ -20,7 +20,7 @@ class LibSshChannelOutputStream(private val sshChannel: ssh_channel) : OutputStr
|
||||
}
|
||||
}
|
||||
|
||||
fun checkValidResult(result: Int) {
|
||||
fun checkValidResult(tag: String, result: Int) {
|
||||
if (result != 0)
|
||||
throw Exception("Result is $result")
|
||||
throw Exception("$tag - Result is $result")
|
||||
}
|
Loading…
Reference in New Issue
Block a user