summaryrefslogtreecommitdiff
path: root/lib/ssh.c
diff options
context:
space:
mode:
authormarquis-de-muesli <marquis.de.muesli@gmail.com>2016-02-23 23:18:31 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-03-27 17:52:16 +0200
commitf9d27e0f8e27881b8939d28dc402fb5ba9d1ded2 (patch)
treed440df399c4e06d58920b3705cecf7ef17eb8e1f /lib/ssh.c
parente32644851a4a8126fc6d6b21ff191ffa7867363e (diff)
downloadcurl-f9d27e0f8e27881b8939d28dc402fb5ba9d1ded2.tar.gz
SSH: support CURLINFO_FILETIME
Diffstat (limited to 'lib/ssh.c')
-rw-r--r--lib/ssh.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index e63446bed..d9a47be8e 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -362,6 +362,8 @@ static void state(struct connectdata *conn, sshstate nowstate)
"SSH_SFTP_QUOTE_RENAME",
"SSH_SFTP_QUOTE_RMDIR",
"SSH_SFTP_QUOTE_UNLINK",
+ "SSH_SFTP_GETINFO",
+ "SSH_SFTP_FILETIME",
"SSH_SFTP_TRANS_INIT",
"SSH_SFTP_UPLOAD_INIT",
"SSH_SFTP_CREATE_DIRS_INIT",
@@ -1183,7 +1185,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
state(conn, SSH_SFTP_QUOTE);
}
else {
- state(conn, SSH_SFTP_TRANS_INIT);
+ state(conn, SSH_SFTP_GETINFO);
}
break;
@@ -1372,7 +1374,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
}
}
if(!sshc->quote_item) {
- state(conn, SSH_SFTP_TRANS_INIT);
+ state(conn, SSH_SFTP_GETINFO);
}
break;
@@ -1391,7 +1393,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->nextstate = SSH_NO_STATE;
}
else {
- state(conn, SSH_SFTP_TRANS_INIT);
+ state(conn, SSH_SFTP_GETINFO);
}
}
break;
@@ -1611,6 +1613,35 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
state(conn, SSH_SFTP_NEXT_QUOTE);
break;
+ case SSH_SFTP_GETINFO:
+ {
+ if(data->set.get_filetime) {
+ state(conn, SSH_SFTP_FILETIME);
+ }
+ else {
+ state(conn, SSH_SFTP_TRANS_INIT);
+ }
+ break;
+ }
+
+ case SSH_SFTP_FILETIME:
+ {
+ LIBSSH2_SFTP_ATTRIBUTES attrs;
+
+ rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
+ curlx_uztoui(strlen(sftp_scp->path)),
+ LIBSSH2_SFTP_STAT, &attrs);
+ if(rc == LIBSSH2_ERROR_EAGAIN) {
+ break;
+ }
+ else if(rc == 0) {
+ data->info.filetime = (long)attrs.mtime;
+ }
+
+ state(conn, SSH_SFTP_TRANS_INIT);
+ break;
+ }
+
case SSH_SFTP_TRANS_INIT:
if(data->set.upload)
state(conn, SSH_SFTP_UPLOAD_INIT);