diff options
Diffstat (limited to 'sftp-server.c')
-rw-r--r-- | sftp-server.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/sftp-server.c b/sftp-server.c index ab6291e61..e6353bceb 100644 --- a/sftp-server.c +++ b/sftp-server.c | |||
@@ -22,7 +22,7 @@ | |||
22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | */ | 23 | */ |
24 | #include "includes.h" | 24 | #include "includes.h" |
25 | RCSID("$OpenBSD: sftp-server.c,v 1.27 2001/06/22 22:21:20 markus Exp $"); | 25 | RCSID("$OpenBSD: sftp-server.c,v 1.28 2001/06/23 15:12:20 itojun Exp $"); |
26 | 26 | ||
27 | #include "buffer.h" | 27 | #include "buffer.h" |
28 | #include "bufaux.h" | 28 | #include "bufaux.h" |
@@ -62,7 +62,7 @@ struct Stat { | |||
62 | Attrib attrib; | 62 | Attrib attrib; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | int | 65 | static int |
66 | errno_to_portable(int unixerrno) | 66 | errno_to_portable(int unixerrno) |
67 | { | 67 | { |
68 | int ret = 0; | 68 | int ret = 0; |
@@ -93,7 +93,7 @@ errno_to_portable(int unixerrno) | |||
93 | return ret; | 93 | return ret; |
94 | } | 94 | } |
95 | 95 | ||
96 | int | 96 | static int |
97 | flags_from_portable(int pflags) | 97 | flags_from_portable(int pflags) |
98 | { | 98 | { |
99 | int flags = 0; | 99 | int flags = 0; |
@@ -115,7 +115,7 @@ flags_from_portable(int pflags) | |||
115 | return flags; | 115 | return flags; |
116 | } | 116 | } |
117 | 117 | ||
118 | Attrib * | 118 | static Attrib * |
119 | get_attrib(void) | 119 | get_attrib(void) |
120 | { | 120 | { |
121 | return decode_attrib(&iqueue); | 121 | return decode_attrib(&iqueue); |
@@ -139,7 +139,7 @@ enum { | |||
139 | 139 | ||
140 | Handle handles[100]; | 140 | Handle handles[100]; |
141 | 141 | ||
142 | void | 142 | static void |
143 | handle_init(void) | 143 | handle_init(void) |
144 | { | 144 | { |
145 | int i; | 145 | int i; |
@@ -148,7 +148,7 @@ handle_init(void) | |||
148 | handles[i].use = HANDLE_UNUSED; | 148 | handles[i].use = HANDLE_UNUSED; |
149 | } | 149 | } |
150 | 150 | ||
151 | int | 151 | static int |
152 | handle_new(int use, char *name, int fd, DIR *dirp) | 152 | handle_new(int use, char *name, int fd, DIR *dirp) |
153 | { | 153 | { |
154 | int i; | 154 | int i; |
@@ -165,14 +165,14 @@ handle_new(int use, char *name, int fd, DIR *dirp) | |||
165 | return -1; | 165 | return -1; |
166 | } | 166 | } |
167 | 167 | ||
168 | int | 168 | static int |
169 | handle_is_ok(int i, int type) | 169 | handle_is_ok(int i, int type) |
170 | { | 170 | { |
171 | return i >= 0 && i < sizeof(handles)/sizeof(Handle) && | 171 | return i >= 0 && i < sizeof(handles)/sizeof(Handle) && |
172 | handles[i].use == type; | 172 | handles[i].use == type; |
173 | } | 173 | } |
174 | 174 | ||
175 | int | 175 | static int |
176 | handle_to_string(int handle, char **stringp, int *hlenp) | 176 | handle_to_string(int handle, char **stringp, int *hlenp) |
177 | { | 177 | { |
178 | if (stringp == NULL || hlenp == NULL) | 178 | if (stringp == NULL || hlenp == NULL) |
@@ -183,7 +183,7 @@ handle_to_string(int handle, char **stringp, int *hlenp) | |||
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
185 | 185 | ||
186 | int | 186 | static int |
187 | handle_from_string(char *handle, u_int hlen) | 187 | handle_from_string(char *handle, u_int hlen) |
188 | { | 188 | { |
189 | int val; | 189 | int val; |
@@ -197,7 +197,7 @@ handle_from_string(char *handle, u_int hlen) | |||
197 | return -1; | 197 | return -1; |
198 | } | 198 | } |
199 | 199 | ||
200 | char * | 200 | static char * |
201 | handle_to_name(int handle) | 201 | handle_to_name(int handle) |
202 | { | 202 | { |
203 | if (handle_is_ok(handle, HANDLE_DIR)|| | 203 | if (handle_is_ok(handle, HANDLE_DIR)|| |
@@ -206,7 +206,7 @@ handle_to_name(int handle) | |||
206 | return NULL; | 206 | return NULL; |
207 | } | 207 | } |
208 | 208 | ||
209 | DIR * | 209 | static DIR * |
210 | handle_to_dir(int handle) | 210 | handle_to_dir(int handle) |
211 | { | 211 | { |
212 | if (handle_is_ok(handle, HANDLE_DIR)) | 212 | if (handle_is_ok(handle, HANDLE_DIR)) |
@@ -214,7 +214,7 @@ handle_to_dir(int handle) | |||
214 | return NULL; | 214 | return NULL; |
215 | } | 215 | } |
216 | 216 | ||
217 | int | 217 | static int |
218 | handle_to_fd(int handle) | 218 | handle_to_fd(int handle) |
219 | { | 219 | { |
220 | if (handle_is_ok(handle, HANDLE_FILE)) | 220 | if (handle_is_ok(handle, HANDLE_FILE)) |
@@ -222,7 +222,7 @@ handle_to_fd(int handle) | |||
222 | return -1; | 222 | return -1; |
223 | } | 223 | } |
224 | 224 | ||
225 | int | 225 | static int |
226 | handle_close(int handle) | 226 | handle_close(int handle) |
227 | { | 227 | { |
228 | int ret = -1; | 228 | int ret = -1; |
@@ -239,7 +239,7 @@ handle_close(int handle) | |||
239 | return ret; | 239 | return ret; |
240 | } | 240 | } |
241 | 241 | ||
242 | int | 242 | static int |
243 | get_handle(void) | 243 | get_handle(void) |
244 | { | 244 | { |
245 | char *handle; | 245 | char *handle; |
@@ -255,7 +255,7 @@ get_handle(void) | |||
255 | 255 | ||
256 | /* send replies */ | 256 | /* send replies */ |
257 | 257 | ||
258 | void | 258 | static void |
259 | send_msg(Buffer *m) | 259 | send_msg(Buffer *m) |
260 | { | 260 | { |
261 | int mlen = buffer_len(m); | 261 | int mlen = buffer_len(m); |
@@ -265,7 +265,7 @@ send_msg(Buffer *m) | |||
265 | buffer_consume(m, mlen); | 265 | buffer_consume(m, mlen); |
266 | } | 266 | } |
267 | 267 | ||
268 | void | 268 | static void |
269 | send_status(u_int32_t id, u_int32_t error) | 269 | send_status(u_int32_t id, u_int32_t error) |
270 | { | 270 | { |
271 | Buffer msg; | 271 | Buffer msg; |
@@ -295,7 +295,7 @@ send_status(u_int32_t id, u_int32_t error) | |||
295 | send_msg(&msg); | 295 | send_msg(&msg); |
296 | buffer_free(&msg); | 296 | buffer_free(&msg); |
297 | } | 297 | } |
298 | void | 298 | static void |
299 | send_data_or_handle(char type, u_int32_t id, char *data, int dlen) | 299 | send_data_or_handle(char type, u_int32_t id, char *data, int dlen) |
300 | { | 300 | { |
301 | Buffer msg; | 301 | Buffer msg; |
@@ -308,14 +308,14 @@ send_data_or_handle(char type, u_int32_t id, char *data, int dlen) | |||
308 | buffer_free(&msg); | 308 | buffer_free(&msg); |
309 | } | 309 | } |
310 | 310 | ||
311 | void | 311 | static void |
312 | send_data(u_int32_t id, char *data, int dlen) | 312 | send_data(u_int32_t id, char *data, int dlen) |
313 | { | 313 | { |
314 | TRACE("sent data id %d len %d", id, dlen); | 314 | TRACE("sent data id %d len %d", id, dlen); |
315 | send_data_or_handle(SSH2_FXP_DATA, id, data, dlen); | 315 | send_data_or_handle(SSH2_FXP_DATA, id, data, dlen); |
316 | } | 316 | } |
317 | 317 | ||
318 | void | 318 | static void |
319 | send_handle(u_int32_t id, int handle) | 319 | send_handle(u_int32_t id, int handle) |
320 | { | 320 | { |
321 | char *string; | 321 | char *string; |
@@ -327,7 +327,7 @@ send_handle(u_int32_t id, int handle) | |||
327 | xfree(string); | 327 | xfree(string); |
328 | } | 328 | } |
329 | 329 | ||
330 | void | 330 | static void |
331 | send_names(u_int32_t id, int count, Stat *stats) | 331 | send_names(u_int32_t id, int count, Stat *stats) |
332 | { | 332 | { |
333 | Buffer msg; | 333 | Buffer msg; |
@@ -347,7 +347,7 @@ send_names(u_int32_t id, int count, Stat *stats) | |||
347 | buffer_free(&msg); | 347 | buffer_free(&msg); |
348 | } | 348 | } |
349 | 349 | ||
350 | void | 350 | static void |
351 | send_attrib(u_int32_t id, Attrib *a) | 351 | send_attrib(u_int32_t id, Attrib *a) |
352 | { | 352 | { |
353 | Buffer msg; | 353 | Buffer msg; |
@@ -363,7 +363,7 @@ send_attrib(u_int32_t id, Attrib *a) | |||
363 | 363 | ||
364 | /* parse incoming */ | 364 | /* parse incoming */ |
365 | 365 | ||
366 | void | 366 | static void |
367 | process_init(void) | 367 | process_init(void) |
368 | { | 368 | { |
369 | Buffer msg; | 369 | Buffer msg; |
@@ -377,7 +377,7 @@ process_init(void) | |||
377 | buffer_free(&msg); | 377 | buffer_free(&msg); |
378 | } | 378 | } |
379 | 379 | ||
380 | void | 380 | static void |
381 | process_open(void) | 381 | process_open(void) |
382 | { | 382 | { |
383 | u_int32_t id, pflags; | 383 | u_int32_t id, pflags; |
@@ -409,7 +409,7 @@ process_open(void) | |||
409 | xfree(name); | 409 | xfree(name); |
410 | } | 410 | } |
411 | 411 | ||
412 | void | 412 | static void |
413 | process_close(void) | 413 | process_close(void) |
414 | { | 414 | { |
415 | u_int32_t id; | 415 | u_int32_t id; |
@@ -423,7 +423,7 @@ process_close(void) | |||
423 | send_status(id, status); | 423 | send_status(id, status); |
424 | } | 424 | } |
425 | 425 | ||
426 | void | 426 | static void |
427 | process_read(void) | 427 | process_read(void) |
428 | { | 428 | { |
429 | char buf[64*1024]; | 429 | char buf[64*1024]; |
@@ -463,7 +463,7 @@ process_read(void) | |||
463 | send_status(id, status); | 463 | send_status(id, status); |
464 | } | 464 | } |
465 | 465 | ||
466 | void | 466 | static void |
467 | process_write(void) | 467 | process_write(void) |
468 | { | 468 | { |
469 | u_int32_t id; | 469 | u_int32_t id; |
@@ -501,7 +501,7 @@ process_write(void) | |||
501 | xfree(data); | 501 | xfree(data); |
502 | } | 502 | } |
503 | 503 | ||
504 | void | 504 | static void |
505 | process_do_stat(int do_lstat) | 505 | process_do_stat(int do_lstat) |
506 | { | 506 | { |
507 | Attrib a; | 507 | Attrib a; |
@@ -526,19 +526,19 @@ process_do_stat(int do_lstat) | |||
526 | xfree(name); | 526 | xfree(name); |
527 | } | 527 | } |
528 | 528 | ||
529 | void | 529 | static void |
530 | process_stat(void) | 530 | process_stat(void) |
531 | { | 531 | { |
532 | process_do_stat(0); | 532 | process_do_stat(0); |
533 | } | 533 | } |
534 | 534 | ||
535 | void | 535 | static void |
536 | process_lstat(void) | 536 | process_lstat(void) |
537 | { | 537 | { |
538 | process_do_stat(1); | 538 | process_do_stat(1); |
539 | } | 539 | } |
540 | 540 | ||
541 | void | 541 | static void |
542 | process_fstat(void) | 542 | process_fstat(void) |
543 | { | 543 | { |
544 | Attrib a; | 544 | Attrib a; |
@@ -564,7 +564,7 @@ process_fstat(void) | |||
564 | send_status(id, status); | 564 | send_status(id, status); |
565 | } | 565 | } |
566 | 566 | ||
567 | struct timeval * | 567 | static struct timeval * |
568 | attrib_to_tv(Attrib *a) | 568 | attrib_to_tv(Attrib *a) |
569 | { | 569 | { |
570 | static struct timeval tv[2]; | 570 | static struct timeval tv[2]; |
@@ -576,7 +576,7 @@ attrib_to_tv(Attrib *a) | |||
576 | return tv; | 576 | return tv; |
577 | } | 577 | } |
578 | 578 | ||
579 | void | 579 | static void |
580 | process_setstat(void) | 580 | process_setstat(void) |
581 | { | 581 | { |
582 | Attrib *a; | 582 | Attrib *a; |
@@ -608,7 +608,7 @@ process_setstat(void) | |||
608 | xfree(name); | 608 | xfree(name); |
609 | } | 609 | } |
610 | 610 | ||
611 | void | 611 | static void |
612 | process_fsetstat(void) | 612 | process_fsetstat(void) |
613 | { | 613 | { |
614 | Attrib *a; | 614 | Attrib *a; |
@@ -657,7 +657,7 @@ process_fsetstat(void) | |||
657 | send_status(id, status); | 657 | send_status(id, status); |
658 | } | 658 | } |
659 | 659 | ||
660 | void | 660 | static void |
661 | process_opendir(void) | 661 | process_opendir(void) |
662 | { | 662 | { |
663 | DIR *dirp = NULL; | 663 | DIR *dirp = NULL; |
@@ -689,7 +689,7 @@ process_opendir(void) | |||
689 | /* | 689 | /* |
690 | * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh | 690 | * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh |
691 | */ | 691 | */ |
692 | char * | 692 | static char * |
693 | ls_file(char *name, struct stat *st) | 693 | ls_file(char *name, struct stat *st) |
694 | { | 694 | { |
695 | int ulen, glen, sz = 0; | 695 | int ulen, glen, sz = 0; |
@@ -728,7 +728,7 @@ ls_file(char *name, struct stat *st) | |||
728 | return xstrdup(buf); | 728 | return xstrdup(buf); |
729 | } | 729 | } |
730 | 730 | ||
731 | void | 731 | static void |
732 | process_readdir(void) | 732 | process_readdir(void) |
733 | { | 733 | { |
734 | DIR *dirp; | 734 | DIR *dirp; |
@@ -782,7 +782,7 @@ process_readdir(void) | |||
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | void | 785 | static void |
786 | process_remove(void) | 786 | process_remove(void) |
787 | { | 787 | { |
788 | char *name; | 788 | char *name; |
@@ -799,7 +799,7 @@ process_remove(void) | |||
799 | xfree(name); | 799 | xfree(name); |
800 | } | 800 | } |
801 | 801 | ||
802 | void | 802 | static void |
803 | process_mkdir(void) | 803 | process_mkdir(void) |
804 | { | 804 | { |
805 | Attrib *a; | 805 | Attrib *a; |
@@ -819,7 +819,7 @@ process_mkdir(void) | |||
819 | xfree(name); | 819 | xfree(name); |
820 | } | 820 | } |
821 | 821 | ||
822 | void | 822 | static void |
823 | process_rmdir(void) | 823 | process_rmdir(void) |
824 | { | 824 | { |
825 | u_int32_t id; | 825 | u_int32_t id; |
@@ -835,7 +835,7 @@ process_rmdir(void) | |||
835 | xfree(name); | 835 | xfree(name); |
836 | } | 836 | } |
837 | 837 | ||
838 | void | 838 | static void |
839 | process_realpath(void) | 839 | process_realpath(void) |
840 | { | 840 | { |
841 | char resolvedname[MAXPATHLEN]; | 841 | char resolvedname[MAXPATHLEN]; |
@@ -860,7 +860,7 @@ process_realpath(void) | |||
860 | xfree(path); | 860 | xfree(path); |
861 | } | 861 | } |
862 | 862 | ||
863 | void | 863 | static void |
864 | process_rename(void) | 864 | process_rename(void) |
865 | { | 865 | { |
866 | u_int32_t id; | 866 | u_int32_t id; |
@@ -882,7 +882,7 @@ process_rename(void) | |||
882 | xfree(newpath); | 882 | xfree(newpath); |
883 | } | 883 | } |
884 | 884 | ||
885 | void | 885 | static void |
886 | process_readlink(void) | 886 | process_readlink(void) |
887 | { | 887 | { |
888 | u_int32_t id; | 888 | u_int32_t id; |
@@ -906,7 +906,7 @@ process_readlink(void) | |||
906 | xfree(path); | 906 | xfree(path); |
907 | } | 907 | } |
908 | 908 | ||
909 | void | 909 | static void |
910 | process_symlink(void) | 910 | process_symlink(void) |
911 | { | 911 | { |
912 | u_int32_t id; | 912 | u_int32_t id; |
@@ -928,7 +928,7 @@ process_symlink(void) | |||
928 | xfree(newpath); | 928 | xfree(newpath); |
929 | } | 929 | } |
930 | 930 | ||
931 | void | 931 | static void |
932 | process_extended(void) | 932 | process_extended(void) |
933 | { | 933 | { |
934 | u_int32_t id; | 934 | u_int32_t id; |
@@ -942,7 +942,7 @@ process_extended(void) | |||
942 | 942 | ||
943 | /* stolen from ssh-agent */ | 943 | /* stolen from ssh-agent */ |
944 | 944 | ||
945 | void | 945 | static void |
946 | process(void) | 946 | process(void) |
947 | { | 947 | { |
948 | u_int msg_len; | 948 | u_int msg_len; |