summaryrefslogtreecommitdiffstats
path: root/libssh/scp.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2009-08-23 22:36:32 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2009-08-23 22:36:32 +0200
commitf3b36af50ef8edb8b04dc81a0e2ee5599f0cdd49 (patch)
treec89ca4aa08b6bdd9fee4506e7d1ae19d2cef7394 /libssh/scp.c
parent385b640d1dabddb06e389e633c622fb1c7cc664e (diff)
downloadlibssh-f3b36af50ef8edb8b04dc81a0e2ee5599f0cdd49.tar.gz
libssh-f3b36af50ef8edb8b04dc81a0e2ee5599f0cdd49.tar.xz
libssh-f3b36af50ef8edb8b04dc81a0e2ee5599f0cdd49.zip
added ssh_scp_deny_request
Diffstat (limited to 'libssh/scp.c')
-rw-r--r--libssh/scp.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libssh/scp.c b/libssh/scp.c
index 9cabe30..869af20 100644
--- a/libssh/scp.c
+++ b/libssh/scp.c
@@ -372,3 +372,26 @@ int ssh_scp_pull_request(ssh_scp scp){
ssh_set_error(scp->session,SSH_FATAL,"Parsing error while parsing message: %s",buffer);
return SSH_ERROR;
}
+
+/**
+ * @brief denies the transfer of a file or creation of a directory
+ * coming from the remote party
+ * @param reason nul-terminated string with a human-readable explanation
+ * of the deny
+ * @returns SSH_OK the message was sent
+ * @returns SSH_ERROR Error sending the message, or sending it in a bad state
+ */
+int ssh_scp_deny_request(ssh_scp scp, const char *reason){
+ char buffer[4096];
+ int err;
+ if(scp->state != SSH_SCP_READ_REQUESTED){
+ ssh_set_error(scp->session,SSH_FATAL,"ssh_scp_deny_request called under invalid state");
+ return SSH_ERROR;
+ }
+ snprintf(buffer,sizeof(buffer),"%c%s\n",2,reason);
+ err=channel_write(scp->channel,buffer,strlen(buffer));
+ if(err==SSH_ERROR)
+ return SSH_ERROR;
+ else
+ return SSH_OK;
+}