cleanup some of portability #ifdefs, which are not needed for netbsd.

This commit is contained in:
itojun 2002-05-24 05:38:19 +00:00
parent 5faa38589c
commit 2ef04ff634
8 changed files with 14 additions and 420 deletions

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.8 1998/10/07 02:25:12 simonb Exp $
# $NetBSD: Makefile,v 1.9 2002/05/24 05:38:19 itojun Exp $
LIB= wrap
SRCS= hosts_access.c options.c shell_cmd.c rfc931.c eval.c hosts_ctl.c \
refuse.c percent_x.c clean_exit.c fix_options.c socket.c \
workarounds.c update.c misc.c diag.c
update.c misc.c diag.c
MAN= hosts_access.3 hosts_access.5 hosts_options.5
MLINKS+=hosts_access.5 hosts.allow.5
MLINKS+=hosts_access.5 hosts.deny.5

View File

@ -1,13 +1,12 @@
# $NetBSD: Makefile.cflags,v 1.6 2002/03/22 18:10:21 thorpej Exp $
# $NetBSD: Makefile.cflags,v 1.7 2002/05/24 05:38:20 itojun Exp $
.include <bsd.own.mk>
CPPFLAGS+=-DFACILITY=LOG_AUTHPRIV -DSEVERITY=LOG_INFO
CPPFLAGS+=-DREAL_DAEMON_DIR=\"/usr/libexec\" -DHOSTS_ACCESS -DDAEMON_UMASK=022
CPPFLAGS+=-DRFC931_TIMEOUT=10 -DALWAYS_HOSTNAME -DSYS_ERRLIST_DEFINED
CPPFLAGS+=-DRFC931_TIMEOUT=10 -DALWAYS_HOSTNAME
CPPFLAGS+=-DHOSTS_ALLOW=\"/etc/hosts.allow\" -DHOSTS_DENY=\"/etc/hosts.deny\"
CPPFLAGS+=-DPROCESS_OPTIONS
CPPFLAGS+=-Dss_family=__ss_family -Dss_len=__ss_len
.if (${USE_YP} != "no")
CPPFLAGS+=-DNETGROUP

View File

@ -1,4 +1,4 @@
/* $NetBSD: hosts_access.c,v 1.13 2002/04/24 16:37:08 atatat Exp $ */
/* $NetBSD: hosts_access.c,v 1.14 2002/05/24 05:38:20 itojun Exp $ */
/*
* This module implements a simple access control language that is based on
@ -24,7 +24,7 @@
#if 0
static char sccsid[] = "@(#) hosts_access.c 1.21 97/02/12 02:13:22";
#else
__RCSID("$NetBSD: hosts_access.c,v 1.13 2002/04/24 16:37:08 atatat Exp $");
__RCSID("$NetBSD: hosts_access.c,v 1.14 2002/05/24 05:38:20 itojun Exp $");
#endif
#endif
@ -50,10 +50,6 @@ __RCSID("$NetBSD: hosts_access.c,v 1.13 2002/04/24 16:37:08 atatat Exp $");
#include <rpcsvc/ypclnt.h>
#endif
#ifndef INADDR_NONE
#define INADDR_NONE (-1) /* XXX should be 0xffffffff */
#endif
/* Local stuff. */
#include "tcpd.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.7 1999/08/31 13:58:58 itojun Exp $ */
/* $NetBSD: misc.c,v 1.8 2002/05/24 05:38:20 itojun Exp $ */
/*
* Misc routines that are used by tcpd and by tcpdchk.
@ -11,7 +11,7 @@
#if 0
static char sccsic[] = "@(#) misc.c 1.2 96/02/11 17:01:29";
#else
__RCSID("$NetBSD: misc.c,v 1.7 1999/08/31 13:58:58 itojun Exp $");
__RCSID("$NetBSD: misc.c,v 1.8 2002/05/24 05:38:20 itojun Exp $");
#endif
#endif
@ -24,10 +24,6 @@ __RCSID("$NetBSD: misc.c,v 1.7 1999/08/31 13:58:58 itojun Exp $");
#include "tcpd.h"
#ifndef INADDR_NONE
#define INADDR_NONE (-1) /* XXX should be 0xffffffff */
#endif
/* xgets - fgets() with backslash-newline stripping */
char *xgets(ptr, len, fp)
@ -61,13 +57,6 @@ char *split_at(string, delimiter)
char *string;
int delimiter;
{
#if 0
char *cp;
if ((cp = strchr(string, delimiter)) != 0)
*cp++ = 0;
return (cp);
#else
char *cp;
int bracket;
@ -89,7 +78,6 @@ int delimiter;
}
}
return NULL;
#endif
}
/* dot_quad_addr - convert dotted quad to internal form */

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.10 2000/10/04 16:24:49 sommerfeld Exp $ */
/* $NetBSD: options.c,v 1.11 2002/05/24 05:38:20 itojun Exp $ */
/*
* General skeleton for adding options to the access control language. The
@ -35,7 +35,7 @@
#if 0
static char sccsid[] = "@(#) options.c 1.17 96/02/11 17:01:31";
#else
__RCSID("$NetBSD: options.c,v 1.10 2000/10/04 16:24:49 sommerfeld Exp $");
__RCSID("$NetBSD: options.c,v 1.11 2002/05/24 05:38:20 itojun Exp $");
#endif
#endif
@ -57,10 +57,6 @@ __RCSID("$NetBSD: options.c,v 1.10 2000/10/04 16:24:49 sommerfeld Exp $");
#include <setjmp.h>
#include <string.h>
#ifndef MAXPATHNAMELEN
#define MAXPATHNAMELEN BUFSIZ
#endif
/* Local stuff. */
#include "tcpd.h"
@ -246,7 +242,7 @@ static void banners_option(value, request)
char *value;
struct request_info *request;
{
char path[MAXPATHNAMELEN];
char path[MAXPATHLEN];
char ibuf[BUFSIZ];
char obuf[2 * BUFSIZ];
struct stat st;

View File

@ -1,4 +1,4 @@
/* $NetBSD: socket.c,v 1.9 2001/11/05 15:05:18 lukem Exp $ */
/* $NetBSD: socket.c,v 1.10 2002/05/24 05:38:20 itojun Exp $ */
/*
* This module determines the type of socket (datagram, stream), the client
@ -22,7 +22,7 @@
#if 0
static char sccsid[] = "@(#) socket.c 1.15 97/03/21 19:27:24";
#else
__RCSID("$NetBSD: socket.c,v 1.9 2001/11/05 15:05:18 lukem Exp $");
__RCSID("$NetBSD: socket.c,v 1.10 2002/05/24 05:38:20 itojun Exp $");
#endif
#endif
@ -46,36 +46,6 @@ __RCSID("$NetBSD: socket.c,v 1.9 2001/11/05 15:05:18 lukem Exp $");
static void sock_sink __P((int));
#ifdef APPEND_DOT
static struct hostent *gethostbyname_dot __P((char *));
/*
* Speed up DNS lookups by terminating the host name with a dot. Should be
* done with care. The speedup can give problems with lookups from sources
* that lack DNS-style trailing dot magic, such as local files or NIS maps.
*/
static struct hostent *gethostbyname_dot(name)
char *name;
{
char dot_name[MAXHOSTNAMELEN + 1];
/*
* Don't append dots to unqualified names. Such names are likely to come
* from local hosts files or from NIS.
*/
if (strchr(name, '.') == 0 || strlen(name) >= MAXHOSTNAMELEN - 1) {
return (gethostbyname(name));
} else {
(void)snprintf(dot_name, sizeof dot_name, "%s.", name);
return (gethostbyname(dot_name));
}
}
#define gethostbyname gethostbyname_dot
#endif
/* sock_host - look up endpoint addresses and install conversion methods */
void sock_host(request)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcpd.h,v 1.11 2001/03/27 22:46:55 kleink Exp $ */
/* $NetBSD: tcpd.h,v 1.12 2002/05/24 05:38:20 itojun Exp $ */
/*
* @(#) tcpd.h 1.5 96/03/19 16:22:24
*
@ -71,12 +71,7 @@ __END_DECLS
/* Global functions. */
__BEGIN_DECLS
#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
extern void fromhost /* get/validate client host info */
__P((struct request_info *));
#else
#define fromhost sock_host /* no TLI support needed */
#endif
extern int hosts_access /* access control */
__P((struct request_info *));
@ -216,41 +211,4 @@ extern void process_options /* execute options */
extern int dry_run; /* verification flag */
extern void fix_options /* get rid of IP-level socket options */
__P((struct request_info *));
/* Bug workarounds. */
#ifdef INET_ADDR_BUG /* inet_addr() returns struct */
#define inet_addr fix_inet_addr
extern long fix_inet_addr __P((char *));
#endif
#ifdef BROKEN_FGETS /* partial reads from sockets */
#define fgets fix_fgets
extern char *fix_fgets __P((char *, int, FILE *));
#endif
#ifdef RECVFROM_BUG /* no address family info */
#define recvfrom fix_recvfrom
extern int fix_recvfrom __P((int, char *, int, int, struct sockaddr *, int *));
#endif
#ifdef GETPEERNAME_BUG /* claims success with UDP */
#include <sys/socket.h> /* XXX serious hack! */
#define getpeername fix_getpeername
extern int fix_getpeername __P((int, struct sockaddr *, int *));
#endif
#ifdef SOLARIS_24_GETHOSTBYNAME_BUG /* lists addresses as aliases */
#define gethostbyname fix_gethostbyname
extern struct hostent *fix_gethostbyname __P((char *));
#endif
#ifdef USE_STRSEP /* libc calls strtok() */
#define strtok fix_strtok
extern char *fix_strtok __P((char *, char *));
#endif
#ifdef LIBC_CALLS_STRTOK /* libc calls strtok() */
#define strtok my_strtok
extern char *my_strtok __P((char *, char *));
#endif
__END_DECLS

View File

@ -1,313 +0,0 @@
/* $NetBSD: workarounds.c,v 1.6 2000/01/21 17:08:34 mycroft Exp $ */
/*
* Workarounds for known system software bugs. This module provides wrappers
* around library functions and system calls that are known to have problems
* on some systems. Most of these workarounds won't do any harm on regular
* systems.
*
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
char sccsid[] = "@(#) workarounds.c 1.6 96/03/19 16:22:25";
#else
__RCSID("$NetBSD: workarounds.c,v 1.6 2000/01/21 17:08:34 mycroft Exp $");
#endif
#endif
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include "tcpd.h"
/*
* Some AIX versions advertise a too small MAXHOSTNAMELEN value (32).
* Result: long hostnames would be truncated, and connections would be
* dropped because of host name verification failures. Adrian van Bloois
* (A.vanBloois@info.nic.surfnet.nl) figured out what was the problem.
*/
#if (MAXHOSTNAMELEN < 64)
#undef MAXHOSTNAMELEN
#endif
/* In case not defined in <sys/param.h>. */
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256 /* storage for host name */
#endif
/*
* Some DG/UX inet_addr() versions return a struct/union instead of a long.
* You have this problem when the compiler complains about illegal lvalues
* or something like that. The following code fixes this mutant behaviour.
* It should not be enabled on "normal" systems.
*
* Bug reported by ben@piglet.cr.usgs.gov (Rev. Ben A. Mesander).
*/
#ifdef INET_ADDR_BUG
#undef inet_addr
long fix_inet_addr(string)
char *string;
{
return (inet_addr(string).s_addr);
}
#endif /* INET_ADDR_BUG */
/*
* With some System-V versions, the fgets() library function does not
* account for partial reads from e.g. sockets. The result is that fgets()
* gives up too soon, causing username lookups to fail. Problem first
* reported for IRIX 4.0.5, by Steve Kotsopoulos <steve@ecf.toronto.edu>.
* The following code works around the problem. It does no harm on "normal"
* systems.
*/
#ifdef BROKEN_FGETS
#undef fgets
char *fix_fgets(buf, len, fp)
char *buf;
int len;
FILE *fp;
{
char *cp = buf;
int c;
/*
* Copy until the buffer fills up, until EOF, or until a newline is
* found.
*/
while (len > 1 && (c = getc(fp)) != EOF) {
len--;
*cp++ = c;
if (c == '\n')
break;
}
/*
* Return 0 if nothing was read. This is correct even when a silly buffer
* length was specified.
*/
if (cp > buf) {
*cp = 0;
return (buf);
} else {
return (0);
}
}
#endif /* BROKEN_FGETS */
/*
* With early SunOS 5 versions, recvfrom() does not completely fill in the
* source address structure when doing a non-destructive read. The following
* code works around the problem. It does no harm on "normal" systems.
*/
#ifdef RECVFROM_BUG
#undef recvfrom
int fix_recvfrom(sock, buf, buflen, flags, from, fromlen)
int sock;
char *buf;
int buflen;
int flags;
struct sockaddr *from;
int *fromlen;
{
int ret;
/* Assume that both ends of a socket belong to the same address family. */
if ((ret = recvfrom(sock, buf, buflen, flags, from, fromlen)) >= 0) {
if (from->sa_family == 0) {
struct sockaddr_storage my_addr;
int my_addr_len = sizeof(my_addr);
if (getsockname(0, (struct sockaddr *)&my_addr, &my_addr_len)) {
tcpd_warn("getsockname: %m");
} else {
from->sa_family = my_addr.sa_family;
}
}
}
return (ret);
}
#endif /* RECVFROM_BUG */
/*
* The Apollo SR10.3 and some SYSV4 getpeername(2) versions do not return an
* error in case of a datagram-oriented socket. Instead, they claim that all
* UDP requests come from address 0.0.0.0. The following code works around
* the problem. It does no harm on "normal" systems.
*/
#ifdef GETPEERNAME_BUG
#undef getpeername
int fix_getpeername(sock, sa, len)
int sock;
struct sockaddr *sa;
int *len;
{
int ret;
struct sockaddr_in *sin = (struct sockaddr_in *) sa;
if ((ret = getpeername(sock, sa, len)) >= 0
&& sa->sa_family == AF_INET
&& sin->sin_addr.s_addr == 0) {
errno = ENOTCONN;
return (-1);
} else {
return (ret);
}
}
#endif /* GETPEERNAME_BUG */
/*
* According to Karl Vogel (vogelke@c-17igp.wpafb.af.mil) some Pyramid
* versions have no yp_default_domain() function. We use getdomainname()
* instead.
*/
#ifdef USE_GETDOMAIN
int yp_get_default_domain(ptr)
char **ptr;
{
static char mydomain[MAXHOSTNAMELEN];
*ptr = mydomain;
return (getdomainname(mydomain, MAXHOSTNAMELEN));
}
#endif /* USE_GETDOMAIN */
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
/*
* Solaris 2.4 gethostbyname() has problems with multihomed hosts. When
* doing DNS through NIS, only one host address ends up in the address list.
* All other addresses end up in the hostname alias list, interspersed with
* copies of the official host name. This would wreak havoc with tcpd's
* hostname double checks. Below is a workaround that should do no harm when
* accidentally left in. A side effect of the workaround is that address
* list members are no longer properly aligned for structure access.
*/
#ifdef SOLARIS_24_GETHOSTBYNAME_BUG
#undef gethostbyname
struct hostent *fix_gethostbyname(name)
char *name;
{
struct hostent *hp;
struct in_addr addr;
char **o_addr_list;
char **o_aliases;
char **n_addr_list;
int broken_gethostbyname = 0;
if ((hp = gethostbyname(name)) && !hp->h_addr_list[1] && hp->h_aliases[1]) {
for (o_aliases = n_addr_list = hp->h_aliases; *o_aliases; o_aliases++) {
if ((addr.s_addr = inet_addr(*o_aliases)) != INADDR_NONE) {
memcpy(*n_addr_list++, (char *) &addr, hp->h_length);
broken_gethostbyname = 1;
}
}
if (broken_gethostbyname) {
o_addr_list = hp->h_addr_list;
memcpy(*n_addr_list++, *o_addr_list, hp->h_length);
*n_addr_list = 0;
hp->h_addr_list = hp->h_aliases;
hp->h_aliases = o_addr_list + 1;
}
}
return (hp);
}
#endif /* SOLARIS_24_GETHOSTBYNAME_BUG */
/*
* Horror! Some FreeBSD 2.0 libc routines call strtok(). Since tcpd depends
* heavily on strtok(), strange things may happen. Workaround: use our
* private strtok(). This has been fixed in the meantime.
*/
#ifdef USE_STRSEP
char *fix_strtok(buf, sep)
char *buf;
char *sep;
{
static char *state;
char *result;
if (buf)
state = buf;
while ((result = strsep(&state, sep)) && result[0] == 0)
/* void */ ;
return (result);
}
#endif /* USE_STRSEP */
/*
* IRIX 5.3 (and possibly earlier versions, too) library routines call the
* non-reentrant strtok() library routine, causing hosts to slip through
* allow/deny filters. Workaround: don't rely on the vendor and use our own
* strtok() function. FreeBSD 2.0 has a similar problem (fixed in 2.0.5).
*/
#ifdef LIBC_CALLS_STRTOK
char *my_strtok(buf, sep)
char *buf;
char *sep;
{
static char *state;
char *result;
if (buf)
state = buf;
/*
* Skip over separator characters and detect end of string.
*/
if (*(state += strspn(state, sep)) == 0)
return (0);
/*
* Skip over non-separator characters and terminate result.
*/
result = state;
if (*(state += strcspn(state, sep)) != 0)
*state++ = 0;
return (result);
}
#endif /* LIBC_CALLS_STRTOK */