Skip to content

Commit

Permalink
ssh/session.scm (make-session): Fix "#:config" handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
artyom-poptsov committed Nov 1, 2024
1 parent 1c01f8f commit 88c9a89
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
9 changes: 9 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ This change affects the following procedures from =(ssh popen)=:

Reported by graywolf in
<https://github.com/artyom-poptsov/guile-ssh/issues/39>
** =make-session= now handles =#:config= set to =#f= properly
Now =make-session= disables reading the default SSH configuration files when
=#:config= is set to =#f= (as per Guile-SSH documentation.)

When =#:config= is set to =#t= then the default SSH configuration files are
read. This is by default to keep the backward compatibility.

Reported by graywolf in
<https://github.com/artyom-poptsov/guile-ssh/issues/38>
** New simplified version of the project logo
Thanks to Darya Sev. <sdarsy@ya.ru> for very helpful design advices for the
new simplified version of the project logo.
Expand Down
7 changes: 7 additions & 0 deletions doc/api-sessions.texi
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ be ``yes'', ``no'' or a specific algorithm name if needed ("zlib",
@verb{|"zlib@openssh.com"|}, "none").

Expected type of @var{value}: string.
@item process-config?
Set it to @code{#f} to disable automatic processing of per-user and
system-wide OpenSSH configuration files. LibSSH automatically uses these
configuration files unless you provide it with this option or with different
file.

Expected type of @var{value}: boolean.
@item proxycommand
Set the command to be executed in order to connect to server.

Expand Down
2 changes: 2 additions & 0 deletions libguile-ssh/session-func.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ static gssh_symbol_t session_options[] = {
{ "stricthostkeycheck", SSH_OPTIONS_STRICTHOSTKEYCHECK },
{ "compression", SSH_OPTIONS_COMPRESSION },
{ "compression-level", SSH_OPTIONS_COMPRESSION_LEVEL },
{ "process-config?", SSH_OPTIONS_PROCESS_CONFIG },

#if HAVE_LIBSSH_0_8_1
{ "nodelay", SSH_OPTIONS_NODELAY },
Expand Down Expand Up @@ -384,6 +385,7 @@ set_option (SCM scm_session, gssh_session_t* sd, int type, SCM value)
case SSH_OPTIONS_SSH1:
case SSH_OPTIONS_SSH2:
case SSH_OPTIONS_STRICTHOSTKEYCHECK:
case SSH_OPTIONS_PROCESS_CONFIG:
#if HAVE_LIBSSH_0_8_1
case SSH_OPTIONS_NODELAY:
#endif
Expand Down
26 changes: 14 additions & 12 deletions modules/ssh/session.scm
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,27 @@
knownhosts timeout timeout-usec ssh1 ssh2 log-verbosity
ciphers-c-s ciphers-s-c compression-c-s compression-s-c
proxycommand stricthostkeycheck compression
compression-level nodelay callbacks config
compression-level nodelay callbacks (config #t)
public-key-accepted-types)
"Make a new SSH session with specified configuration.\n
Return a new SSH session."
(let ((session (%make-session)))

(session-set-if-specified! host)

(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))))
(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)
(%gssh-session-parse-config! session #f))
(else
(throw 'guile-ssh-error "Wrong 'config' value" config))))
(session-set! session 'process-config? #f))

(session-set-if-specified! port)
(session-set-if-specified! user)
Expand Down

0 comments on commit 88c9a89

Please sign in to comment.