ftpshut.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/****************************************************************************
Copyright (c) 1999,2000 WU-FTPD Development Group.
All rights reserved.
Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
The Regents of the University of California.
Portions Copyright (c) 1993, 1994 Washington University in Saint Louis.
Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc.
Portions Copyright (c) 1989 Massachusetts Institute of Technology.
Portions Copyright (c) 1998 Sendmail, Inc.
Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman.
Portions Copyright (c) 1997 by Stan Barber.
Portions Copyright (c) 1997 by Kent Landfield.
Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
Free Software Foundation, Inc.
Use and distribution of this software and its source code are governed
by the terms and conditions of the WU-FTPD Software License ("LICENSE").
If you did not receive a copy of the license, it may be obtained online
$Id: ftpshut.c,v 1.12 2000/07/01 18:17:39 wuftpd Exp $
****************************************************************************/
/* ftpshut
* =======
* creates the ftpd shutdown file.
*/
#include "config.h"
#include <errno.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifdef TIME_WITH_SYS_TIME
#include <time.h>
#else
#ifdef HAVE_SYS_TIME_H
#else
#include <time.h>
#endif
#endif
#endif
#include "pathnames.h"
#define WIDTH 70
int verbose = 0;
#define MAXVIRTUALS 512
char *progname;
char *msgfiles[MAXVIRTUALS];
int numfiles = 0;
#ifdef VIRTUAL
#endif
void print_copyright(void);
{
int i;
int fnd;
/*
** Check to see if the message file path has already been
** seen. If so then there is no need to create it again.
*/
fnd = 0;
for (i = 0; i < numfiles; i++) {
fnd = 1;
break;
}
}
if (!fnd) {
return (1);
}
return (0);
}
{
return (1);
}
if (verbose)
return (0);
}
{
char *ptr;
int i = 0;
int j = 0;
while (*ptr++ != '\0') {
++i;
/* if we have a space, keep track of where and at what "count" */
if (*ptr == ' ') {
j = i;
}
/* magic cookies... */
if (*ptr == '%') {
++ptr;
switch (*ptr) {
case 'r':
case 's':
case 'd':
case 'T':
i = i + 24;
break;
case '\n':
i = 0;
break;
case 'C':
case 'R':
case 'L':
case 'U':
i = i + 10;
break;
case 'M':
case 'N':
i = i + 3;
break;
case '\0':
return;
/* break; */
default:
i = i + 1;
break;
}
}
/* break up the long lines... */
*sp = '\n';
i = i - j;
}
}
}
{
"Usage: %s [-d min] [-l min] now [\"message\"]\n", progname);
" %s [-d min] [-l min] +dd [\"message\"]\n", progname);
" %s [-d min] [-l min] HHMM [\"message\"]\n", progname);
}
{
int c;
extern int optind;
extern char *optarg;
char linebuf[1024];
char anonpath[MAXPATHLEN];
#ifdef VIRTUAL
#ifdef INET6
char hostaddress[INET6_ADDRSTRLEN];
#else
char hostaddress[32];
#endif
char root[MAXPATHLEN];
char accesspath[MAXPATHLEN];
char configdir[MAXPATHLEN];
char altmsgpath[MAXPATHLEN];
#endif
++progname;
else
switch (c) {
case 'v':
verbose++;
break;
case 'l':
break;
case 'd':
break;
case 'V':
exit(0);
default:
usage(-1);
}
}
exit(1);
}
exit(1);
}
exit(1);
}
else {
exit(1);
}
}
while (*myaclbuf != '\0') {
*--crptr = '\0';
*crptr = '\n';
/* save for future use */
}
}
/* three cases
* -- now
* -- +ddd
* -- HHMM
*/
c = -1;
}
}
exit(1);
}
}
}
if (c_time <= 0) {
usage(1);
}
exit(1);
}
/* do we have a shutdown message? */
else
/*
** Create the system shutdown message file at the location
** specified in the ftpaccess 'shutdown' directive. This
** is for support of real system users.
*/
/*
** Determine if the site supports anonymous ftp and if so, create
** the shutdown message file in the anonymous ftp area as well
** so that shutdown works appropriately for both real and guest
** accounts. Save in msgfiles array for later comparison.
*/
shutmsg);
}
#ifdef VIRTUAL
/*
** Search the Master access file for virtual ftp servers.
** If found, construct a path to the shutdown message file
** under the virtual server's root. Don't duplicate what
** is specified in the "ftp" account directory information.
*/
sp++;
sp++;
shutmsg);
if (newfile(altmsgpath))
}
}
}
/*
** Need to deal with the access files at the virtual domain directory
** locations specified in the ftpservers file.
*/
/* get rid of any trailing slash */
if (*sp == '/')
*sp = '\0';
/*
** check to see that a valid directory value was
** supplied and not something such as "INTERNAL"
**
** It is valid to have a string such as "INTERNAL" in the
** ftpservers entry. This is not an error. Silently ignore it.
*/
continue;
(void) fclose(accessfile);
continue;
}
}
/* need to find the root path */
sp++;
sp++;
break;
}
}
/* need to find the shutdown message file path */
sp++;
sp++;
break;
}
}
/*
** check to make sure the admin hasn't specified
** a complete path in the 'shutdown' directive.
*/
cp);
/*
** Check to see if the message file has been created elsewhere.
*/
if (newfile(altmsgpath))
}
}
#endif /* VIRTUAL */
exit(c > 0 ? 1 : 0);
}