version 1.3, 2001/02/04 15:32:25 |
version 1.4, 2001/02/06 23:30:28 |
|
|
/* XXX: what should this be? */ |
/* XXX: what should this be? */ |
#define COPY_SIZE 8192 |
#define COPY_SIZE 8192 |
|
|
|
/* Message ID */ |
|
static u_int msg_id = 1; |
|
|
void |
void |
send_msg(int fd, Buffer *m) |
send_msg(int fd, Buffer *m) |
{ |
{ |
|
|
|
|
buffer_init(&msg); |
buffer_init(&msg); |
|
|
id = arc4random(); |
id = msg_id++; |
buffer_put_char(&msg, SSH2_FXP_CLOSE); |
buffer_put_char(&msg, SSH2_FXP_CLOSE); |
buffer_put_int(&msg, id); |
buffer_put_int(&msg, id); |
buffer_put_string(&msg, handle, handle_len); |
buffer_put_string(&msg, handle, handle_len); |
|
|
u_int type, id, handle_len, i, expected_id; |
u_int type, id, handle_len, i, expected_id; |
char *handle; |
char *handle; |
|
|
id = arc4random(); |
id = msg_id++; |
|
|
buffer_init(&msg); |
buffer_init(&msg); |
buffer_put_char(&msg, SSH2_FXP_OPENDIR); |
buffer_put_char(&msg, SSH2_FXP_OPENDIR); |
|
|
for(;;) { |
for(;;) { |
int count; |
int count; |
|
|
expected_id = ++id; |
id = expected_id = msg_id++; |
|
|
debug3("Sending SSH2_FXP_READDIR I:%d", id); |
debug3("Sending SSH2_FXP_READDIR I:%d", id); |
|
|
|
|
|
|
debug2("Sending SSH2_FXP_REMOVE \"%s\"", path); |
debug2("Sending SSH2_FXP_REMOVE \"%s\"", path); |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_request(fd_out, id, SSH2_FXP_REMOVE, path, strlen(path)); |
send_string_request(fd_out, id, SSH2_FXP_REMOVE, path, strlen(path)); |
status = get_status(fd_in, id); |
status = get_status(fd_in, id); |
if (status != SSH2_FX_OK) |
if (status != SSH2_FX_OK) |
|
|
{ |
{ |
u_int status, id; |
u_int status, id; |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_attrs_request(fd_out, id, SSH2_FXP_MKDIR, path, |
send_string_attrs_request(fd_out, id, SSH2_FXP_MKDIR, path, |
strlen(path), a); |
strlen(path), a); |
|
|
|
|
{ |
{ |
u_int status, id; |
u_int status, id; |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_request(fd_out, id, SSH2_FXP_RMDIR, path, strlen(path)); |
send_string_request(fd_out, id, SSH2_FXP_RMDIR, path, strlen(path)); |
|
|
status = get_status(fd_in, id); |
status = get_status(fd_in, id); |
|
|
{ |
{ |
u_int id; |
u_int id; |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_request(fd_out, id, SSH2_FXP_STAT, path, strlen(path)); |
send_string_request(fd_out, id, SSH2_FXP_STAT, path, strlen(path)); |
return(get_decode_stat(fd_in, id)); |
return(get_decode_stat(fd_in, id)); |
} |
} |
|
|
{ |
{ |
u_int id; |
u_int id; |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_request(fd_out, id, SSH2_FXP_LSTAT, path, strlen(path)); |
send_string_request(fd_out, id, SSH2_FXP_LSTAT, path, strlen(path)); |
return(get_decode_stat(fd_in, id)); |
return(get_decode_stat(fd_in, id)); |
} |
} |
|
|
{ |
{ |
u_int id; |
u_int id; |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_request(fd_out, id, SSH2_FXP_FSTAT, handle, handle_len); |
send_string_request(fd_out, id, SSH2_FXP_FSTAT, handle, handle_len); |
return(get_decode_stat(fd_in, id)); |
return(get_decode_stat(fd_in, id)); |
} |
} |
|
|
{ |
{ |
u_int status, id; |
u_int status, id; |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_attrs_request(fd_out, id, SSH2_FXP_SETSTAT, path, |
send_string_attrs_request(fd_out, id, SSH2_FXP_SETSTAT, path, |
strlen(path), a); |
strlen(path), a); |
|
|
|
|
{ |
{ |
u_int status, id; |
u_int status, id; |
|
|
id = arc4random(); |
id = msg_id++; |
send_string_attrs_request(fd_out, id, SSH2_FXP_FSETSTAT, handle, |
send_string_attrs_request(fd_out, id, SSH2_FXP_FSETSTAT, handle, |
handle_len, a); |
handle_len, a); |
|
|
|
|
char *filename, *longname; |
char *filename, *longname; |
Attrib *a; |
Attrib *a; |
|
|
expected_id = id = arc4random(); |
expected_id = id = msg_id++; |
send_string_request(fd_out, id, SSH2_FXP_REALPATH, path, |
send_string_request(fd_out, id, SSH2_FXP_REALPATH, path, |
strlen(path)); |
strlen(path)); |
|
|
|
|
buffer_init(&msg); |
buffer_init(&msg); |
|
|
/* Send rename request */ |
/* Send rename request */ |
id = arc4random(); |
id = msg_id++; |
buffer_put_char(&msg, SSH2_FXP_RENAME); |
buffer_put_char(&msg, SSH2_FXP_RENAME); |
buffer_put_int(&msg, id); |
buffer_put_int(&msg, id); |
buffer_put_cstring(&msg, oldpath); |
buffer_put_cstring(&msg, oldpath); |
|
|
buffer_init(&msg); |
buffer_init(&msg); |
|
|
/* Send open request */ |
/* Send open request */ |
id = arc4random(); |
id = msg_id++; |
buffer_put_char(&msg, SSH2_FXP_OPEN); |
buffer_put_char(&msg, SSH2_FXP_OPEN); |
buffer_put_int(&msg, id); |
buffer_put_int(&msg, id); |
buffer_put_cstring(&msg, remote_path); |
buffer_put_cstring(&msg, remote_path); |
|
|
u_int len; |
u_int len; |
char *data; |
char *data; |
|
|
expected_id = ++id; |
id = expected_id = msg_id++; |
|
|
buffer_clear(&msg); |
buffer_clear(&msg); |
buffer_put_char(&msg, SSH2_FXP_READ); |
buffer_put_char(&msg, SSH2_FXP_READ); |
|
|
buffer_init(&msg); |
buffer_init(&msg); |
|
|
/* Send open request */ |
/* Send open request */ |
id = arc4random(); |
id = msg_id++; |
buffer_put_char(&msg, SSH2_FXP_OPEN); |
buffer_put_char(&msg, SSH2_FXP_OPEN); |
buffer_put_int(&msg, id); |
buffer_put_int(&msg, id); |
buffer_put_cstring(&msg, remote_path); |
buffer_put_cstring(&msg, remote_path); |