close(0); dup2(to[0], 0); close(to[1]);
close(1); dup2(from[1], 1); close(from[0]);
execl("/home/simon/src/openssh/openssh_cvs/prefix/bin/ssh", "ssh", "-2", "simon@localhost", "-s", "sftp", NULL);
+ //execl("/root/ssh-research/ssh-2.4.0/apps/ssh/sftp-server2", "sftp-server2", NULL);
+ //execl("/usr/lib/sftp-server", "sftp-server", NULL);
assert(0); /* bomb out if not */
} else {
/* We are parent. Close wrong end of each pipe, assign to glob vars. */
}
/*
- * Canonify a pathname. Concatenate the two given path elements
- * with a separating slash, unless the second is NULL.
+ * Canonify a pathname.
*/
-char *fxp_realpath(char *path, char *path2) {
+char *fxp_realpath(char *path) {
struct sftp_packet *pktin, *pktout;
int id;
sftp_pkt_adduint32(pktout, 0x123); /* request id */
sftp_pkt_addstring_start(pktout);
sftp_pkt_addstring_str(pktout, path);
- if (path2) {
- sftp_pkt_addstring_str(pktout, "/");
- sftp_pkt_addstring_str(pktout, path2);
- }
sftp_send(pktout);
pktin = sftp_recv();
id = sftp_pkt_getuint32(pktin);
}
handle = smalloc(sizeof(struct fxp_handle));
handle->hstring = mkstr(hstring, len);
+ handle->hlen = len;
sftp_pkt_free(pktin);
return handle;
} else {
}
handle = smalloc(sizeof(struct fxp_handle));
handle->hstring = mkstr(hstring, len);
+ handle->hlen = len;
sftp_pkt_free(pktin);
return handle;
} else {
pktout = sftp_pkt_init(SSH_FXP_CLOSE);
sftp_pkt_adduint32(pktout, 0x789); /* request id */
- sftp_pkt_addstring(pktout, handle->hstring);
+ sftp_pkt_addstring_start(pktout);
+ sftp_pkt_addstring_data(pktout, handle->hstring, handle->hlen);
sftp_send(pktout);
pktin = sftp_recv();
id = sftp_pkt_getuint32(pktin);
pktout = sftp_pkt_init(SSH_FXP_READ);
sftp_pkt_adduint32(pktout, 0xBCD); /* request id */
- sftp_pkt_addstring(pktout, handle->hstring);
+ sftp_pkt_addstring_start(pktout);
+ sftp_pkt_addstring_data(pktout, handle->hstring, handle->hlen);
sftp_pkt_adduint64(pktout, offset);
sftp_pkt_adduint32(pktout, len);
sftp_send(pktout);
pktout = sftp_pkt_init(SSH_FXP_READDIR);
sftp_pkt_adduint32(pktout, 0xABC); /* request id */
- sftp_pkt_addstring(pktout, handle->hstring);
+ sftp_pkt_addstring_start(pktout);
+ sftp_pkt_addstring_data(pktout, handle->hstring, handle->hlen);
sftp_send(pktout);
pktin = sftp_recv();
id = sftp_pkt_getuint32(pktin);
pktout = sftp_pkt_init(SSH_FXP_WRITE);
sftp_pkt_adduint32(pktout, 0xDCB); /* request id */
- sftp_pkt_addstring(pktout, handle->hstring);
+ sftp_pkt_addstring_start(pktout);
+ sftp_pkt_addstring_data(pktout, handle->hstring, handle->hlen);
sftp_pkt_adduint64(pktout, offset);
sftp_pkt_addstring_start(pktout);
sftp_pkt_addstring_data(pktout, buffer, len);