2000-12-18 05:32:50 +03:00
|
|
|
/* $NetBSD: extern.h,v 1.37 2000/12/18 02:32:51 lukem Exp $ */
|
1999-07-02 09:52:14 +04:00
|
|
|
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
1999-07-02 09:52:14 +04:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
1999-07-02 09:52:14 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
1999-07-02 09:52:14 +04:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
1999-07-02 09:52:14 +04:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
*
|
|
|
|
* @(#)extern.h 8.2 (Berkeley) 4/4/94
|
1999-07-02 09:52:14 +04:00
|
|
|
*/
|
1995-04-11 06:44:45 +04:00
|
|
|
|
1994-06-29 05:49:37 +04:00
|
|
|
/*-
|
2000-01-08 14:09:56 +03:00
|
|
|
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Luke Mewburn.
|
1994-06-29 05:49:37 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1997 and 1998 WIDE Project.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the project nor the names of its contributors
|
1994-06-29 05:49:37 +04:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
1994-06-29 05:49:37 +04:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
1994-06-29 05:49:37 +04:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2000-11-16 16:15:13 +03:00
|
|
|
#ifdef NO_LONG_LONG
|
|
|
|
# define LLF "%ld"
|
|
|
|
# define LLFP(x) "%" x "ld"
|
|
|
|
# define LLT long
|
|
|
|
# define ULLF "%lu"
|
|
|
|
# define ULLFP(x) "%" x "lu"
|
|
|
|
# define ULLT unsigned long
|
|
|
|
# define STRTOLL(x,y,z) strtol(x,y,z)
|
|
|
|
#else
|
|
|
|
# define LLF "%lld"
|
|
|
|
# define LLFP(x) "%" x "lld"
|
|
|
|
# define LLT long long
|
|
|
|
# define ULLF "%llu"
|
|
|
|
# define ULLFP(x) "%" x "llu"
|
|
|
|
# define ULLT unsigned long long
|
|
|
|
# define STRTOLL(x,y,z) strtoll(x,y,z)
|
|
|
|
#endif
|
|
|
|
|
2000-05-20 06:20:18 +04:00
|
|
|
void blkfree(char **);
|
various fixes suggested by Robert Elz:
* implement closedataconn() and use appropriately (including in mlsd())
* only put leading space in front of MLST output (not MLSD output)
* MLSD: only output pdir and cdir entries when the type fact is requested.
* change error code for giving MLSD a non-directory from 550 to 501
* remove MLSx Type fact support for UNIX.* for now; it's not standardised yet.
* do a check_login when MLSD and MLST are given no args
* detect & complain about null facts in OPTS MLST
* cache getgroups() at login instead of calling each time in fact_perm()
other mods:
* implement cprintf(); as per fprintf() but increments total_bytes{,_out}
* implement CPUTC(); as per putc() but increments total_bytes{,_out}
* implement base64_encode()
* fact_unique() display base64 encoding of dev_t and ino_t rather than
hex output; should scale if size of those changes
* change reply() so that a negative code acts as the initial line in a reply,
code == 0 prefixes the line with 4 spaces, and code > 0 works as before.
deprecate lreply(code, ) and lreply(0, ) in favour of reply(-code, ) and
reply(0, ) respectively.
* use cprintf() and CPUTC() appropriately (often instead of printf(),
lreply(-2, ) or lreply(-1, ).
now we actually account for the data sent by MLST and MLSD.
* remove DEBUG support for sending MLSD output to control connection instead
of data connection (my ftp client now supports MLSD :-)
2000-06-19 19:15:03 +04:00
|
|
|
void closedataconn(FILE *);
|
2000-05-20 06:20:18 +04:00
|
|
|
char *conffilename(const char *);
|
|
|
|
char **copyblk(char **);
|
|
|
|
void count_users(void);
|
2000-07-08 22:24:28 +04:00
|
|
|
void cprintf(FILE *, const char *, ...)
|
|
|
|
__attribute__((__format__(__printf__, 2, 3)));
|
2000-05-20 06:20:18 +04:00
|
|
|
void cwd(const char *);
|
2000-06-14 17:44:21 +04:00
|
|
|
FILE *dataconn(const char *, off_t, const char *);
|
2000-05-20 06:20:18 +04:00
|
|
|
void delete(const char *);
|
2000-07-17 06:30:52 +04:00
|
|
|
int display_file(const char *, int);
|
2000-05-20 06:20:18 +04:00
|
|
|
char **do_conversion(const char *);
|
|
|
|
void dologout(int);
|
|
|
|
void fatal(const char *);
|
2000-06-14 17:44:21 +04:00
|
|
|
void feat(void);
|
2000-07-17 06:30:52 +04:00
|
|
|
void format_path(char *, const char *);
|
2000-05-20 06:20:18 +04:00
|
|
|
int ftpd_pclose(FILE *);
|
|
|
|
FILE *ftpd_popen(char *[], const char *, int);
|
|
|
|
char *getline(char *, int, FILE *);
|
|
|
|
void init_curclass(void);
|
2000-12-18 05:32:50 +03:00
|
|
|
void logxfer(const char *, off_t, const char *, const char *,
|
2000-05-20 06:20:18 +04:00
|
|
|
const struct timeval *, const char *);
|
|
|
|
void logwtmp(const char *, const char *, const char *);
|
2000-06-14 17:44:21 +04:00
|
|
|
struct tab *lookup(struct tab *, const char *);
|
2000-05-20 06:20:18 +04:00
|
|
|
void makedir(const char *);
|
2000-06-14 17:44:21 +04:00
|
|
|
void mlsd(const char *);
|
|
|
|
void mlst(const char *);
|
|
|
|
void opts(const char *);
|
2000-05-20 06:20:18 +04:00
|
|
|
void parse_conf(const char *);
|
|
|
|
void pass(const char *);
|
|
|
|
void passive(void);
|
2000-11-13 14:50:46 +03:00
|
|
|
int lpsvproto2af(int);
|
|
|
|
int af2lpsvproto(int);
|
|
|
|
int epsvproto2af(int);
|
|
|
|
int af2epsvproto(int);
|
2000-05-20 06:20:18 +04:00
|
|
|
void long_passive(char *, int);
|
2000-11-13 14:50:46 +03:00
|
|
|
int extended_port(const char *);
|
|
|
|
void epsv_protounsupp(const char *);
|
2000-05-20 06:20:18 +04:00
|
|
|
void perror_reply(int, const char *);
|
|
|
|
void pwd(void);
|
|
|
|
void removedir(const char *);
|
|
|
|
void renamecmd(const char *, const char *);
|
|
|
|
char *renamefrom(const char *);
|
2000-07-08 22:24:28 +04:00
|
|
|
void reply(int, const char *, ...)
|
|
|
|
__attribute__((__format__(__printf__, 2, 3)));
|
2000-05-20 06:20:18 +04:00
|
|
|
void retrieve(char *[], const char *);
|
|
|
|
void send_file_list(const char *);
|
|
|
|
void show_chdir_messages(int);
|
2000-06-14 17:44:21 +04:00
|
|
|
void sizecmd(const char *);
|
2000-05-20 06:20:18 +04:00
|
|
|
void statcmd(void);
|
|
|
|
void statfilecmd(const char *);
|
|
|
|
void store(const char *, const char *, int);
|
2000-11-16 16:15:13 +03:00
|
|
|
LLT strsuftoll(const char *);
|
2000-05-20 06:20:18 +04:00
|
|
|
void user(const char *);
|
|
|
|
char *xstrdup(const char *);
|
|
|
|
void yyerror(char *);
|
* implement /etc/ftpd.conf, which adds support for the following features,
controllable on a per class (which is one of: real, chroot, guest,
all or none) basis:
* on-the-fly execution of a command to build the file (a ``conversion''),
providing support for "get dirname.tar" and the like.
* displaying the contents of a file when a directory is entered
for the first time.
* maximum value for timeout (replaces -T).
* control usage of CHMOD, DELE, MKD, RMD, UMASK; replacing -DINSECURE_GUEST.
* notifying the user of the existance of a files matching a glob
pattern when a directory is entered for the first time.
* default value for timeout (replaces -t).
* default umask (replaces -DGUEST_CMASK and -u).
The conversion, display, and notify functionality was based on code by
Simon Burge <simonb@telstra.com.au>.
* clean up and re-order parts of the man page into subsections.
* STAT displays the settings defined for the class of the current user.
* bump version from 6.00 to 7.00, because of ftpd.conf.
* deprecate -DGUEST_CMASK and -DINSECURE_GUEST in the Makefile, and
-t, -T and -u, as ftpd.conf allows finer control of these.
* add "nostderr" argument to ftpd_popen(), because you don't want the
stderr stream mixing with the stdout stream during a conversion,
as this can corrupt the stream.
1997-06-14 12:43:26 +04:00
|
|
|
|
2000-12-18 05:32:50 +03:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#ifdef BSD4_4
|
|
|
|
# define HAVE_SETPROCTITLE 1
|
|
|
|
# define HAVE_SOCKADDR_SA_LEN 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct sockinet {
|
|
|
|
union sockunion {
|
|
|
|
struct sockaddr_in su_sin;
|
|
|
|
#ifdef INET6
|
|
|
|
struct sockaddr_in6 su_sin6;
|
|
|
|
#endif
|
|
|
|
} si_su;
|
|
|
|
#if !HAVE_SOCKADDR_SA_LEN
|
|
|
|
int si_len;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#if !HAVE_SOCKADDR_SA_LEN
|
|
|
|
# define su_len si_len
|
|
|
|
#else
|
|
|
|
# define su_len si_su.su_sin.sin_len
|
|
|
|
#endif
|
|
|
|
#define su_addr si_su.su_sin.sin_addr
|
|
|
|
#define su_family si_su.su_sin.sin_family
|
|
|
|
#define su_port si_su.su_sin.sin_port
|
|
|
|
#ifdef INET6
|
|
|
|
# define su_6addr si_su.su_sin6.sin6_addr
|
|
|
|
# define su_scope_id si_su.su_sin6.sin6_scope_id
|
|
|
|
#endif
|
|
|
|
|
2000-06-14 17:44:21 +04:00
|
|
|
struct tab {
|
|
|
|
char *name;
|
|
|
|
short token;
|
|
|
|
short state;
|
|
|
|
short flags; /* 1 if command implemented, 2 if has options */
|
|
|
|
char *help;
|
|
|
|
char *options;
|
|
|
|
};
|
* implement /etc/ftpd.conf, which adds support for the following features,
controllable on a per class (which is one of: real, chroot, guest,
all or none) basis:
* on-the-fly execution of a command to build the file (a ``conversion''),
providing support for "get dirname.tar" and the like.
* displaying the contents of a file when a directory is entered
for the first time.
* maximum value for timeout (replaces -T).
* control usage of CHMOD, DELE, MKD, RMD, UMASK; replacing -DINSECURE_GUEST.
* notifying the user of the existance of a files matching a glob
pattern when a directory is entered for the first time.
* default value for timeout (replaces -t).
* default umask (replaces -DGUEST_CMASK and -u).
The conversion, display, and notify functionality was based on code by
Simon Burge <simonb@telstra.com.au>.
* clean up and re-order parts of the man page into subsections.
* STAT displays the settings defined for the class of the current user.
* bump version from 6.00 to 7.00, because of ftpd.conf.
* deprecate -DGUEST_CMASK and -DINSECURE_GUEST in the Makefile, and
-t, -T and -u, as ftpd.conf allows finer control of these.
* add "nostderr" argument to ftpd_popen(), because you don't want the
stderr stream mixing with the stdout stream during a conversion,
as this can corrupt the stream.
1997-06-14 12:43:26 +04:00
|
|
|
|
|
|
|
struct ftpconv {
|
|
|
|
struct ftpconv *next;
|
1997-06-18 23:05:46 +04:00
|
|
|
char *suffix; /* Suffix of requested name */
|
|
|
|
char *types; /* Valid file types */
|
|
|
|
char *disable; /* File to disable conversions */
|
|
|
|
char *command; /* Command to do the conversion */
|
* implement /etc/ftpd.conf, which adds support for the following features,
controllable on a per class (which is one of: real, chroot, guest,
all or none) basis:
* on-the-fly execution of a command to build the file (a ``conversion''),
providing support for "get dirname.tar" and the like.
* displaying the contents of a file when a directory is entered
for the first time.
* maximum value for timeout (replaces -T).
* control usage of CHMOD, DELE, MKD, RMD, UMASK; replacing -DINSECURE_GUEST.
* notifying the user of the existance of a files matching a glob
pattern when a directory is entered for the first time.
* default value for timeout (replaces -t).
* default umask (replaces -DGUEST_CMASK and -u).
The conversion, display, and notify functionality was based on code by
Simon Burge <simonb@telstra.com.au>.
* clean up and re-order parts of the man page into subsections.
* STAT displays the settings defined for the class of the current user.
* bump version from 6.00 to 7.00, because of ftpd.conf.
* deprecate -DGUEST_CMASK and -DINSECURE_GUEST in the Makefile, and
-t, -T and -u, as ftpd.conf allows finer control of these.
* add "nostderr" argument to ftpd_popen(), because you don't want the
stderr stream mixing with the stdout stream during a conversion,
as this can corrupt the stream.
1997-06-14 12:43:26 +04:00
|
|
|
};
|
|
|
|
|
2000-11-16 16:15:13 +03:00
|
|
|
typedef enum {
|
|
|
|
CLASS_GUEST,
|
|
|
|
CLASS_CHROOT,
|
|
|
|
CLASS_REAL
|
|
|
|
} class_ft;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
FLAG_checkportcmd = 1<<0, /* Check port commands */
|
|
|
|
FLAG_modify = 1<<1, /* Allow CHMOD, DELE, MKD, RMD, RNFR,
|
|
|
|
UMASK */
|
|
|
|
FLAG_passive = 1<<2, /* Allow PASV mode */
|
|
|
|
FLAG_sanenames = 1<<3, /* Restrict names of uploaded files */
|
|
|
|
FLAG_upload = 1<<4 /* As per modify, but also allow
|
|
|
|
APPE, STOR, STOU */
|
|
|
|
} classflag_t;
|
|
|
|
|
|
|
|
#define CURCLASS_FLAGS_SET(x) (curclass.flags |= (FLAG_ ## x))
|
|
|
|
#define CURCLASS_FLAGS_CLR(x) (curclass.flags &= ~(FLAG_ ## x))
|
|
|
|
#define CURCLASS_FLAGS_ISSET(x) (curclass.flags & (FLAG_ ## x))
|
|
|
|
|
* implement /etc/ftpd.conf, which adds support for the following features,
controllable on a per class (which is one of: real, chroot, guest,
all or none) basis:
* on-the-fly execution of a command to build the file (a ``conversion''),
providing support for "get dirname.tar" and the like.
* displaying the contents of a file when a directory is entered
for the first time.
* maximum value for timeout (replaces -T).
* control usage of CHMOD, DELE, MKD, RMD, UMASK; replacing -DINSECURE_GUEST.
* notifying the user of the existance of a files matching a glob
pattern when a directory is entered for the first time.
* default value for timeout (replaces -t).
* default umask (replaces -DGUEST_CMASK and -u).
The conversion, display, and notify functionality was based on code by
Simon Burge <simonb@telstra.com.au>.
* clean up and re-order parts of the man page into subsections.
* STAT displays the settings defined for the class of the current user.
* bump version from 6.00 to 7.00, because of ftpd.conf.
* deprecate -DGUEST_CMASK and -DINSECURE_GUEST in the Makefile, and
-t, -T and -u, as ftpd.conf allows finer control of these.
* add "nostderr" argument to ftpd_popen(), because you don't want the
stderr stream mixing with the stdout stream during a conversion,
as this can corrupt the stream.
1997-06-14 12:43:26 +04:00
|
|
|
struct ftpclass {
|
2000-12-18 05:32:50 +03:00
|
|
|
struct sockinet advertise; /* PASV address to advertise as */
|
2000-07-17 06:30:52 +04:00
|
|
|
char *chroot; /* Directory to chroot(2) to at login */
|
1997-06-18 23:05:46 +04:00
|
|
|
char *classname; /* Current class */
|
1999-12-07 08:30:53 +03:00
|
|
|
struct ftpconv *conversions; /* List of conversions */
|
2000-11-16 16:15:13 +03:00
|
|
|
char *display; /* File to display upon chdir */
|
2000-07-17 06:30:52 +04:00
|
|
|
char *homedir; /* Directory to chdir(2) to at login */
|
2000-11-16 16:15:13 +03:00
|
|
|
classflag_t flags; /* Flags; see classflag_t above */
|
2000-01-08 14:09:56 +03:00
|
|
|
int limit; /* Max connections (-1 = unlimited) */
|
|
|
|
char *limitfile; /* File to display if limit reached */
|
2000-11-16 16:15:13 +03:00
|
|
|
LLT maxfilesize; /* Maximum file size of uploads */
|
|
|
|
LLT maxrateget; /* Maximum get transfer rate throttle */
|
|
|
|
LLT maxrateput; /* Maximum put transfer rate throttle */
|
* implement /etc/ftpd.conf, which adds support for the following features,
controllable on a per class (which is one of: real, chroot, guest,
all or none) basis:
* on-the-fly execution of a command to build the file (a ``conversion''),
providing support for "get dirname.tar" and the like.
* displaying the contents of a file when a directory is entered
for the first time.
* maximum value for timeout (replaces -T).
* control usage of CHMOD, DELE, MKD, RMD, UMASK; replacing -DINSECURE_GUEST.
* notifying the user of the existance of a files matching a glob
pattern when a directory is entered for the first time.
* default value for timeout (replaces -t).
* default umask (replaces -DGUEST_CMASK and -u).
The conversion, display, and notify functionality was based on code by
Simon Burge <simonb@telstra.com.au>.
* clean up and re-order parts of the man page into subsections.
* STAT displays the settings defined for the class of the current user.
* bump version from 6.00 to 7.00, because of ftpd.conf.
* deprecate -DGUEST_CMASK and -DINSECURE_GUEST in the Makefile, and
-t, -T and -u, as ftpd.conf allows finer control of these.
* add "nostderr" argument to ftpd_popen(), because you don't want the
stderr stream mixing with the stdout stream during a conversion,
as this can corrupt the stream.
1997-06-14 12:43:26 +04:00
|
|
|
unsigned int maxtimeout; /* Maximum permitted timeout */
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
char *motd; /* MotD file to display after login */
|
1997-06-18 23:05:46 +04:00
|
|
|
char *notify; /* Files to notify about upon chdir */
|
2000-01-13 01:39:27 +03:00
|
|
|
int portmin; /* Minumum port for passive mode */
|
|
|
|
int portmax; /* Maximum port for passive mode */
|
2000-11-16 16:15:13 +03:00
|
|
|
LLT rateget; /* Get (RETR) transfer rate throttle */
|
|
|
|
LLT rateput; /* Put (STOR) transfer rate throttle */
|
* implement /etc/ftpd.conf, which adds support for the following features,
controllable on a per class (which is one of: real, chroot, guest,
all or none) basis:
* on-the-fly execution of a command to build the file (a ``conversion''),
providing support for "get dirname.tar" and the like.
* displaying the contents of a file when a directory is entered
for the first time.
* maximum value for timeout (replaces -T).
* control usage of CHMOD, DELE, MKD, RMD, UMASK; replacing -DINSECURE_GUEST.
* notifying the user of the existance of a files matching a glob
pattern when a directory is entered for the first time.
* default value for timeout (replaces -t).
* default umask (replaces -DGUEST_CMASK and -u).
The conversion, display, and notify functionality was based on code by
Simon Burge <simonb@telstra.com.au>.
* clean up and re-order parts of the man page into subsections.
* STAT displays the settings defined for the class of the current user.
* bump version from 6.00 to 7.00, because of ftpd.conf.
* deprecate -DGUEST_CMASK and -DINSECURE_GUEST in the Makefile, and
-t, -T and -u, as ftpd.conf allows finer control of these.
* add "nostderr" argument to ftpd_popen(), because you don't want the
stderr stream mixing with the stdout stream during a conversion,
as this can corrupt the stream.
1997-06-14 12:43:26 +04:00
|
|
|
unsigned int timeout; /* Default timeout */
|
2000-06-14 17:44:21 +04:00
|
|
|
class_ft type; /* Class type */
|
* implement /etc/ftpd.conf, which adds support for the following features,
controllable on a per class (which is one of: real, chroot, guest,
all or none) basis:
* on-the-fly execution of a command to build the file (a ``conversion''),
providing support for "get dirname.tar" and the like.
* displaying the contents of a file when a directory is entered
for the first time.
* maximum value for timeout (replaces -T).
* control usage of CHMOD, DELE, MKD, RMD, UMASK; replacing -DINSECURE_GUEST.
* notifying the user of the existance of a files matching a glob
pattern when a directory is entered for the first time.
* default value for timeout (replaces -t).
* default umask (replaces -DGUEST_CMASK and -u).
The conversion, display, and notify functionality was based on code by
Simon Burge <simonb@telstra.com.au>.
* clean up and re-order parts of the man page into subsections.
* STAT displays the settings defined for the class of the current user.
* bump version from 6.00 to 7.00, because of ftpd.conf.
* deprecate -DGUEST_CMASK and -DINSECURE_GUEST in the Makefile, and
-t, -T and -u, as ftpd.conf allows finer control of these.
* add "nostderr" argument to ftpd_popen(), because you don't want the
stderr stream mixing with the stdout stream during a conversion,
as this can corrupt the stream.
1997-06-14 12:43:26 +04:00
|
|
|
mode_t umask; /* Umask to use */
|
|
|
|
};
|
1998-09-06 14:39:40 +04:00
|
|
|
|
2000-05-20 06:20:18 +04:00
|
|
|
extern int yyparse(void);
|
2000-01-13 01:39:27 +03:00
|
|
|
|
|
|
|
#ifndef GLOBAL
|
|
|
|
#define GLOBAL extern
|
|
|
|
#endif
|
|
|
|
|
2000-03-05 09:12:19 +03:00
|
|
|
|
2000-11-15 05:32:30 +03:00
|
|
|
GLOBAL struct sockinet ctrl_addr;
|
|
|
|
GLOBAL struct sockinet data_dest;
|
|
|
|
GLOBAL struct sockinet data_source;
|
|
|
|
GLOBAL struct sockinet his_addr;
|
|
|
|
GLOBAL struct sockinet pasv_addr;
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL int connections;
|
|
|
|
GLOBAL struct ftpclass curclass;
|
|
|
|
GLOBAL int debug;
|
|
|
|
GLOBAL jmp_buf errcatch;
|
2000-11-16 16:15:13 +03:00
|
|
|
GLOBAL char *emailaddr;
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL int form;
|
various fixes suggested by Robert Elz:
* implement closedataconn() and use appropriately (including in mlsd())
* only put leading space in front of MLST output (not MLSD output)
* MLSD: only output pdir and cdir entries when the type fact is requested.
* change error code for giving MLSD a non-directory from 550 to 501
* remove MLSx Type fact support for UNIX.* for now; it's not standardised yet.
* do a check_login when MLSD and MLST are given no args
* detect & complain about null facts in OPTS MLST
* cache getgroups() at login instead of calling each time in fact_perm()
other mods:
* implement cprintf(); as per fprintf() but increments total_bytes{,_out}
* implement CPUTC(); as per putc() but increments total_bytes{,_out}
* implement base64_encode()
* fact_unique() display base64 encoding of dev_t and ino_t rather than
hex output; should scale if size of those changes
* change reply() so that a negative code acts as the initial line in a reply,
code == 0 prefixes the line with 4 spaces, and code > 0 works as before.
deprecate lreply(code, ) and lreply(0, ) in favour of reply(-code, ) and
reply(0, ) respectively.
* use cprintf() and CPUTC() appropriately (often instead of printf(),
lreply(-2, ) or lreply(-1, ).
now we actually account for the data sent by MLST and MLSD.
* remove DEBUG support for sending MLSD output to control connection instead
of data connection (my ftp client now supports MLSD :-)
2000-06-19 19:15:03 +04:00
|
|
|
GLOBAL int gidcount; /* number of entries in gidlist[] */
|
|
|
|
GLOBAL gid_t gidlist[NGROUPS_MAX];
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL int hasyyerrored;
|
2000-03-05 09:12:19 +03:00
|
|
|
GLOBAL char hostname[MAXHOSTNAMELEN+1];
|
2000-07-17 06:30:52 +04:00
|
|
|
GLOBAL char homedir[MAXPATHLEN];
|
1998-09-06 14:39:40 +04:00
|
|
|
#ifdef KERBEROS5
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL krb5_context kcontext;
|
1998-09-06 14:39:40 +04:00
|
|
|
#endif
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL int logged_in;
|
|
|
|
GLOBAL int logging;
|
2000-03-05 09:12:19 +03:00
|
|
|
GLOBAL int pdata; /* for passive mode */
|
2000-11-30 05:59:11 +03:00
|
|
|
#if HAVE_SETPROCTITLE
|
2000-03-05 09:12:19 +03:00
|
|
|
GLOBAL char proctitle[BUFSIZ]; /* initial part of title */
|
|
|
|
#endif
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL struct passwd *pw;
|
2000-01-13 03:04:31 +03:00
|
|
|
GLOBAL int quietmessages;
|
2000-03-05 09:12:19 +03:00
|
|
|
GLOBAL char remotehost[MAXHOSTNAMELEN+1];
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL off_t restart_point;
|
2000-03-05 09:12:19 +03:00
|
|
|
GLOBAL char tmpline[7];
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL sig_atomic_t transflag;
|
|
|
|
GLOBAL int type;
|
2000-03-05 09:12:19 +03:00
|
|
|
GLOBAL int usedefault; /* for data transfers */
|
* make checkportcmd the default. this breaks third-party proxy ftp but
prevents the ftp bounce attack, and we should be secure out of the
box, not require users to tweak obscure stuff.
* allow the version string reported to clients to be changed with '-V vers'.
if vers is empty or `-', don't report a version.
* if -r is given, permanently drop root privs
* if not a REAL user (i.e, GUEST or CHROOT), and ftpd is running on a port
> IPPORT_RESERVED+1, permanently drop root privs
* don't bother reverting to root privs to logout of wtmp/utmp; since the
file descriptor is already open this isn't necessary.
* fix the binding of the port for the PORT/LPRT/EPRT connection to be the
ctrl_addr.su_port-1, not hardcoded to `20' (this was broken in the ipv6
merge). if root privs have been dropped, and this would be a port <
IPPORT_RESERVED, use a random port instead (which isn't RFC959 compliant
but it doesn't appear that many clients care).
* prevent login of a new user if privs have been dropped and already logged
in as a REAL user (existing check already stops GUEST & CHROOT users).
* move the port check stuff into a separate port_check() function, and use
for PORT, LPRT, and EPRT checks. inspired by freebsd
* minor KNF
* minor man page cleanup
2000-07-23 18:40:48 +04:00
|
|
|
GLOBAL const char *version;
|
2000-01-13 01:39:27 +03:00
|
|
|
|
2000-03-05 09:12:19 +03:00
|
|
|
/* total file data bytes */
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL off_t total_data_in, total_data_out, total_data;
|
2000-03-05 09:12:19 +03:00
|
|
|
/* total number of data files */
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL off_t total_files_in, total_files_out, total_files;
|
2000-03-05 09:12:19 +03:00
|
|
|
/* total bytes */
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL off_t total_bytes_in, total_bytes_out, total_bytes;
|
2000-03-05 09:12:19 +03:00
|
|
|
/* total number of xfers */
|
2000-01-13 01:39:27 +03:00
|
|
|
GLOBAL off_t total_xfers_in, total_xfers_out, total_xfers;
|
1999-05-17 19:14:53 +04:00
|
|
|
|
2000-06-14 17:44:21 +04:00
|
|
|
extern struct tab cmdtab[];
|
|
|
|
|
|
|
|
#define INTERNAL_LS "/bin/ls"
|
|
|
|
|
|
|
|
|
|
|
|
#define CMD_IMPLEMENTED(x) ((x)->flags != 0)
|
|
|
|
#define CMD_HAS_OPTIONS(x) ((x)->flags == 2)
|
|
|
|
|
various fixes suggested by Robert Elz:
* implement closedataconn() and use appropriately (including in mlsd())
* only put leading space in front of MLST output (not MLSD output)
* MLSD: only output pdir and cdir entries when the type fact is requested.
* change error code for giving MLSD a non-directory from 550 to 501
* remove MLSx Type fact support for UNIX.* for now; it's not standardised yet.
* do a check_login when MLSD and MLST are given no args
* detect & complain about null facts in OPTS MLST
* cache getgroups() at login instead of calling each time in fact_perm()
other mods:
* implement cprintf(); as per fprintf() but increments total_bytes{,_out}
* implement CPUTC(); as per putc() but increments total_bytes{,_out}
* implement base64_encode()
* fact_unique() display base64 encoding of dev_t and ino_t rather than
hex output; should scale if size of those changes
* change reply() so that a negative code acts as the initial line in a reply,
code == 0 prefixes the line with 4 spaces, and code > 0 works as before.
deprecate lreply(code, ) and lreply(0, ) in favour of reply(-code, ) and
reply(0, ) respectively.
* use cprintf() and CPUTC() appropriately (often instead of printf(),
lreply(-2, ) or lreply(-1, ).
now we actually account for the data sent by MLST and MLSD.
* remove DEBUG support for sending MLSD output to control connection instead
of data connection (my ftp client now supports MLSD :-)
2000-06-19 19:15:03 +04:00
|
|
|
#define CPUTC(c, f) do { \
|
|
|
|
putc(c, f); total_bytes++; total_bytes_out++; \
|
|
|
|
} while (0);
|
|
|
|
|
2000-06-14 17:44:21 +04:00
|
|
|
#define CURCLASSTYPE curclass.type == CLASS_GUEST ? "GUEST" : \
|
|
|
|
curclass.type == CLASS_CHROOT ? "CHROOT" : \
|
|
|
|
curclass.type == CLASS_REAL ? "REAL" : \
|
|
|
|
"<unknown>"
|
|
|
|
|
|
|
|
#define ISDOTDIR(x) (x[0] == '.' && x[1] == '\0')
|
|
|
|
#define ISDOTDOTDIR(x) (x[0] == '.' && x[1] == '.' && x[2] == '\0')
|
1999-05-17 19:14:53 +04:00
|
|
|
|
* change format of /etc/ftpusers lines from
userglob [allow|deny]
to
userglob[@host] [allow|deny [classname]]
where class is a userdefined classname.
- if host is given it may either be a CIDR address (e.g, `1.2.3.0/24') or a
hostglob (e.g, `*.foo.com'), and the remote host is matched against that.
- if classname is given, use that to match entries in ftpd.conf (defaults
to `guest' for `anonymous'/`ftp' logins, `chroot' for users found in
/etc/ftpchroot, and `real' for everyone else.
* implement new /etc/ftpd.conf directives:
classtype classname type set type of classname to GUEST, CHROOT, or REAL
motd classname file file to use instead of /etc/motd
rateget classname rate set rateget throttle to rate
rateput classname rate set rateput throttle to rate
upload classname allow/deny uploads (STOU, STOR, APPE). if
denied, also acts as `modify deny'.
* implement new `SITE' commands:
RATEGET as per /etc/ftpd.conf rateget, but cannot exceed that
RATEPUT as per /etc/ftpd.conf rateput, but cannot exceed that
* implement format_file(), which outputs a file to the user, parsing %
escapes. use to print /etc/ftpwelcome, /etc/motd, and the `display' file.
* implement strsuftoi() (from ftp(1)), which parses a number and
optional suffix (for use with rateget, etc)
* don't bother seteuid(0) ; bind(...) ; seteuid(pw->pw_uid), since
we don't need reserved ports (at wasn't getting them anyway).
* update & reorder copyrights
* use strlcpy() as appropriate
1999-12-12 17:05:54 +03:00
|
|
|
#define EMPTYSTR(p) ((p) == NULL || *(p) == '\0')
|
|
|
|
#define NEXTWORD(P, W) do { \
|
|
|
|
(W) = strsep(&(P), " \t"); \
|
|
|
|
} while ((W) != NULL && *(W) == '\0')
|
1999-05-17 19:14:53 +04:00
|
|
|
#define PLURAL(s) ((s) == 1 ? "" : "s")
|
2000-05-20 06:20:18 +04:00
|
|
|
#define REASSIGN(X,Y) do { if (X) free(X); (X)=(Y); } while (/*CONSTCOND*/0)
|
2000-11-15 05:32:30 +03:00
|
|
|
|
|
|
|
#ifndef IPPORT_ANONMAX
|
|
|
|
# define IPPORT_ANONMAX 65535
|
|
|
|
#endif
|