-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
The #:port seems to be ignored #38
Comments
Hello! Thank you for the bug report. I investigated the problem I came to conclusion that it's because currently the config file is being read after the options are set: guile-ssh/modules/ssh/session.scm Line 111 in 7b27597
So even though you provide I think that we must read the config first and then set the provided options. I'll see what I can do. -avp |
As a workaround you can try to set the guile-ssh/modules/ssh/session.scm Line 105 in 7b27597
|
'make-session' would always overwrite the explicitly set options passed by keywords with the values from the SSH configuration file. That lead to unexpected behavior. This patch fixes this error. Reported by graywolf in <#38> * modules/ssh/session.scm (make-session): Bugfix: Set the '#:host' option first, then read the SSH configuration and only after that set the other options.
The issue is fixed in the latest release. Thanks! |
Hello, thanks for the fix, however I am not sure it works. I have ran it with
As you can see, it still tries to connect to 2222. Also, looking closer at the code, the `config' should be #f anyway, so the whole moved block (when config ...) should not even trigger. And when I check the strace output, I can see the ~/.ssh/config file being opened for reading. So it is probably coming from somewhere else? The commit is (in my opinion) still desired for situations with config being non-#f, but it does not seem to address this particular issue. Or I am doing something wrong, also possible. EDIT: When I pass |
I think https://github.com/libssh/libssh-mirror/blob/ac6d2fad4a8bf07277127736367e90387646363f/src/options.c#L1472 is the cause why |
This seems to work? Sorry for the formatting, |
As far as I can tell
As such, having But your attempt to solve the problem helped me to find another bug: currently there's no way to set config to What is interesting with current situation is that when |
Albeit that might be the intention, it is not obvious from the documentation:
My understanding of One option I guess would be to change the default value to PS: The documentation snippet above still says
should I open another bug? I feel like I am spamming you enough already. :)
This seems to be a misunderstanding, as I said above: |
Okay, that's a good point. The documentation needs to be fixed. But maybe we can improve the API as follows:
What do you think?
Yeah, it seems that was my intention back then when I implemented
I think it's fine to use this bug to discuss the documentation changes related to BTW, I just fixed (d56fb10) a bug in a test that checks if options passed to
The configuration file contains port number 2222 but |
On 2024-05-05 09:15:12 -0700, Artyom V. Poptsov wrote:
> Albeit that might be the intention, it is not obvious from the documentation:
Okay, that's a good point. The documentation needs to be fixed.
But maybe we can improve the API as follows:
- `#:process-config #f` disables reading of any configuration files altogether as it works in libssh.
What will be the behavior when called with `#:process-config #f #:config 'default`?
I wonder whether we actually need separate keyword (#:process-config) or the
#:config would cover everything via the cases below.
Naming nitpick: I am pretty new to Guile, but should the name not be
`#:process-config?`?
- `#:config "/dev/null"` or `#:config #f` means the same thing -- no user configuration file should be read.
It is not obvious from this proposal whether that is the case, so I will just
note that I do not think string "/dev/null" should have a special meaning. It
will work to suppress the configuration reading, same like it does now, but
should not get special handling.
- `#:config 'default` reads the default user configuration file (`~/.ssh/config`.)
I personally would prefer #t to 'default, it is shorter. But if you prefer the
symbol, maybe at least both ('default and #t) could be allowed?
I guess for backward compatibility this needs to be default (no pun intended)
value of #:config. Do you think someone passes in #f explicitly in their code?
- `#:config "/path/to/config"` specifies a config file to read.
What do you think?
I like it ^_^ Just the comments above.
> PS: The documentation snippet above still says
Yeah, it seems that was my intention back then when I implemented `make-session`. But you're right, the options passed to `make-session` should overwrite the options from the config, it is more logical.
> should I open another bug? I feel like I am spamming you enough already. :)
I think it's fine to use this bug to discuss the documentation changes related to `make-session` as well. Thanks for helping!
You are welcome. More like, thank you for writing this library. I was putting
together a Guile-based server installer script and guile-ssh was of immense
help.
Cheers,
Tomas
…--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
|
Hello! Sorry for the late answer.
Agreed, we should keep backward compatibility where it's possible. But currently there's a problem in config-handling code in Guile-SSH:
So maybe we should go with the following:
That means that instead of (when config
(or host
(throw 'guile-ssh-error
"'config' is specified, but 'host' option is missed."))
(cond
((string? config)
(%gssh-session-parse-config! session config))
((boolean? config)
(%gssh-session-parse-config! session #f))
(else
(throw 'guile-ssh-error "Wrong 'config' value" config)))) we will do something like this (as you proposed): (if config
(begin
(or host
(throw 'guile-ssh-error
"'config' is specified, but 'host' option is missed."))
(cond
((string? config)
(%gssh-session-parse-config! session config))
((boolean? config) ; set to #t
(%gssh-session-parse-config! session #f))
(else
(throw 'guile-ssh-error "Wrong 'config' value" config))))
(session-set! session 'process-config? #f)) Does this sound right? By the way, I see that you've been quite active in Guile-SSH recently with several useful bug reports. Do you want to participate in Guile-SSH development more directly? You could start with a pull request to one of your issues, and then we'll see -- maybe I could give you the commit access. Thanks! |
This patch fixes "make-session" procedure to make it handle "#:config" option according to the Guile-SSH documentation. That is, passing "#f" as the "#:config" value disables reading the default SSH documentation. Reported by graywolf in <#38> * modules/ssh/session.scm (make-session): Fix "#:config" handling: disable default configuration reading when set to "#f" as per Guile-SSH documentation. Use "#t" as the default value to keep the backward compatibility. * libguile-ssh/session-func.c (session_options): Add SSH_OPTIONS_PROCESS_CONFIG. (set_option): Handle SSH_OPTIONS_PROCESS_CONFIG. * doc/api-sessions.texi: Update. * NEWS: Update.
I pushed the proposed fix to the branch 38-the-port-seems-to-be-ignored. -avp |
This patch fixes "make-session" procedure to make it handle "#:config" option according to the Guile-SSH documentation. That is, passing "#f" as the "#:config" value disables reading the default SSH documentation. Reported by graywolf in <#38> * modules/ssh/session.scm (make-session): Fix "#:config" handling: disable default configuration reading when set to "#f" as per Guile-SSH documentation. Use "#t" as the default value to keep the backward compatibility. * libguile-ssh/session-func.c (session_options): Add SSH_OPTIONS_PROCESS_CONFIG. (set_option): Handle SSH_OPTIONS_PROCESS_CONFIG. * doc/api-sessions.texi: Update. * NEWS: Update.
* modules/ssh/session.scm (make-session): Don't try to set "parse-config?" option when libssh version is older than 0.9. Log a message and fallback to the old Guile-SSH behavior instead (see <#38>.)
This issue should be fixed in the new Guile-SSH release. |
Hello,
I am trying to deploy using guix deploy (which under the hood uses guile-ssh), and it seems the #:port argument to (make-session) is ignored. I managed to reproduce it even without guix, the steps follow.
I have this in my ~/.ssh/config:
However, on specific host I am deploying to the sshd is still running on 22. I can connect fine using the ssh command (ssh -4 -p22 ...). Using strace I see this line:
However when I try to do the same using guile-ssh:
I see this instead:
Notice that sin_port is set to the value from ~/.ssh/config instead of what I passed in #:port.
The text was updated successfully, but these errors were encountered: