diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sftp.1 | 9 | ||||
-rw-r--r-- | sftp.c | 92 |
3 files changed, 65 insertions, 42 deletions
@@ -92,6 +92,10 @@ | |||
92 | - stevesk@cvs.openbsd.org 2002/02/04 20:41:16 | 92 | - stevesk@cvs.openbsd.org 2002/02/04 20:41:16 |
93 | [ssh-add.1] | 93 | [ssh-add.1] |
94 | more sync for default ssh-add identities; ok markus@ | 94 | more sync for default ssh-add identities; ok markus@ |
95 | - djm@cvs.openbsd.org 2002/02/04 21:53:12 | ||
96 | [sftp.1 sftp.c] | ||
97 | Add "-P" option to directly connect to a local sftp-server. Should be | ||
98 | useful for regression testing; ok markus@ | ||
95 | 99 | ||
96 | 20020130 | 100 | 20020130 |
97 | - (djm) Delay PRNG seeding until we need it in ssh-keygen, from markus@ | 101 | - (djm) Delay PRNG seeding until we need it in ssh-keygen, from markus@ |
@@ -7494,4 +7498,4 @@ | |||
7494 | - Wrote replacements for strlcpy and mkdtemp | 7498 | - Wrote replacements for strlcpy and mkdtemp |
7495 | - Released 1.0pre1 | 7499 | - Released 1.0pre1 |
7496 | 7500 | ||
7497 | $Id: ChangeLog,v 1.1824 2002/02/05 01:26:58 djm Exp $ | 7501 | $Id: ChangeLog,v 1.1825 2002/02/05 01:27:31 djm Exp $ |
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: sftp.1,v 1.26 2001/09/17 20:38:09 stevesk Exp $ | 1 | .\" $OpenBSD: sftp.1,v 1.27 2002/02/04 21:53:11 djm Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2001 Damien Miller. All rights reserved. | 3 | .\" Copyright (c) 2001 Damien Miller. All rights reserved. |
4 | .\" | 4 | .\" |
@@ -34,6 +34,7 @@ | |||
34 | .Op Fl b Ar batchfile | 34 | .Op Fl b Ar batchfile |
35 | .Op Fl F Ar ssh_config | 35 | .Op Fl F Ar ssh_config |
36 | .Op Fl o Ar ssh_option | 36 | .Op Fl o Ar ssh_option |
37 | .Op Fl P Ar sftp_server path | ||
37 | .Op Fl s Ar subsystem | sftp_server | 38 | .Op Fl s Ar subsystem | sftp_server |
38 | .Op Fl S Ar program | 39 | .Op Fl S Ar program |
39 | .Ar host | 40 | .Ar host |
@@ -65,6 +66,12 @@ The options are as follows: | |||
65 | .Bl -tag -width Ds | 66 | .Bl -tag -width Ds |
66 | .It Fl 1 | 67 | .It Fl 1 |
67 | Specify the use of protocol version 1. | 68 | Specify the use of protocol version 1. |
69 | .It Fl P Ar sftp_server path | ||
70 | Connect directly to a local | ||
71 | .Nm sftp-server | ||
72 | (rather than via | ||
73 | .Nm ssh ) | ||
74 | This option may be useful in debugging the client and server. | ||
68 | .It Fl b Ar batchfile | 75 | .It Fl b Ar batchfile |
69 | Batch mode reads a series of commands from an input | 76 | Batch mode reads a series of commands from an input |
70 | .Ar batchfile | 77 | .Ar batchfile |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2001 Damien Miller. All rights reserved. | 2 | * Copyright (c) 2001,2002 Damien Miller. All rights reserved. |
3 | * | 3 | * |
4 | * Redistribution and use in source and binary forms, with or without | 4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions | 5 | * modification, are permitted provided that the following conditions |
@@ -24,9 +24,8 @@ | |||
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | 26 | ||
27 | RCSID("$OpenBSD: sftp.c,v 1.22 2001/12/19 07:18:56 deraadt Exp $"); | 27 | RCSID("$OpenBSD: sftp.c,v 1.23 2002/02/04 21:53:12 djm Exp $"); |
28 | 28 | ||
29 | /* XXX: commandline mode */ | ||
30 | /* XXX: short-form remote directory listings (like 'ls -C') */ | 29 | /* XXX: short-form remote directory listings (like 'ls -C') */ |
31 | 30 | ||
32 | #include "buffer.h" | 31 | #include "buffer.h" |
@@ -46,11 +45,10 @@ extern char *__progname; | |||
46 | char *__progname; | 45 | char *__progname; |
47 | #endif | 46 | #endif |
48 | 47 | ||
49 | char *ssh_program = _PATH_SSH_PROGRAM; | ||
50 | FILE* infile; | 48 | FILE* infile; |
51 | 49 | ||
52 | static void | 50 | static void |
53 | connect_to_server(char **args, int *in, int *out, pid_t *sshpid) | 51 | connect_to_server(char *path, char **args, int *in, int *out, pid_t *sshpid) |
54 | { | 52 | { |
55 | int c_in, c_out; | 53 | int c_in, c_out; |
56 | #ifdef USE_PIPES | 54 | #ifdef USE_PIPES |
@@ -81,8 +79,8 @@ connect_to_server(char **args, int *in, int *out, pid_t *sshpid) | |||
81 | close(*out); | 79 | close(*out); |
82 | close(c_in); | 80 | close(c_in); |
83 | close(c_out); | 81 | close(c_out); |
84 | execv(ssh_program, args); | 82 | execv(path, args); |
85 | fprintf(stderr, "exec: %s: %s\n", ssh_program, strerror(errno)); | 83 | fprintf(stderr, "exec: %s: %s\n", path, strerror(errno)); |
86 | exit(1); | 84 | exit(1); |
87 | } | 85 | } |
88 | 86 | ||
@@ -107,6 +105,7 @@ main(int argc, char **argv) | |||
107 | char *host, *userhost, *cp, *file2; | 105 | char *host, *userhost, *cp, *file2; |
108 | int debug_level = 0, sshver = 2; | 106 | int debug_level = 0, sshver = 2; |
109 | char *file1 = NULL, *sftp_server = NULL; | 107 | char *file1 = NULL, *sftp_server = NULL; |
108 | char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL; | ||
110 | LogLevel ll = SYSLOG_LEVEL_INFO; | 109 | LogLevel ll = SYSLOG_LEVEL_INFO; |
111 | arglist args; | 110 | arglist args; |
112 | extern int optind; | 111 | extern int optind; |
@@ -122,7 +121,7 @@ main(int argc, char **argv) | |||
122 | ll = SYSLOG_LEVEL_INFO; | 121 | ll = SYSLOG_LEVEL_INFO; |
123 | infile = stdin; /* Read from STDIN unless changed by -b */ | 122 | infile = stdin; /* Read from STDIN unless changed by -b */ |
124 | 123 | ||
125 | while ((ch = getopt(argc, argv, "1hvCo:s:S:b:F:")) != -1) { | 124 | while ((ch = getopt(argc, argv, "1hvCo:s:S:b:F:P:")) != -1) { |
126 | switch (ch) { | 125 | switch (ch) { |
127 | case 'C': | 126 | case 'C': |
128 | addargs(&args, "-C"); | 127 | addargs(&args, "-C"); |
@@ -157,54 +156,67 @@ main(int argc, char **argv) | |||
157 | } else | 156 | } else |
158 | fatal("Filename already specified."); | 157 | fatal("Filename already specified."); |
159 | break; | 158 | break; |
159 | case 'P': | ||
160 | sftp_direct = optarg; | ||
161 | break; | ||
160 | case 'h': | 162 | case 'h': |
161 | default: | 163 | default: |
162 | usage(); | 164 | usage(); |
163 | } | 165 | } |
164 | } | 166 | } |
165 | 167 | ||
166 | if (optind == argc || argc > (optind + 2)) | 168 | if (sftp_direct == NULL) { |
167 | usage(); | 169 | if (optind == argc || argc > (optind + 2)) |
170 | usage(); | ||
168 | 171 | ||
169 | userhost = xstrdup(argv[optind]); | 172 | userhost = xstrdup(argv[optind]); |
170 | file2 = argv[optind+1]; | 173 | file2 = argv[optind+1]; |
171 | 174 | ||
172 | if ((cp = colon(userhost)) != NULL) { | 175 | if ((cp = colon(userhost)) != NULL) { |
173 | *cp++ = '\0'; | 176 | *cp++ = '\0'; |
174 | file1 = cp; | 177 | file1 = cp; |
175 | } | 178 | } |
176 | 179 | ||
177 | if ((host = strchr(userhost, '@')) == NULL) | 180 | if ((host = strchr(userhost, '@')) == NULL) |
178 | host = userhost; | 181 | host = userhost; |
179 | else { | 182 | else { |
180 | *host++ = '\0'; | 183 | *host++ = '\0'; |
181 | if (!userhost[0]) { | 184 | if (!userhost[0]) { |
182 | fprintf(stderr, "Missing username\n"); | 185 | fprintf(stderr, "Missing username\n"); |
183 | usage(); | 186 | usage(); |
187 | } | ||
188 | addargs(&args, "-l%s",userhost); | ||
184 | } | 189 | } |
185 | addargs(&args, "-l%s",userhost); | ||
186 | } | ||
187 | 190 | ||
188 | host = cleanhostname(host); | 191 | host = cleanhostname(host); |
189 | if (!*host) { | 192 | if (!*host) { |
190 | fprintf(stderr, "Missing hostname\n"); | 193 | fprintf(stderr, "Missing hostname\n"); |
191 | usage(); | 194 | usage(); |
192 | } | 195 | } |
193 | 196 | ||
194 | log_init(argv[0], ll, SYSLOG_FACILITY_USER, 1); | 197 | log_init(argv[0], ll, SYSLOG_FACILITY_USER, 1); |
195 | addargs(&args, "-oProtocol %d", sshver); | 198 | addargs(&args, "-oProtocol %d", sshver); |
196 | 199 | ||
197 | /* no subsystem if the server-spec contains a '/' */ | 200 | /* no subsystem if the server-spec contains a '/' */ |
198 | if (sftp_server == NULL || strchr(sftp_server, '/') == NULL) | 201 | if (sftp_server == NULL || strchr(sftp_server, '/') == NULL) |
199 | addargs(&args, "-s"); | 202 | addargs(&args, "-s"); |
200 | 203 | ||
201 | addargs(&args, "%s", host); | 204 | addargs(&args, "%s", host); |
202 | addargs(&args, "%s", (sftp_server != NULL ? sftp_server : "sftp")); | 205 | addargs(&args, "%s", (sftp_server != NULL ? |
203 | args.list[0] = ssh_program; | 206 | sftp_server : "sftp")); |
207 | args.list[0] = ssh_program; | ||
204 | 208 | ||
205 | fprintf(stderr, "Connecting to %s...\n", host); | 209 | fprintf(stderr, "Connecting to %s...\n", host); |
210 | connect_to_server(ssh_program, args.list, &in, &out, | ||
211 | &sshpid); | ||
212 | } else { | ||
213 | args.list = NULL; | ||
214 | addargs(&args, "sftp-server"); | ||
206 | 215 | ||
207 | connect_to_server(args.list, &in, &out, &sshpid); | 216 | fprintf(stderr, "Attaching to %s...\n", sftp_direct); |
217 | connect_to_server(sftp_direct, args.list, &in, &out, | ||
218 | &sshpid); | ||
219 | } | ||
208 | 220 | ||
209 | interactive_loop(in, out, file1, file2); | 221 | interactive_loop(in, out, file1, file2); |
210 | 222 | ||