ftpcount.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: ftpcount.c,v 1.22 2000/07/01 18:17:39 wuftpd Exp $
****************************************************************************/
#include "config.h"
#ifdef TSOL
#endif
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#ifdef HAVE_SYS_SYSLOG_H
#endif
#include <syslog.h>
#endif
#include <signal.h>
#include <time.h>
#include <ctype.h>
#include <limits.h>
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
#endif
#include "pathnames.h"
#include "extensions.h"
#if defined(HAVE_FCNTL_H)
#include <fcntl.h>
#endif
#ifdef VIRTUAL
#define ARGS "Vv"
#else
#define ARGS "V"
#endif
struct c_list {
char *class;
};
#ifdef VIRTUAL
#endif
void print_copyright(void);
char *progname;
/*************************************************************************/
/* FUNCTION : parse_time */
/* PURPOSE : Check a single valid-time-string against the current time */
/* and return whether or not a match occurs. */
/* ARGUMENTS : a pointer to the time-string */
/*************************************************************************/
{
static char *days[] =
{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Wk"};
validday = 0;
match = 1;
match = 0;
whattime += 2;
match = 1;
validday = 1;
}
}
}
if (!validday) {
validday = 1;
whattime += 3;
}
else
return (0);
}
return (1);
return (1);
}
else
return (1);
return (0);
}
/*************************************************************************/
/* FUNCTION : validtime */
/* PURPOSE : Break apart a set of valid time-strings and pass them to */
/* parse_time, returning whether or not ANY matches occurred */
/* ARGUMENTS : a pointer to the time-string */
/*************************************************************************/
{
char *nextptr;
int good;
while (1) {
*nextptr = '\0';
if (good)
return (1);
}
}
{
int limit;
while (*aclbuf != '\0') {
*--crptr = '\0';
*crptr = '\n';
return (limit);
}
}
}
}
return (-1);
}
/*************************************************************************/
/* FUNCTION : lock_fd */
/* PURPOSE : Lock a file. */
/* ARGUMENTS : File descriptor of file to lock. */
/*************************************************************************/
{
#ifndef HAVE_FLOCK
#endif
#ifdef HAVE_FLOCK
#ifndef NO_PID_SLEEP_MSGS
#endif
#else
#ifdef TSOL
}
#endif
#ifndef NO_PID_SLEEP_MSGS
#endif
#endif /* HAVE_FLOCK */
sleep(1);
}
#ifndef HAVE_FLOCK
#ifdef TSOL
}
#endif
#endif /* HAVE_FLOCK */
}
/*************************************************************************/
/* FUNCTION : unlock_fd */
/* PURPOSE : Unlock a file locked by lock_fd. */
/* ARGUMENTS : File descriptor of file to unlock. */
/*************************************************************************/
{
#ifndef HAVE_FLOCK
#endif
#ifdef HAVE_FLOCK
#else
#ifdef TSOL
}
#endif
#ifdef TSOL
}
#endif
#endif /* HAVE_FLOCK */
}
static int acl_countusers(char *class)
{
char pidfile[MAXPATHLEN];
char line[1024];
struct pidfile_header hdr;
if (pidfd == -1) {
return (0);
}
return (0);
}
}
/*
* Printing the process information can take a long time, and while we
* hold the lock no users can join or leave this class. To minimize the
* problem, read the whole PID file into memory then release the lock.
*/
return (0);
}
return (0);
}
count = 0;
procid = 0;
for (i = 0; i < n; i++) {
if (buf[i] == 0) {
}
else {
bits = 1;
for (j = 0; j < CHAR_BIT; j++) {
#if defined(SVR4)
#ifdef AIX
#else
#if defined (LINUX_BUT_NOT_REDHAT_6_0)
#else
#endif
#endif
#else
#endif
line[0] = '\0';
if (line[0] != '\0') {
size_t i;
count++;
}
}
bits <<= 1;
procid++;
}
}
}
return (count);
}
{
perror("malloc error in new_list");
exit(1);
}
}
else {
while (cp) {
}
}
}
{
return (-1);
}
perror("malloc error in add_list");
exit(1);
}
perror("malloc error in add_list");
exit(1);
}
return (1);
}
{
int limit;
return (1);
}
return (1);
}
return (0);
}
else {
return (1);
}
}
while (*myaclbuf != '\0') {
*--crptr = '\0';
*crptr = '\n';
/* returns class name */
/* we have a class with multiple "class..." lines so, only
* display one count... */
;
}
else {
#ifdef VIRTUAL
#endif
}
else {
printf("Service class %-20.20s - %3d users ",
}
if (limit == -1)
printf("(no maximum)\n");
else
}
}
}
return (0);
}
{
int c, exitval;
int virtual = 0;
#ifdef VIRTUAL
char *sp;
char configdir[MAXPATHLEN];
char accesspath[MAXPATHLEN];
#ifdef INET6
char hostaddress[INET6_ADDRSTRLEN];
#else
char hostaddress[32];
#endif
#endif
#ifdef TSOL
/* Before anything, clear the effective privilege set */
if (set_effective_priv(PRIV_SET, 0) != 0) {
exit(1);
}
#endif
++progname;
else
if (argc > 1) {
switch (c) {
case 'V':
exit(0);
#ifdef VIRTUAL
case 'v':
virtual = 1;
break;
#endif
default:
exit(1);
}
}
}
exitval = 0;
exitval = 1;
#ifdef VIRTUAL
/*
* Deal with the ftpaccess 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 */
exitval = 1;
}
}
}
#endif
return (exitval);
}