Cleanup for WARNS = 1
- add prototypes - comment out rfc931(); it conflicts with the one in -lwrap and is not needed anyway. - remove unused variables - add NetBSD rcsids.
This commit is contained in:
parent
935794817d
commit
f8dba09cca
|
@ -1,17 +1,17 @@
|
|||
# $Netbsd$
|
||||
|
||||
WARNS?= 1
|
||||
PROG= tcpdchk
|
||||
SRCS= tcpdchk.c fakelog.c inetcf.c scaffold.c percent_m.c
|
||||
MAN= tcpdchk.8
|
||||
LDADD= -lwrap
|
||||
DPADD= ${LIBWRAP}
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../../lib/libwrap
|
||||
|
||||
CFLAGS+=-DFACILITY=LOG_AUTHPRIV -DSEVERITY=LOG_INFO -DPARANOID
|
||||
CFLAGS+=-DREAL_DAEMON_DIR=\"/usr/libexec\" -DHOSTS_ACCESS -DDAEMON_UMASK=022
|
||||
CFLAGS+=-DRFC931_TIMEOUT=10 -DALWAYS_HOSTNAME -DSYS_ERRLIST_DEFINED
|
||||
CFLAGS+=-DHOSTS_ALLOW=\"/etc/hosts.allow\" -DHOSTS_DENY=\"/etc/hosts.deny\"
|
||||
CFLAGS+=-DPROCESS_OPTIONS
|
||||
CPPFLAGS+= -I${.CURDIR}/../../lib/libwrap
|
||||
CPPFLAGS+=-DFACILITY=LOG_AUTHPRIV -DSEVERITY=LOG_INFO -DPARANOID
|
||||
CPPFLAGS+=-DREAL_DAEMON_DIR=\"/usr/libexec\" -DHOSTS_ACCESS -DDAEMON_UMASK=022
|
||||
CPPFLAGS+=-DRFC931_TIMEOUT=10 -DALWAYS_HOSTNAME -DSYS_ERRLIST_DEFINED
|
||||
CPPFLAGS+=-DHOSTS_ALLOW=\"/etc/hosts.allow\" -DHOSTS_DENY=\"/etc/hosts.deny\"
|
||||
CPPFLAGS+=-DPROCESS_OPTIONS
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* $NetBSD: fakelog.c,v 1.2 1997/10/11 21:41:36 christos Exp $ */
|
||||
|
||||
/*
|
||||
* This module intercepts syslog() library calls and redirects their output
|
||||
* to the standard output stream. For interactive testing.
|
||||
|
@ -5,20 +7,28 @@
|
|||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#) fakelog.c 1.3 94/12/28 17:42:21";
|
||||
#else
|
||||
__RCSID("$NetBSD: fakelog.c,v 1.2 1997/10/11 21:41:36 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "mystdarg.h"
|
||||
#include "percent_m.h"
|
||||
|
||||
/* openlog - dummy */
|
||||
|
||||
/* ARGSUSED */
|
||||
|
||||
void
|
||||
openlog(name, logopt, facility)
|
||||
char *name;
|
||||
const char *name;
|
||||
int logopt;
|
||||
int facility;
|
||||
{
|
||||
|
@ -27,9 +37,10 @@ int facility;
|
|||
|
||||
/* vsyslog - format one record */
|
||||
|
||||
void
|
||||
vsyslog(severity, fmt, ap)
|
||||
int severity;
|
||||
char *fmt;
|
||||
const char *fmt;
|
||||
va_list ap;
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
|
@ -43,19 +54,33 @@ va_list ap;
|
|||
|
||||
/* VARARGS */
|
||||
|
||||
VARARGS(syslog, int, severity)
|
||||
void
|
||||
#ifdef __STDC__
|
||||
syslog(int severity, const char *fmt, ...)
|
||||
#else
|
||||
syslog(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#ifndef __STDC__
|
||||
int severity;
|
||||
char *fmt;
|
||||
|
||||
VASTART(ap, int, severity);
|
||||
va_start(ap);
|
||||
severity = va_arg(ap, int);
|
||||
fmt = va_arg(ap, char *);
|
||||
#else
|
||||
va_start(ap, fmt);
|
||||
#endif
|
||||
fmt = va_arg(ap, char *);
|
||||
vsyslog(severity, fmt, ap);
|
||||
VAEND(ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/* closelog - dummy */
|
||||
|
||||
void
|
||||
closelog()
|
||||
{
|
||||
/* void */
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* $NetBSD: inetcf.c,v 1.4 1997/10/11 21:41:37 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Routines to parse an inetd.conf or tlid.conf file. This would be a great
|
||||
* job for a PERL script.
|
||||
|
@ -5,8 +7,13 @@
|
|||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#) inetcf.c 1.6 96/02/11 17:01:29";
|
||||
#else
|
||||
__RCSID("$NetBSD: inetcf.c,v 1.4 1997/10/11 21:41:37 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -16,11 +23,13 @@ static char sccsid[] = "@(#) inetcf.c 1.6 96/02/11 17:01:29";
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int errno;
|
||||
extern void exit();
|
||||
|
||||
#include "tcpd.h"
|
||||
#include "inetcf.h"
|
||||
#include "percent_m.h"
|
||||
#include "scaffold.h"
|
||||
|
||||
static void inet_chk __P((char *, char *, char *, char *));
|
||||
static char *base_name __P((char *));
|
||||
|
||||
/*
|
||||
* Programs that use libwrap directly are not in inetd.conf, and so must
|
||||
|
@ -50,9 +59,6 @@ char *inet_files[] = {
|
|||
0,
|
||||
};
|
||||
|
||||
static void inet_chk();
|
||||
static char *base_name();
|
||||
|
||||
/*
|
||||
* Structure with everything we know about a service.
|
||||
*/
|
||||
|
@ -72,7 +78,7 @@ char *inet_cfg(conf)
|
|||
char *conf;
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
FILE *fp;
|
||||
FILE *fp = NULL;
|
||||
char **wrapped;
|
||||
char *service;
|
||||
char *protocol;
|
||||
|
@ -81,7 +87,6 @@ char *conf;
|
|||
char *arg0;
|
||||
char *arg1;
|
||||
struct tcpd_context saved_context;
|
||||
char *percent_m();
|
||||
int i;
|
||||
struct stat st;
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
extern char *inet_cfg(); /* read inetd.conf file */
|
||||
extern void inet_set(); /* remember internet service */
|
||||
extern int inet_get(); /* look up internet service */
|
||||
char *inet_cfg __P((char *)); /* read inetd.conf file */
|
||||
void inet_set __P((char *, int)); /* remember internet service */
|
||||
int inet_get __P((char *)); /* look up internet service */
|
||||
|
||||
#define WR_UNKNOWN (-1) /* service unknown */
|
||||
#define WR_NOT 1 /* may not be wrapped */
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
/* $NetBSD: percent_m.c,v 1.2 1997/10/11 21:41:40 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Replace %m by system error message.
|
||||
*
|
||||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#) percent_m.c 1.1 94/12/28 17:42:37";
|
||||
#else
|
||||
__RCSID("$NetBSD: percent_m.c,v 1.2 1997/10/11 21:41:40 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -19,15 +26,16 @@ extern int sys_nerr;
|
|||
#endif
|
||||
|
||||
#include "mystdarg.h"
|
||||
#include "percent_m.h"
|
||||
|
||||
char *percent_m(obuf, ibuf)
|
||||
char *obuf;
|
||||
char *ibuf;
|
||||
const char *ibuf;
|
||||
{
|
||||
char *bp = obuf;
|
||||
char *cp = ibuf;
|
||||
const char *cp = ibuf;
|
||||
|
||||
while (*bp = *cp)
|
||||
while ((*bp = *cp) != '\0')
|
||||
if (*cp == '%' && cp[1] == 'm') {
|
||||
if (errno < sys_nerr && errno > 0) {
|
||||
strcpy(bp, sys_errlist[errno]);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/* $NetBSD: percent_m.h,v 1.1 1997/10/11 21:41:41 christos Exp $ */
|
||||
|
||||
char *percent_m __P((char *, const char *));
|
|
@ -1,11 +1,18 @@
|
|||
/* $NetBSD: scaffold.c,v 1.2 1997/10/11 21:41:44 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Routines for testing only. Not really industrial strength.
|
||||
*
|
||||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccs_id[] = "@(#) scaffold.c 1.5 95/01/03 09:13:48";
|
||||
#else
|
||||
__RCSID("$NetBSD: scaffold.c,v 1.2 1997/10/11 21:41:44 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* System libraries. */
|
||||
|
@ -20,18 +27,19 @@ static char sccs_id[] = "@(#) scaffold.c 1.5 95/01/03 09:13:48";
|
|||
#include <syslog.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE (-1) /* XXX should be 0xffffffff */
|
||||
#endif
|
||||
|
||||
extern char *malloc();
|
||||
|
||||
/* Application-specific. */
|
||||
|
||||
#include "tcpd.h"
|
||||
#include "scaffold.h"
|
||||
|
||||
static struct hostent *dup_hostent __P((struct hostent *));
|
||||
|
||||
/*
|
||||
* These are referenced by the options module and by rfc931.c.
|
||||
*/
|
||||
|
@ -176,6 +184,7 @@ struct request_info *request;
|
|||
exit(0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* dummy function to intercept the real rfc931() */
|
||||
|
||||
/* ARGSUSED */
|
||||
|
@ -185,6 +194,7 @@ struct request_info *request;
|
|||
{
|
||||
strcpy(request->user, unknown);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* check_path - examine accessibility */
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
extern struct hostent *find_inet_addr();
|
||||
extern int check_dns();
|
||||
extern int check_path();
|
||||
struct hostent *find_inet_addr __P((char *));
|
||||
int check_dns __P((char *));
|
||||
void shell_cmd __P((char *));
|
||||
void clean_exit __P((struct request_info *));
|
||||
#if 0
|
||||
void rfc931 __P((struct request_info *));
|
||||
#endif
|
||||
int check_path __P((char *, struct stat *));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* $NetBSD: tcpdchk.c,v 1.2 1997/10/11 21:41:46 christos Exp $ */
|
||||
|
||||
/*
|
||||
* tcpdchk - examine all tcpd access control rules and inetd.conf entries
|
||||
*
|
||||
|
@ -14,8 +16,13 @@
|
|||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#) tcpdchk.c 1.7 96/02/11 17:01:34";
|
||||
#else
|
||||
__RCSID("$NetBSD: tcpdchk.c,v 1.2 1997/10/11 21:41:46 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* System libraries. */
|
||||
|
@ -30,11 +37,8 @@ static char sccsid[] = "@(#) tcpdchk.c 1.7 96/02/11 17:01:34";
|
|||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int errno;
|
||||
extern void exit();
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE (-1) /* XXX should be 0xffffffff */
|
||||
|
@ -66,15 +70,17 @@ extern jmp_buf tcpd_buf;
|
|||
/*
|
||||
* Local stuff.
|
||||
*/
|
||||
static void usage();
|
||||
static void parse_table();
|
||||
static void print_list();
|
||||
static void check_daemon_list();
|
||||
static void check_client_list();
|
||||
static void check_daemon();
|
||||
static void check_user();
|
||||
static int check_host();
|
||||
static int reserved_name();
|
||||
static void usage __P((void));
|
||||
static void parse_table __P((char *, struct request_info *));
|
||||
static void print_list __P((char *, char *));
|
||||
static void check_daemon_list __P((char *));
|
||||
static void check_client_list __P((char *));
|
||||
static void check_daemon __P((char *));
|
||||
static void check_user __P((char *));
|
||||
static int check_host __P((char *));
|
||||
static int reserved_name __P((char *));
|
||||
|
||||
int main __P((int, char **));
|
||||
|
||||
#define PERMIT 1
|
||||
#define DENY 0
|
||||
|
@ -199,13 +205,15 @@ struct request_info *request;
|
|||
char sv_list[BUFLEN]; /* becomes list of daemons */
|
||||
char *cl_list; /* becomes list of requests */
|
||||
char *sh_cmd; /* becomes optional shell command */
|
||||
char buf[BUFSIZ];
|
||||
int verdict;
|
||||
struct tcpd_context saved_context;
|
||||
#ifdef __GNUC__
|
||||
(void) &real_verdict;
|
||||
#endif
|
||||
|
||||
saved_context = tcpd_context; /* stupid compilers */
|
||||
|
||||
if (fp = fopen(table, "r")) {
|
||||
if ((fp = fopen(table, "r")) != NULL) {
|
||||
tcpd_context.file = table;
|
||||
tcpd_context.line = 0;
|
||||
while (xgets(sv_list, sizeof(sv_list), fp)) {
|
||||
|
@ -330,7 +338,7 @@ char *list;
|
|||
clients = 0;
|
||||
} else {
|
||||
clients++;
|
||||
if (host = split_at(cp + 1, '@')) { /* user@host */
|
||||
if ((host = split_at(cp + 1, '@')) != NULL) { /* user@host */
|
||||
check_user(cp);
|
||||
check_host(host);
|
||||
} else {
|
||||
|
@ -421,7 +429,7 @@ char *pat;
|
|||
tcpd_warn("netgroup support disabled");
|
||||
#endif
|
||||
#endif
|
||||
} else if (mask = split_at(pat, '/')) { /* network/netmask */
|
||||
} else if ((mask = split_at(pat, '/')) != NULL) { /* network/netmask */
|
||||
if (dot_quad_addr(pat) == INADDR_NONE
|
||||
|| dot_quad_addr(mask) == INADDR_NONE)
|
||||
tcpd_warn("%s/%s: bad net/mask pattern", pat, mask);
|
||||
|
|
Loading…
Reference in New Issue