* authorized by the /etc/hosts.{allow,deny} files. The local system is
* always treated as an authorized host. The access control tables are never
* consulted for requests from the local system, and are always consulted
- * for requests from other hosts. Access control is based on IP addresses
- * only; attempts to map an address to a host name might cause the
- * portmapper to hang.
+ * for requests from other hosts.
*
* Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and
* Computing Science, Eindhoven University of Technology, The Netherlands.
*/
-#include "tcpwrapper.h"
-
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <tcpwrapper.h>
#include <unistd.h>
#include <string.h>
#include <rpc/rpc.h>
/* A handful of macros for "readability". */
+#ifdef HAVE_LIBWRAP
/* coming from libwrap.a (tcp_wrappers) */
extern int hosts_ctl(char *daemon, char *name, char *addr, char *user);
+#else
+int hosts_ctl(char *daemon, char *name, char *addr, char *user)
+{
+ return 0;
+}
+#endif
#define legal_port(a,p) \
(ntohs((a)->sin_port) < IPPORT_RESERVED || (p) >= IPPORT_RESERVED)
char *text;
{
char *procname;
- char procbuf[4 * sizeof(u_long)];
+ char procbuf[16 + 4 * sizeof(u_long)];
char *progname;
- char progbuf[4 * sizeof(u_long)];
+ char progbuf[16 + 4 * sizeof(u_long)];
struct rpcent *rpc;
/*
* Fork off a process or the portmap daemon might hang while
* getrpcbynumber() or syslog() does its thing.
+ *
+ * Don't forget to wait for the children, too...
*/
if (fork() == 0) {
} else if ((rpc = getrpcbynumber((int) prognum))) {
progname = rpc->r_name;
} else {
- sprintf(progname = progbuf, "%lu", prognum);
+ snprintf(progname = progbuf, sizeof (progbuf),
+ "prog (%lu)", prognum);
}
/* Try to map procedure number to name. */
- sprintf(procname = procbuf, "%lu", (u_long) procnum);
+ snprintf(procname = procbuf, sizeof (procbuf),
+ "proc (%lu)", (u_long) procnum);
/* Write syslog record. */
- syslog(severity, "connect from %s to %s(%s)%s",
+ syslog(severity, "connect from %s to %s in %s%s",
inet_ntoa(addr->sin_addr), procname, progname, text);
exit(0);
}