diff options
| author | lukem <lukem@NetBSD.org> | 1997-09-23 13:56:39 +0000 |
|---|---|---|
| committer | lukem <lukem@NetBSD.org> | 1997-09-23 13:56:39 +0000 |
| commit | 550665a81478c166997b7a00d76615df29b63129 (patch) | |
| tree | 95585a85af49b0e8f49c07cc3ba24cdde15957fc /libexec | |
| parent | a3683f2819e29c2ffdedaf36b70877d6743eb404 (diff) | |
implement '-c confdir', which allows the specification of an alternate
directory to look for the various configuration files, overriding /etc.
From Matthias Scheler <tron@lyssa.owl.de> in [bin/4133]
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ftpd/conf.c | 6 | ||||
| -rw-r--r-- | libexec/ftpd/extern.h | 4 | ||||
| -rw-r--r-- | libexec/ftpd/ftpd.8 | 8 | ||||
| -rw-r--r-- | libexec/ftpd/ftpd.c | 32 | ||||
| -rw-r--r-- | libexec/ftpd/pathnames.h | 14 |
5 files changed, 45 insertions, 19 deletions
diff --git a/libexec/ftpd/conf.c b/libexec/ftpd/conf.c index 4ad1f36522b..e06df29c7ab 100644 --- a/libexec/ftpd/conf.c +++ b/libexec/ftpd/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.5 1997/08/14 02:06:15 lukem Exp $ */ +/* $NetBSD: conf.c,v 1.6 1997/09/23 13:56:39 lukem Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: conf.c,v 1.5 1997/08/14 02:06:15 lukem Exp $"); +__RCSID("$NetBSD: conf.c,v 1.6 1997/09/23 13:56:39 lukem Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -106,7 +106,7 @@ parse_conf(findclass) curclass.modify = 0; } - infile = _PATH_FTPDCONF; + infile = conffilename(_PATH_FTPDCONF); if ((f = fopen(infile, "r")) == NULL) return; diff --git a/libexec/ftpd/extern.h b/libexec/ftpd/extern.h index 10c06d094e8..b5ee543dcf9 100644 --- a/libexec/ftpd/extern.h +++ b/libexec/ftpd/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.4 1997/06/18 19:05:48 christos Exp $ */ +/* $NetBSD: extern.h,v 1.5 1997/09/23 13:56:40 lukem Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,6 +36,7 @@ */ void blkfree __P((char **)); +char *conffilename __P((const char *)); char **copyblk __P((char **)); void cwd __P((char *)); void delete __P((char *)); @@ -68,7 +69,6 @@ void upper __P((char *)); void user __P((char *)); void yyerror __P((char *)); - #define CLASS_CHROOT "chroot" #define CLASS_GUEST "guest" #define CLASS_REAL "real" diff --git a/libexec/ftpd/ftpd.8 b/libexec/ftpd/ftpd.8 index 6a126e7b613..466a309f334 100644 --- a/libexec/ftpd/ftpd.8 +++ b/libexec/ftpd/ftpd.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftpd.8,v 1.15 1997/09/21 22:59:03 cjs Exp $ +.\" $NetBSD: ftpd.8,v 1.16 1997/09/23 13:56:41 lukem Exp $ .\" .\" Copyright (c) 1985, 1988, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -44,6 +44,7 @@ Internet File Transfer Protocol server .Nm .Op Fl dl .Op Fl a Ar anondir +.Op Fl c Ar confdir .Sh DESCRIPTION .Nm is the @@ -63,6 +64,11 @@ Define the directory to .Xr chroot 2 into for anonymous logins. Default is the home directory for the ftp user. +.It Fl c +Change the root directory of the configuration files from +.Dq Pa /etc +to +.Ar directory . .It Fl d Debugging information is written to the syslog using LOG_FTP. .It Fl l diff --git a/libexec/ftpd/ftpd.c b/libexec/ftpd/ftpd.c index e9f15146130..1fb1ff72f92 100644 --- a/libexec/ftpd/ftpd.c +++ b/libexec/ftpd/ftpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftpd.c,v 1.33 1997/09/18 07:27:35 lukem Exp $ */ +/* $NetBSD: ftpd.c,v 1.34 1997/09/23 13:56:42 lukem Exp $ */ /* * Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994 @@ -44,7 +44,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)ftpd.c 8.5 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: ftpd.c,v 1.33 1997/09/18 07:27:35 lukem Exp $"); +__RCSID("$NetBSD: ftpd.c,v 1.34 1997/09/23 13:56:42 lukem Exp $"); #endif #endif /* not lint */ @@ -132,6 +132,7 @@ char remotehost[MAXHOSTNAMELEN]; static char ttyline[20]; char *tty = ttyline; /* for klogin */ static char *anondir = NULL; +static char confdir[MAXPATHLEN]; extern struct ftpclass curclass; @@ -244,16 +245,22 @@ main(argc, argv, envp) #endif data_source.sin_port = htons(ntohs(ctrl_addr.sin_port) - 1); debug = 0; + (void)strcpy(confdir, _DEFAULT_CONFDIR); /* set this here so klogin can use it... */ (void)snprintf(ttyline, sizeof(ttyline), "ftp%d", getpid()); - while ((ch = getopt(argc, argv, "a:dlt:T:u:v")) != EOF) { + while ((ch = getopt(argc, argv, "a:c:dlt:T:u:v")) != EOF) { switch (ch) { case 'a': anondir = optarg; break; + case 'c': + (void)strncpy(confdir, optarg, sizeof(confdir)); + confdir[sizeof(confdir)-1] = '\0'; + break; + case 'd': case 'v': /* deprecated */ debug = 1; @@ -314,7 +321,7 @@ main(argc, argv, envp) reply(530, "System not available."); exit(0); } - if ((fd = fopen(_PATH_FTPWELCOME, "r")) != NULL) { + if ((fd = fopen(conffilename(_PATH_FTPWELCOME), "r")) != NULL) { while (fgets(line, sizeof(line), fd) != NULL) { if ((cp = strchr(line, '\n')) != NULL) *cp = '\0'; @@ -436,6 +443,7 @@ user(name) "ANONYMOUS FTP LOGIN REFUSED FROM %s", remotehost); return; } + pw = sgetpwnam(name); if (logging) strncpy(curname, name, sizeof(curname)-1); @@ -517,7 +525,7 @@ checkaccess(name) int retval = ALLOWED; char *glob, *perm, line[BUFSIZ]; - if ((fd = fopen(_PATH_FTPUSERS, "r")) == NULL) + if ((fd = fopen(conffilename(_PATH_FTPUSERS), "r")) == NULL) return NOT_ALLOWED; while (fgets(line, sizeof(line), fd) != NULL) { @@ -658,7 +666,7 @@ skip: logwtmp(ttyline, pw->pw_name, remotehost); logged_in = 1; - dochroot = checkuser(_PATH_FTPCHROOT, pw->pw_name); + dochroot = checkuser(conffilename(_PATH_FTPCHROOT), pw->pw_name); /* parse ftpd.conf, setting up various parameters */ if (guest) @@ -700,7 +708,7 @@ skip: * Display a login message, if it exists. * N.B. reply(230,) must follow the message. */ - if ((fd = fopen(_PATH_FTPLOGINMESG, "r")) != NULL) { + if ((fd = fopen(conffilename(_PATH_FTPLOGINMESG), "r")) != NULL) { char *cp, line[LINE_MAX]; while (fgets(line, sizeof(line), fd) != NULL) { @@ -1805,3 +1813,13 @@ out: globfree(&gl); } } + +char * +conffilename(s) + const char *s; +{ + static char filename[MAXPATHLEN]; + + (void)snprintf(filename, sizeof(filename), "%s/%s", confdir ,s); + return filename; +} diff --git a/libexec/ftpd/pathnames.h b/libexec/ftpd/pathnames.h index 0bfc6ad4dcd..434af6fce05 100644 --- a/libexec/ftpd/pathnames.h +++ b/libexec/ftpd/pathnames.h @@ -1,4 +1,4 @@ -/* $NetBSD: pathnames.h,v 1.6 1997/06/14 08:43:32 lukem Exp $ */ +/* $NetBSD: pathnames.h,v 1.7 1997/09/23 13:56:43 lukem Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,8 +37,10 @@ #include <paths.h> -#define _PATH_FTPCHROOT "/etc/ftpchroot" -#define _PATH_FTPDCONF "/etc/ftpd.conf" -#define _PATH_FTPLOGINMESG "/etc/motd" -#define _PATH_FTPUSERS "/etc/ftpusers" -#define _PATH_FTPWELCOME "/etc/ftpwelcome" +#define _DEFAULT_CONFDIR "/etc" + +#define _PATH_FTPCHROOT "ftpchroot" +#define _PATH_FTPDCONF "ftpd.conf" +#define _PATH_FTPLOGINMESG "motd" +#define _PATH_FTPUSERS "ftpusers" +#define _PATH_FTPWELCOME "ftpwelcome" |
