X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/38f0c08ea9a626c97a1d97b6d56d6f44b6a14572..edd0cb8aef57080ae884e06731a7892ca8cdba44:/psftp.c diff --git a/psftp.c b/psftp.c index 4678c97a..2705d45d 100644 --- a/psftp.c +++ b/psftp.c @@ -1399,7 +1399,6 @@ int sftp_cmd_mkdir(struct sftp_command *cmd) if (!result) { printf("mkdir %s: %s\n", dir, fxp_error()); - sfree(dir); ret = 0; } else printf("mkdir %s: OK\n", dir); @@ -2524,6 +2523,15 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen) return 0; } +int from_backend_untrusted(void *frontend_handle, const char *data, int len) +{ + /* + * No "untrusted" output should get here (the way the code is + * currently, it's all diverted by FLAG_STDERR). + */ + assert(!"Unexpected call to from_backend_untrusted()"); + return 0; /* not reached */ +} int sftp_recvdata(char *buf, int len) { outptr = (unsigned char *) buf; @@ -2573,6 +2581,8 @@ static void usage(void) printf("%s\n", ver); printf("Usage: psftp [options] [user@]host\n"); printf("Options:\n"); + printf(" -V print version information and exit\n"); + printf(" -pgpfp print PGP key fingerprints and exit\n"); printf(" -b file use specified batchfile\n"); printf(" -bc output batchfile commands\n"); printf(" -be don't stop batchfile processing if errors\n"); @@ -2586,7 +2596,6 @@ static void usage(void) printf(" -C enable compression\n"); printf(" -i key private key file for authentication\n"); printf(" -batch disable all interactive prompts\n"); - printf(" -V print version information\n"); cleanup_exit(1); } @@ -2714,14 +2723,21 @@ static int psftp_connect(char *userhost, char *user, int portnumber) cfg.username[sizeof(cfg.username) - 1] = '\0'; } if (!cfg.username[0]) { - if (!console_get_line("login as: ", - cfg.username, sizeof(cfg.username), FALSE)) { + /* FIXME: leave this to ssh.c? */ + int ret; + prompts_t *p = new_prompts(NULL); + p->to_server = TRUE; + p->name = dupstr("SSH login name"); + add_prompt(p, dupstr("login as: "), TRUE, lenof(cfg.username)); + ret = get_userpass_input(p, NULL, 0); + assert(ret >= 0); + if (!ret) { + free_prompts(p); fprintf(stderr, "psftp: no username, aborting\n"); cleanup_exit(1); } else { - int len = strlen(cfg.username); - if (cfg.username[len - 1] == '\n') - cfg.username[len - 1] = '\0'; + memcpy(cfg.username, p->prompts[0]->result, lenof(cfg.username)); + free_prompts(p); } } @@ -2743,7 +2759,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber) cfg.nopty = TRUE; /* - * Set up fallback option, for SSH1 servers or servers with the + * Set up fallback option, for SSH-1 servers or servers with the * sftp subsystem not enabled but the server binary installed * in the usual place. We only support fallback on Unix * systems, and we use a kludgy piece of shellery which should @@ -2819,7 +2835,6 @@ int psftp_main(int argc, char *argv[]) #endif ; cmdline_tooltype = TOOLTYPE_FILETRANSFER; - ssh_get_line = &console_get_line; sk_init(); userhost = user = NULL; @@ -2850,6 +2865,9 @@ int psftp_main(int argc, char *argv[]) } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-?") == 0) { usage(); + } else if (strcmp(argv[i], "-pgpfp") == 0) { + pgp_fingerprints(); + return 1; } else if (strcmp(argv[i], "-V") == 0) { version(); } else if (strcmp(argv[i], "-batch") == 0) {