summaryrefslogtreecommitdiffstats
path: root/contrib/tcp_wrappers
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2017-01-09 20:14:02 +0000
committerdim <dim@FreeBSD.org>2017-01-09 20:14:02 +0000
commit6cb45500fc5412ac9eadd58d3d873bfbe8af8548 (patch)
tree1f0a38e105f6a26d5373c014e0479e5b9a2480e6 /contrib/tcp_wrappers
parenta77510b409c5ded1a4274ef75fbbf01fa765013b (diff)
downloadFreeBSD-src-6cb45500fc5412ac9eadd58d3d873bfbe8af8548.zip
FreeBSD-src-6cb45500fc5412ac9eadd58d3d873bfbe8af8548.tar.gz
MFC r257398 (by sbruno):
Quiesce warnings by updating headerfile includes r257404 | sbruno | 2013-10-30 23:41:18 +0100 (Wed, 30 Oct 2013) | 9 lines Quiesce two warnings: 1. define the CODE * as const 2. restructure function to eliminate warning about exiting with no return. severity_map() never returns when it can't find an appropriate sysylog facility, and it longjmp()'s away into error code handling. Keep this behavior by stashing the facility value found during our search and checking for -1 if found. MFC r257405 (by sbruno): Quiesce warning, which could be a bug IMO, by correctly defining the host_info structure name MFC r257406 (by sbruno): Queisce warning about undeclared function usage. yp_get_default_domain is defined in workaround.c but is not declared in any header file. Tie the declaration to the same #define conditional used when the function is called, NETGROUP MFC r311459: Put proper prototypes in tcpd.h Clang 4.0.0 complains about tcpd.h's not-really-prototypes, e.g.: /usr/include/tcpd.h:75:24: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes] extern int hosts_access(); /* access control */ ^ To fix this, turn these declarations into real prototypes. While here, garbage collect the incompatible rfc931() function from scaffold.c, as it is never used. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D9052 MFC r311461: Also remove unnecessary extern keywords from tcpd.h. Noticed by: kib MFC r311556: After r311459, some ports can break, because a few of the newly added prototypes in <tcpd.h> use FILE. Pull in a minimal forward declaration of FILE from <stdio.h> to minimize impact. Sorry for the breakage. Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>
Diffstat (limited to 'contrib/tcp_wrappers')
-rw-r--r--contrib/tcp_wrappers/clean_exit.c1
-rw-r--r--contrib/tcp_wrappers/hosts_access.c8
-rw-r--r--contrib/tcp_wrappers/options.c19
-rw-r--r--contrib/tcp_wrappers/percent_x.c1
-rw-r--r--contrib/tcp_wrappers/rfc931.c1
-rw-r--r--contrib/tcp_wrappers/scaffold.c10
-rw-r--r--contrib/tcp_wrappers/shell_cmd.c3
-rw-r--r--contrib/tcp_wrappers/tcpd.h96
-rw-r--r--contrib/tcp_wrappers/update.c1
9 files changed, 74 insertions, 66 deletions
diff --git a/contrib/tcp_wrappers/clean_exit.c b/contrib/tcp_wrappers/clean_exit.c
index cb9d4f5..41caaf0 100644
--- a/contrib/tcp_wrappers/clean_exit.c
+++ b/contrib/tcp_wrappers/clean_exit.c
@@ -13,6 +13,7 @@ static char sccsid[] = "@(#) clean_exit.c 1.4 94/12/28 17:42:19";
#endif
#include <stdio.h>
+#include <unistd.h>
extern void exit();
diff --git a/contrib/tcp_wrappers/hosts_access.c b/contrib/tcp_wrappers/hosts_access.c
index 03d305b..af0433b 100644
--- a/contrib/tcp_wrappers/hosts_access.c
+++ b/contrib/tcp_wrappers/hosts_access.c
@@ -44,6 +44,7 @@ static char sccsid[] = "@(#) hosts_access.c 1.21 97/02/12 02:13:22";
#ifdef INET6
#include <netdb.h>
#endif
+#include <stdlib.h>
extern char *fgets();
extern int errno;
@@ -102,6 +103,11 @@ static int masked_match6();
#define BUFLEN 2048
+/* definition to be used from workarounds.c */
+#ifdef NETGROUP
+int yp_get_default_domain(char **);
+#endif
+
/* hosts_access - host access control facility */
int hosts_access(request)
@@ -269,7 +275,7 @@ struct request_info *request;
static int hostfile_match(path, host)
char *path;
-struct hosts_info *host;
+struct host_info *host;
{
char tok[BUFSIZ];
int match = NO;
diff --git a/contrib/tcp_wrappers/options.c b/contrib/tcp_wrappers/options.c
index 97d3127..04ae174 100644
--- a/contrib/tcp_wrappers/options.c
+++ b/contrib/tcp_wrappers/options.c
@@ -50,6 +50,8 @@ static char sccsid[] = "@(#) options.c 1.17 96/02/11 17:01:31";
#include <ctype.h>
#include <setjmp.h>
#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
#ifndef MAXPATHNAMELEN
#define MAXPATHNAMELEN BUFSIZ
@@ -441,16 +443,21 @@ struct request_info *request;
/* severity_map - lookup facility or severity value */
static int severity_map(table, name)
-CODE *table;
+const CODE *table;
char *name;
{
- CODE *t;
+ const CODE *t;
+ int ret = -1;
for (t = table; t->c_name; t++)
- if (STR_EQ(t->c_name, name))
- return (t->c_val);
- tcpd_jump("bad syslog facility or severity: \"%s\"", name);
- /* NOTREACHED */
+ if (STR_EQ(t->c_name, name)) {
+ ret = t->c_val;
+ break;
+ }
+ if (ret == -1)
+ tcpd_jump("bad syslog facility or severity: \"%s\"", name);
+
+ return (ret);
}
/* severity_option - change logging severity for this event (Dave Mitchell) */
diff --git a/contrib/tcp_wrappers/percent_x.c b/contrib/tcp_wrappers/percent_x.c
index c95a1ea..9b37329 100644
--- a/contrib/tcp_wrappers/percent_x.c
+++ b/contrib/tcp_wrappers/percent_x.c
@@ -19,6 +19,7 @@ static char sccsid[] = "@(#) percent_x.c 1.4 94/12/28 17:42:37";
#include <stdio.h>
#include <syslog.h>
#include <string.h>
+#include <unistd.h>
extern void exit();
diff --git a/contrib/tcp_wrappers/rfc931.c b/contrib/tcp_wrappers/rfc931.c
index e7fb3d1..924dac3 100644
--- a/contrib/tcp_wrappers/rfc931.c
+++ b/contrib/tcp_wrappers/rfc931.c
@@ -25,6 +25,7 @@ static char sccsid[] = "@(#) rfc931.c 1.10 95/01/02 16:11:34";
#include <setjmp.h>
#include <signal.h>
#include <string.h>
+#include <unistd.h>
#ifndef SEEK_SET
#define SEEK_SET 0
diff --git a/contrib/tcp_wrappers/scaffold.c b/contrib/tcp_wrappers/scaffold.c
index 8da9df0..bef8467 100644
--- a/contrib/tcp_wrappers/scaffold.c
+++ b/contrib/tcp_wrappers/scaffold.c
@@ -235,16 +235,6 @@ struct request_info *request;
exit(0);
}
-/* dummy function to intercept the real rfc931() */
-
-/* ARGSUSED */
-
-void rfc931(request)
-struct request_info *request;
-{
- strcpy(request->user, unknown);
-}
-
/* check_path - examine accessibility */
int check_path(path, st)
diff --git a/contrib/tcp_wrappers/shell_cmd.c b/contrib/tcp_wrappers/shell_cmd.c
index 62d31bc..4928636 100644
--- a/contrib/tcp_wrappers/shell_cmd.c
+++ b/contrib/tcp_wrappers/shell_cmd.c
@@ -16,10 +16,13 @@ static char sccsid[] = "@(#) shell_cmd.c 1.5 94/12/28 17:42:44";
#include <sys/types.h>
#include <sys/param.h>
+#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <syslog.h>
#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
extern void exit();
diff --git a/contrib/tcp_wrappers/tcpd.h b/contrib/tcp_wrappers/tcpd.h
index af17c07..1078073 100644
--- a/contrib/tcp_wrappers/tcpd.h
+++ b/contrib/tcp_wrappers/tcpd.h
@@ -6,6 +6,17 @@
* $FreeBSD$
*/
+#ifdef INET6
+#define TCPD_SOCKADDR struct sockaddr
+#else
+#define TCPD_SOCKADDR struct sockaddr_in
+#endif
+
+#ifndef _STDFILE_DECLARED
+#define _STDFILE_DECLARED
+typedef struct __sFILE FILE;
+#endif
+
/* Structure to describe one communications endpoint. */
#define STRING_LENGTH 128 /* hosts, users, processes */
@@ -13,11 +24,7 @@
struct host_info {
char name[STRING_LENGTH]; /* access via eval_hostname(host) */
char addr[STRING_LENGTH]; /* access via eval_hostaddr(host) */
-#ifdef INET6
- struct sockaddr *sin; /* socket address or 0 */
-#else
- struct sockaddr_in *sin; /* socket address or 0 */
-#endif
+ TCPD_SOCKADDR *sin; /* socket address or 0 */
struct t_unitdata *unit; /* TLI transport address or 0 */
struct request_info *request; /* for shared information */
};
@@ -67,21 +74,22 @@ extern char paranoid[];
/* Global functions. */
#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
-extern void fromhost(); /* get/validate client host info */
+void fromhost(struct request_info *); /* get/validate client host info */
#else
#define fromhost sock_host /* no TLI support needed */
#endif
-extern int hosts_access(); /* access control */
-extern int hosts_ctl(); /* wrapper around request_init() */
-extern void shell_cmd(); /* execute shell command */
-extern char *percent_x(); /* do %<char> expansion */
-extern void rfc931(); /* client name from RFC 931 daemon */
-extern void clean_exit(); /* clean up and exit */
-extern void refuse(); /* clean up and exit */
-extern char *xgets(); /* fgets() on steroids */
-extern char *split_at(); /* strchr() and split */
-extern unsigned long dot_quad_addr(); /* restricted inet_addr() */
+int hosts_access(struct request_info *); /* access control */
+int hosts_ctl(char *, char *, char *, char *); /* wrapper around request_init() */
+void shell_cmd(char *); /* execute shell command */
+char *percent_x(char *, int, char *, struct request_info *); /* do %<char> expansion */
+void rfc931(TCPD_SOCKADDR *, TCPD_SOCKADDR *, char *); /* client name from RFC 931 daemon */
+void clean_exit(struct request_info *); /* clean up and exit */
+void refuse(struct request_info *); /* clean up and exit */
+char *xgets(char *, int, FILE *); /* fgets() on steroids */
+
+char *split_at(char *, int); /* strchr() and split */
+unsigned long dot_quad_addr(char *); /* restricted inet_addr() */
/* Global variables. */
@@ -98,13 +106,8 @@ extern int resident; /* > 0 if resident process */
* attributes. Each attribute has its own key.
*/
-#ifdef __STDC__
-extern struct request_info *request_init(struct request_info *,...);
-extern struct request_info *request_set(struct request_info *,...);
-#else
-extern struct request_info *request_init(); /* initialize request */
-extern struct request_info *request_set(); /* update request structure */
-#endif
+struct request_info *request_init(struct request_info *,...); /* initialize request */
+struct request_info *request_set(struct request_info *,...); /* update request structure */
#define RQ_FILE 1 /* file descriptor */
#define RQ_DAEMON 2 /* server process (argv[0]) */
@@ -124,27 +127,27 @@ extern struct request_info *request_set(); /* update request structure */
* host_info structures serve as caches for the lookup results.
*/
-extern char *eval_user(); /* client user */
-extern char *eval_hostname(); /* printable hostname */
-extern char *eval_hostaddr(); /* printable host address */
-extern char *eval_hostinfo(); /* host name or address */
-extern char *eval_client(); /* whatever is available */
-extern char *eval_server(); /* whatever is available */
+char *eval_user(struct request_info *); /* client user */
+char *eval_hostname(struct host_info *); /* printable hostname */
+char *eval_hostaddr(struct host_info *); /* printable host address */
+char *eval_hostinfo(struct host_info *); /* host name or address */
+char *eval_client(struct request_info *); /* whatever is available */
+char *eval_server(struct request_info *); /* whatever is available */
#define eval_daemon(r) ((r)->daemon) /* daemon process name */
#define eval_pid(r) ((r)->pid) /* process id */
/* Socket-specific methods, including DNS hostname lookups. */
-extern void sock_host(); /* look up endpoint addresses */
-extern void sock_hostname(); /* translate address to hostname */
-extern void sock_hostaddr(); /* address to printable address */
+void sock_host(struct request_info *); /* look up endpoint addresses */
+void sock_hostname(struct host_info *); /* translate address to hostname */
+void sock_hostaddr(struct host_info *); /* address to printable address */
#define sock_methods(r) \
{ (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }
/* The System V Transport-Level Interface (TLI) interface. */
#if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
-extern void tli_host(); /* look up endpoint addresses etc. */
+void tli_host(struct request_info *); /* look up endpoint addresses etc. */
#endif
/*
@@ -153,13 +156,8 @@ extern void tli_host(); /* look up endpoint addresses etc. */
* everyone would have to include <setjmp.h>.
*/
-#ifdef __STDC__
-extern void tcpd_warn(char *, ...); /* report problem and proceed */
-extern void tcpd_jump(char *, ...); /* report problem and jump */
-#else
-extern void tcpd_warn();
-extern void tcpd_jump();
-#endif
+void tcpd_warn(char *, ...); /* report problem and proceed */
+void tcpd_jump(char *, ...); /* report problem and jump */
struct tcpd_context {
char *file; /* current file */
@@ -185,42 +183,42 @@ extern struct tcpd_context tcpd_context;
* behavior.
*/
-extern void process_options(); /* execute options */
-extern int dry_run; /* verification flag */
+void process_options(char *, struct request_info *); /* execute options */
+extern int dry_run; /* verification flag */
/* Bug workarounds. */
#ifdef INET_ADDR_BUG /* inet_addr() returns struct */
#define inet_addr fix_inet_addr
-extern long fix_inet_addr();
+long fix_inet_addr(char *);
#endif
#ifdef BROKEN_FGETS /* partial reads from sockets */
#define fgets fix_fgets
-extern char *fix_fgets();
+char *fix_fgets(char *, int, FILE *);
#endif
#ifdef RECVFROM_BUG /* no address family info */
#define recvfrom fix_recvfrom
-extern int fix_recvfrom();
+int fix_recvfrom(int, char *, int, int, struct sockaddr *, int *);
#endif
#ifdef GETPEERNAME_BUG /* claims success with UDP */
#define getpeername fix_getpeername
-extern int fix_getpeername();
+int fix_getpeername(int, struct sockaddr *, int *);
#endif
#ifdef SOLARIS_24_GETHOSTBYNAME_BUG /* lists addresses as aliases */
#define gethostbyname fix_gethostbyname
-extern struct hostent *fix_gethostbyname();
+struct hostent *fix_gethostbyname(char *);
#endif
#ifdef USE_STRSEP /* libc calls strtok() */
#define strtok fix_strtok
-extern char *fix_strtok();
+char *fix_strtok(char *, char *);
#endif
#ifdef LIBC_CALLS_STRTOK /* libc calls strtok() */
#define strtok my_strtok
-extern char *my_strtok();
+char *my_strtok(char *, char *);
#endif
diff --git a/contrib/tcp_wrappers/update.c b/contrib/tcp_wrappers/update.c
index b612d5e..db73753 100644
--- a/contrib/tcp_wrappers/update.c
+++ b/contrib/tcp_wrappers/update.c
@@ -24,6 +24,7 @@ static char sccsid[] = "@(#) update.c 1.1 94/12/28 17:42:56";
#include <stdio.h>
#include <syslog.h>
#include <string.h>
+#include <unistd.h>
/* Local stuff. */
OpenPOWER on IntegriCloud