Skip to content

Commit

Permalink
tests/session.scm (make-session): Improve
Browse files Browse the repository at this point in the history
* tests/session.scm (make-session): Set the config to "/dev/null" when #f is
used as the value for "#:config" to prevent the reading of default
configuration files on older version of libssh (prior 0.9.)
* modules/ssh/session.scm ("make-session, '#:config' set to '/dev/null'"):
New test case.
  • Loading branch information
artyom-poptsov committed Nov 10, 2024
1 parent 4d51a86 commit a9f697c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 12 additions & 9 deletions modules/ssh/session.scm
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ Return a new SSH session."
(let ((libssh-minor-version (get-libssh-minor-version)))
(if (>= libssh-minor-version 9)
(session-set! session 'process-config? #f)
(format-log 'rare
'make-session
(string-append
"process-config? option is not available"
" (using libssh 0.~a.)"
" Falling back to the old Guile-SSH behavior "
" (no config setting.)"
" See <https://github.com/artyom-poptsov/guile-ssh/issues/38>.")
libssh-minor-version))))
(begin
(format-log 'rare
'make-session
(string-append
"process-config? option is not available"
" (using libssh 0.~a.)"
" Falling back to setting the config to"
" '/dev/null' to prevent reading the default"
" configuration files."
" See <https://github.com/artyom-poptsov/guile-ssh/issues/38>.")
libssh-minor-version)
(%gssh-session-parse-config! session "/dev/null")))))

(session-set-if-specified! port)
(session-set-if-specified! user)
Expand Down
4 changes: 4 additions & 0 deletions tests/session.scm
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@
(make-session #:host "localhost"
#:config %config))

(test-assert "make-session, '#:config' set to '/dev/null'"
(make-session #:host "localhost"
#:config "/dev/null"))

;; Setting '#:config' option to #f must set "process-config?" option to #f.
(test-assert "make-session, '#:config' as a boolean value: #f"
(make-session #:host "localhost"
Expand Down

0 comments on commit a9f697c

Please sign in to comment.