artyom-poptsov / guile-ssh

Guile-SSH is a library that provides access to the SSH protocol for GNU Guile programs.
https://memory-heap.org/~avp/projects/guile-ssh
GNU General Public License v3.0
65 stars 13 forks source link

session.scm test fails with libssh 0.7.5 #4

Closed lantw44 closed 7 years ago

lantw44 commented 7 years ago
PASS: log.scm
PASS: server.scm
FAIL: session.scm
PASS: client-server.scm
PASS: popen.scm
PASS: shell.scm
PASS: server-client.scm
PASS: sssh-ssshd.scm
PASS: key.scm
FAIL: tunnel.scm
PASS: dist.scm
============================================================================
Testsuite summary for Guile-SSH 0.11.1
============================================================================
# TOTAL: 11
# PASS:  9
# SKIP:  0
# XFAIL: 0
# FAIL:  2
# XPASS: 0
# ERROR: 0
============================================================================
See tests/test-suite.log
Please report to poptsov.artyom@gmail.com
============================================================================

The failing test is session-parse-config! in session.scm.

Test begin:
  test-name: "session-parse-config!"
Test end:
  result-kind: fail
  actual-value: #f

This problem doesn't occur when running guile-ssh with libssh 0.7.4.

sexptherapy commented 7 years ago

I can reproduce this error under Arch with libssh 0.7.5-1.

artyom-poptsov commented 7 years ago

Hello,

I investigated the issue and it seems to me that libssh 0.7.5 (and the version from the master branch as well) has an issue with config file reading; and thus Guile-SSH session-parse-config! fails too. I've prepared a patch and sent it to the libssh developers mailing list. Let's see if it pass the libssh developer's review.

Meanwhile here's the patch (tested with abbd6e304ae5e678766f1c97012cb53c12757d96 commit on master branch in the libssh repository):

From 6a8bd601852765c0b1f6cab72bff25056cfbd8b4 Mon Sep 17 00:00:00 2001
From: "Artyom V. Poptsov" <poptsov.artyom@gmail.com>
Date: Sun, 4 Jun 2017 11:54:55 +0300
Subject: [PATCH] config: Bugfix: Don't skip unseen opcodes

libssh fails to read the configuration from a config file due to a
wrong check in 'ssh_config_parse_line' procedure in 'config.c'; it's
effectively skipping every opcode (and therefore every option) from
the file.  The change fixes that behaviour.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
---
 src/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/config.c b/src/config.c
index 6478fc5f..ae7e48d7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -219,7 +219,7 @@ static int ssh_config_parse_line(ssh_session session, const char *line,

   opcode = ssh_config_get_opcode(keyword);
   if (*parsing == 1 && opcode != SOC_HOST) {
-      if (seen[opcode] == 0) {
+      if (seen[opcode]) {
           return 0;
       }
       seen[opcode] = 1;
-- 
2.13.0

Thanks!

Artyom.

artyom-poptsov commented 7 years ago

Hello,

my libssh patch was accepted by libssh developers, so the next libssh release should include the fix.

I'm closing the issue.

Artyom.