summaryrefslogtreecommitdiffstats
path: root/tests/chmodtest.c
blob: 1e6f51127c2b7e94cce1516ea067e198c28ae412 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>

#include <libssh/libssh.h>
#include "examples_common.h"
#include <libssh/sftp.h>

int main(void) {
  ssh_session session;
  sftp_session sftp;
  char buffer[1024*1024];
  int rc;

  session = connect_ssh("localhost", NULL, 0);
  if (session == NULL) {
    return 1;
  }

  sftp=sftp_new(session);
  sftp_init(sftp);
  rc=sftp_rename(sftp,"/tmp/test","/tmp/test");
  rc=sftp_rename(sftp,"/tmp/test","/tmp/test");
  rc=sftp_chmod(sftp,"/tmp/test",0644);
  if (rc < 0) {
    printf("error : %s\n",ssh_get_error(sftp));

    ssh_disconnect(session);
    return 1;
  }

  ssh_disconnect(session);

  return 0;
}