From 4697b40c0dbe040bc599580d127de842bbb740fb Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Fri, 21 Feb 2025 14:24:48 -0500 Subject: [PATCH] libssh2: Print user with verbose flag This change: - Breaks out the existing print out of the LIBSSH2_DEBUG compile-time flag - Adds (single) quotation marks around the string to better expose the actual value - Adds a NULL print, mirroring other verbose prints in libssh2 Why was this done? I was trying out the `sftp` option in `curl`, and found myself hitting an issue where I was not able to get curl to tell me which username it was using to connect to a host. With this change, the `User: ` line is printed with `-v`, just like other SSH verbose prints. Instead of using the pattern used with *SSH MD5 public key*, where a ternary is used to print `NULL` on NULL values, it is using a different branch to add quotes around the string value. The quotes around the string value are used to better expose to the user an empty string value, compared to "no-value". --- lib/vssh/libssh2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 304c9fa69f..3b4fd80cda 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -3167,10 +3167,13 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done) sshc = &conn->proto.sshc; -#ifdef CURL_LIBSSH2_DEBUG if(conn->user) { - infof(data, "User: %s", conn->user); + infof(data, "User: '%s'", conn->user); } + else { + infof(data, "User: NULL"); + } +#ifdef CURL_LIBSSH2_DEBUG if(conn->passwd) { infof(data, "Password: %s", conn->passwd); }