| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ftpd.c,v 1.164.2.3 2008/09/18 19:13:36 bouyer Exp $ */ | | 1 | /* $NetBSD: ftpd.c,v 1.164.2.4 2008/09/18 19:15:12 bouyer Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Luke Mewburn. | | 8 | * by Luke Mewburn. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -95,27 +95,27 @@ | | | @@ -95,27 +95,27 @@ |
95 | */ | | 95 | */ |
96 | | | 96 | |
97 | #include <sys/cdefs.h> | | 97 | #include <sys/cdefs.h> |
98 | #ifndef lint | | 98 | #ifndef lint |
99 | __COPYRIGHT( | | 99 | __COPYRIGHT( |
100 | "@(#) Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994\n\ | | 100 | "@(#) Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994\n\ |
101 | The Regents of the University of California. All rights reserved.\n"); | | 101 | The Regents of the University of California. All rights reserved.\n"); |
102 | #endif /* not lint */ | | 102 | #endif /* not lint */ |
103 | | | 103 | |
104 | #ifndef lint | | 104 | #ifndef lint |
105 | #if 0 | | 105 | #if 0 |
106 | static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95"; | | 106 | static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95"; |
107 | #else | | 107 | #else |
108 | __RCSID("$NetBSD: ftpd.c,v 1.164.2.3 2008/09/18 19:13:36 bouyer Exp $"); | | 108 | __RCSID("$NetBSD: ftpd.c,v 1.164.2.4 2008/09/18 19:15:12 bouyer Exp $"); |
109 | #endif | | 109 | #endif |
110 | #endif /* not lint */ | | 110 | #endif /* not lint */ |
111 | | | 111 | |
112 | /* | | 112 | /* |
113 | * FTP server. | | 113 | * FTP server. |
114 | */ | | 114 | */ |
115 | #include <sys/param.h> | | 115 | #include <sys/param.h> |
116 | #include <sys/stat.h> | | 116 | #include <sys/stat.h> |
117 | #include <sys/ioctl.h> | | 117 | #include <sys/ioctl.h> |
118 | #include <sys/socket.h> | | 118 | #include <sys/socket.h> |
119 | #include <sys/wait.h> | | 119 | #include <sys/wait.h> |
120 | #include <sys/mman.h> | | 120 | #include <sys/mman.h> |
121 | #include <sys/resource.h> | | 121 | #include <sys/resource.h> |
| @@ -2374,31 +2374,32 @@ statcmd(void) | | | @@ -2374,31 +2374,32 @@ statcmd(void) |
2374 | ispassive = 0; | | 2374 | ispassive = 0; |
2375 | if (data != -1) { | | 2375 | if (data != -1) { |
2376 | reply(0, "Data connection open"); | | 2376 | reply(0, "Data connection open"); |
2377 | su = NULL; | | 2377 | su = NULL; |
2378 | } else if (pdata != -1) { | | 2378 | } else if (pdata != -1) { |
2379 | reply(0, "in Passive mode"); | | 2379 | reply(0, "in Passive mode"); |
2380 | if (curclass.advertise.su_len != 0) | | 2380 | if (curclass.advertise.su_len != 0) |
2381 | su = &curclass.advertise; | | 2381 | su = &curclass.advertise; |
2382 | else | | 2382 | else |
2383 | su = &pasv_addr; | | 2383 | su = &pasv_addr; |
2384 | ispassive = 1; | | 2384 | ispassive = 1; |
2385 | goto printaddr; | | 2385 | goto printaddr; |
2386 | } else if (usedefault == 0) { | | 2386 | } else if (usedefault == 0) { |
| | | 2387 | su = (struct sockinet *)&data_dest; |
| | | 2388 | |
2387 | if (epsvall) { | | 2389 | if (epsvall) { |
2388 | reply(0, "EPSV only mode (EPSV ALL)"); | | 2390 | reply(0, "EPSV only mode (EPSV ALL)"); |
2389 | goto epsvonly; | | 2391 | goto epsvonly; |
2390 | } | | 2392 | } |
2391 | su = (struct sockinet *)&data_dest; | | | |
2392 | printaddr: | | 2393 | printaddr: |
2393 | /* PASV/PORT */ | | 2394 | /* PASV/PORT */ |
2394 | if (su->su_family == AF_INET) { | | 2395 | if (su->su_family == AF_INET) { |
2395 | a = (u_char *) &su->su_addr; | | 2396 | a = (u_char *) &su->su_addr; |
2396 | p = (u_char *) &su->su_port; | | 2397 | p = (u_char *) &su->su_port; |
2397 | #define UC(b) (((int) b) & 0xff) | | 2398 | #define UC(b) (((int) b) & 0xff) |
2398 | reply(0, "%s (%d,%d,%d,%d,%d,%d)", | | 2399 | reply(0, "%s (%d,%d,%d,%d,%d,%d)", |
2399 | ispassive ? "PASV" : "PORT" , | | 2400 | ispassive ? "PASV" : "PORT" , |
2400 | UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), | | 2401 | UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), |
2401 | UC(p[0]), UC(p[1])); | | 2402 | UC(p[0]), UC(p[1])); |
2402 | } | | 2403 | } |
2403 | | | 2404 | |
2404 | /* LPSV/LPRT */ | | 2405 | /* LPSV/LPRT */ |