summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c90
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"
25RCSID("$OpenBSD: sftp-server.c,v 1.27 2001/06/22 22:21:20 markus Exp $"); 25RCSID("$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
65int 65static int
66errno_to_portable(int unixerrno) 66errno_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
96int 96static int
97flags_from_portable(int pflags) 97flags_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
118Attrib * 118static Attrib *
119get_attrib(void) 119get_attrib(void)
120{ 120{
121 return decode_attrib(&iqueue); 121 return decode_attrib(&iqueue);
@@ -139,7 +139,7 @@ enum {
139 139
140Handle handles[100]; 140Handle handles[100];
141 141
142void 142static void
143handle_init(void) 143handle_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
151int 151static int
152handle_new(int use, char *name, int fd, DIR *dirp) 152handle_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
168int 168static int
169handle_is_ok(int i, int type) 169handle_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
175int 175static int
176handle_to_string(int handle, char **stringp, int *hlenp) 176handle_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
186int 186static int
187handle_from_string(char *handle, u_int hlen) 187handle_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
200char * 200static char *
201handle_to_name(int handle) 201handle_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
209DIR * 209static DIR *
210handle_to_dir(int handle) 210handle_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
217int 217static int
218handle_to_fd(int handle) 218handle_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
225int 225static int
226handle_close(int handle) 226handle_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
242int 242static int
243get_handle(void) 243get_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
258void 258static void
259send_msg(Buffer *m) 259send_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
268void 268static void
269send_status(u_int32_t id, u_int32_t error) 269send_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}
298void 298static void
299send_data_or_handle(char type, u_int32_t id, char *data, int dlen) 299send_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
311void 311static void
312send_data(u_int32_t id, char *data, int dlen) 312send_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
318void 318static void
319send_handle(u_int32_t id, int handle) 319send_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
330void 330static void
331send_names(u_int32_t id, int count, Stat *stats) 331send_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
350void 350static void
351send_attrib(u_int32_t id, Attrib *a) 351send_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
366void 366static void
367process_init(void) 367process_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
380void 380static void
381process_open(void) 381process_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
412void 412static void
413process_close(void) 413process_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
426void 426static void
427process_read(void) 427process_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
466void 466static void
467process_write(void) 467process_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
504void 504static void
505process_do_stat(int do_lstat) 505process_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
529void 529static void
530process_stat(void) 530process_stat(void)
531{ 531{
532 process_do_stat(0); 532 process_do_stat(0);
533} 533}
534 534
535void 535static void
536process_lstat(void) 536process_lstat(void)
537{ 537{
538 process_do_stat(1); 538 process_do_stat(1);
539} 539}
540 540
541void 541static void
542process_fstat(void) 542process_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
567struct timeval * 567static struct timeval *
568attrib_to_tv(Attrib *a) 568attrib_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
579void 579static void
580process_setstat(void) 580process_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
611void 611static void
612process_fsetstat(void) 612process_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
660void 660static void
661process_opendir(void) 661process_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 */
692char * 692static char *
693ls_file(char *name, struct stat *st) 693ls_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
731void 731static void
732process_readdir(void) 732process_readdir(void)
733{ 733{
734 DIR *dirp; 734 DIR *dirp;
@@ -782,7 +782,7 @@ process_readdir(void)
782 } 782 }
783} 783}
784 784
785void 785static void
786process_remove(void) 786process_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
802void 802static void
803process_mkdir(void) 803process_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
822void 822static void
823process_rmdir(void) 823process_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
838void 838static void
839process_realpath(void) 839process_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
863void 863static void
864process_rename(void) 864process_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
885void 885static void
886process_readlink(void) 886process_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
909void 909static void
910process_symlink(void) 910process_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
931void 931static void
932process_extended(void) 932process_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
945void 945static void
946process(void) 946process(void)
947{ 947{
948 u_int msg_len; 948 u_int msg_len;