aboutsummaryrefslogtreecommitdiff
path: root/libssh/client.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-07-28 11:47:53 +0200
committerAndreas Schneider <mail@cynapses.org>2009-07-28 13:25:26 +0200
commit69ceaae9a9f69dba11ab01889da5b41cb1487896 (patch)
treef32840e6c682e101107b2be40d64832e9c88da4f /libssh/client.c
parent1abdb28995fa5db61af7f385abf078c9b58fd843 (diff)
downloadlibssh-69ceaae9a9f69dba11ab01889da5b41cb1487896.tar.gz
libssh-69ceaae9a9f69dba11ab01889da5b41cb1487896.tar.xz
libssh-69ceaae9a9f69dba11ab01889da5b41cb1487896.zip
Check for OpenSSH and implement sftp_symlink correct.
When OpenSSH's sftp-server was implemented, the order of the arguments to the SSH_FXP_SYMLINK method was inadvertently reversed. Unfortunately, the reversal was not noticed until the server was widely deployed. Since fixing this to follow the specification would cause incompatibility, the current order was retained.
Diffstat (limited to 'libssh/client.c')
-rw-r--r--libssh/client.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/libssh/client.c b/libssh/client.c
index acccd146..cbc70e31 100644
--- a/libssh/client.c
+++ b/libssh/client.c
@@ -98,7 +98,10 @@ char *ssh_get_banner(SSH_SESSION *session) {
* @see ssh_get_banner()
*/
static int ssh_analyze_banner(SSH_SESSION *session, int *ssh1, int *ssh2) {
- char *banner = session->serverbanner;
+ const char *banner = session->serverbanner;
+ const char *openssh;
+
+ ssh_log(session, SSH_LOG_RARE, "Analyzing banner: %s", banner);
if (strncmp(banner, "SSH-", 4) != 0) {
ssh_set_error(session, SSH_FATAL, "Protocol mismatch: %s", banner);
@@ -129,6 +132,17 @@ static int ssh_analyze_banner(SSH_SESSION *session, int *ssh1, int *ssh2) {
return -1;
}
+ openssh = strstr(banner, "OpenSSH");
+ if (openssh != NULL) {
+ int major, minor;
+ major = strtol(openssh + 8, (char **) NULL, 10);
+ minor = strtol(openssh + 10, (char **) NULL, 10);
+ session->openssh = SSH_VERSION_INT(major, minor, 0);
+ ssh_log(session, SSH_LOG_RARE,
+ "We are talking to an OpenSSH server version: %d.%d (%x)",
+ major, minor, session->openssh);
+ }
+
return 0;
}
@@ -616,6 +630,24 @@ char *ssh_get_issue_banner(SSH_SESSION *session) {
}
/**
+ * @brief Get the version of the OpenSSH server, if it is not an OpenSSH server
+ * then 0 will be returned.
+ *
+ * You can use the SSH_VERSION_INT macro to compare version numbers.
+ *
+ * @param session The SSH session to use.
+ *
+ * @return The version number if available, 0 otherwise.
+ */
+int ssh_get_openssh_version(ssh_session session) {
+ if (session == NULL) {
+ return 0;
+ }
+
+ return session->openssh;
+}
+
+/**
* @brief Disconnect from a session (client or server).
*
* @param session The SSH session to disconnect.