diff options
author | davidn <davidn@FreeBSD.org> | 1997-04-26 12:12:10 +0000 |
---|---|---|
committer | davidn <davidn@FreeBSD.org> | 1997-04-26 12:12:10 +0000 |
commit | a1afe7148074c37601ddb27c0db42c7e7e29ac69 (patch) | |
tree | 91a142b078eba657ed76e534ddca5851a3f61c20 /libexec/ftpd | |
parent | 6323aa10bffe459912ba8b2f8592c7ac4ffd8705 (diff) | |
download | FreeBSD-src-a1afe7148074c37601ddb27c0db42c7e7e29ac69.zip FreeBSD-src-a1afe7148074c37601ddb27c0db42c7e7e29ac69.tar.gz |
Adds optional "internal ls" support for ftpd, by collecting
modules from src/bin/ls, and handling exec(_PATH_LS,..) as a
special case, very useful in an environment where many users
are given chroot access. "~/etc/{s}pwd.db" files are still
needed if uid/gid->user/group translation is desired.
To enable this it must be compiled with the make variable
FTP_INTERNAL_LS defined, either in /etc/make.conf or the
environment.
Diffstat (limited to 'libexec/ftpd')
-rw-r--r-- | libexec/ftpd/Makefile | 9 | ||||
-rw-r--r-- | libexec/ftpd/extern.h | 5 | ||||
-rw-r--r-- | libexec/ftpd/ftpd.c | 11 | ||||
-rw-r--r-- | libexec/ftpd/pathnames.h | 3 | ||||
-rw-r--r-- | libexec/ftpd/popen.c | 21 |
5 files changed, 41 insertions, 8 deletions
diff --git a/libexec/ftpd/Makefile b/libexec/ftpd/Makefile index 20fc19f..6bb3bdb 100644 --- a/libexec/ftpd/Makefile +++ b/libexec/ftpd/Makefile @@ -1,5 +1,5 @@ # @(#)Makefile 8.2 (Berkeley) 4/4/94 -# $Id: Makefile,v 1.19 1997/02/22 14:21:26 peter Exp $ +# $Id: Makefile,v 1.20 1997/04/23 04:56:39 davidn Exp $ PROG= ftpd MAN8= ftpd.8 @@ -12,6 +12,13 @@ DPADD= ${LIBSKEY} ${LIBMD} ${LIBCRYPT} ${LIBUTIL} CLEANFILES+=ftpcmd.c y.tab.h +.ifdef FTPD_INTERNAL_LS +LSDIR= ../../bin/ls +.PATH: ${.CURDIR}/${LSDIR} +SRCS+= ls.c cmp.c print.c stat_flags.c util.c +CFLAGS+=-DINTERNAL_LS -Dmain=ls_main -I${.CURDIR}/${LSDIR} +.endif + .if exists(${DESTDIR}/usr/lib/libkrb.a) && defined(MAKE_EBONES) .PATH: ${.CURDIR}/../../usr.bin/login SRCS+= klogin.c diff --git a/libexec/ftpd/extern.h b/libexec/ftpd/extern.h index ff1cdfb..616da79 100644 --- a/libexec/ftpd/extern.h +++ b/libexec/ftpd/extern.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 4/4/94 - * $Id$ + * $Id: extern.h,v 1.8 1997/02/22 14:21:26 peter Exp $ */ void blkfree __P((char **)); @@ -70,3 +70,6 @@ int yyparse __P((void)); #if defined(SKEY) && defined(_PWD_H_) /* XXX evil */ char *skey_challenge __P((char *, struct passwd *, int)); #endif +#if defined(INTERNAL_LS) +int ls_main __P((int, char **)); +#endif diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index 36fbbab..8c6578a 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ftpd.c,v 1.34 1997/03/28 15:48:09 imp Exp $ + * $Id: ftpd.c,v 1.35 1997/04/23 04:56:39 davidn Exp $ */ #if 0 @@ -102,7 +102,12 @@ static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94"; #include <varargs.h> #endif +#ifdef INTERNAL_LS +static char version[] = "Version 6.00LS"; +#undef main +#else static char version[] = "Version 6.00"; +#endif extern off_t restart_point; extern char cbuf[]; @@ -1388,7 +1393,7 @@ statfilecmd(filename) int c; char line[LINE_MAX]; - (void)snprintf(line, sizeof(line), "/bin/ls -lgA %s", filename); + (void)snprintf(line, sizeof(line), _PATH_LS " -lgA %s", filename); fin = ftpd_popen(line, "r"); lreply(211, "status of %s:", filename); while ((c = getc(fin)) != EOF) { @@ -1899,7 +1904,7 @@ send_file_list(whichf) */ if (dirname[0] == '-' && *dirlist == NULL && transflag == 0) { - retrieve("/bin/ls %s", dirname); + retrieve(_PATH_LS " %s", dirname); goto out; } perror_reply(550, whichf); diff --git a/libexec/ftpd/pathnames.h b/libexec/ftpd/pathnames.h index 8842742..5b36082 100644 --- a/libexec/ftpd/pathnames.h +++ b/libexec/ftpd/pathnames.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - * $Id$ + * $Id: pathnames.h,v 1.8 1997/02/22 14:21:29 peter Exp $ */ #include <paths.h> @@ -40,3 +40,4 @@ #define _PATH_FTPWELCOME "/etc/ftpwelcome" #define _PATH_FTPLOGINMESG "/etc/ftpmotd" #define _PATH_FTPDSTATFILE "/var/log/ftpd" +#define _PATH_LS "/bin/ls" diff --git a/libexec/ftpd/popen.c b/libexec/ftpd/popen.c index b00235a..ac0b76a 100644 --- a/libexec/ftpd/popen.c +++ b/libexec/ftpd/popen.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: popen.c,v 1.7 1997/02/22 14:21:31 peter Exp $ */ #if 0 @@ -54,6 +54,9 @@ static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94"; #include <unistd.h> #include "extern.h" +#ifdef INTERNAL_LS +#include "pathnames.h" +#endif #define MAXUSRARGS 100 #define MAXGLOBARGS 1000 @@ -111,7 +114,13 @@ ftpd_popen(program, type) gargv[gargc] = NULL; iop = NULL; - switch(pid = vfork()) { +#ifdef INTERNAL_LS + fflush(NULL); + pid = (strcmp(gargv[0], _PATH_LS) == 0) ? fork() : vfork(); +#else + pid = vfork(); +#endif + switch(pid) { case -1: /* error */ (void)close(pdes[0]); (void)close(pdes[1]); @@ -132,6 +141,14 @@ ftpd_popen(program, type) } (void)close(pdes[1]); } +#ifdef INTERNAL_LS + if (strcmp(gargv[0], _PATH_LS) == 0) { + extern int optreset; + /* Reset getopt for ls_main() */ + optreset = optind = optopt = 1; + exit(ls_main(gargc, gargv)); + } +#endif execv(gargv[0], gargv); _exit(1); } |