summaryrefslogtreecommitdiff
path: root/games/hunt/huntd
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>1999-03-22 00:29:16 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>1999-03-22 00:29:16 +0000
commit278a66c97d5a4e5090c5b0865ca3ce05c67a022a (patch)
treed6c2b787c26b4b792e268a96f74805d82039ecd7 /games/hunt/huntd
parentfbb9c9bb18b9be9353d3232df9f3af78e7240d16 (diff)
More accurate man page; more informative logging; use random() instead of
old internal routine (seems to minimize instant death on re-entry).
Diffstat (limited to 'games/hunt/huntd')
-rw-r--r--games/hunt/huntd/answer.c4
-rw-r--r--games/hunt/huntd/driver.c19
2 files changed, 11 insertions, 12 deletions
diff --git a/games/hunt/huntd/answer.c b/games/hunt/huntd/answer.c
index f45b16d8c47..aed1e6ce5da 100644
--- a/games/hunt/huntd/answer.c
+++ b/games/hunt/huntd/answer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: answer.c,v 1.5 1999/03/14 02:07:30 pjanzen Exp $ */
+/* $OpenBSD: answer.c,v 1.6 1999/03/22 00:29:15 pjanzen Exp $ */
/* $NetBSD: answer.c,v 1.3 1997/10/10 16:32:50 lukem Exp $ */
/*
* Hunt
@@ -57,8 +57,8 @@ answer_first()
request_init(&ri, RQ_DAEMON, "huntd", RQ_FILE, newsock, 0);
fromhost(&ri);
if (hosts_access(&ri) == 0) {
+ logx(LOG_INFO, "rejected connection from %s", eval_client(&ri));
close(newsock);
- logx(LOG_INFO, "rejected connection");
return;
}
diff --git a/games/hunt/huntd/driver.c b/games/hunt/huntd/driver.c
index 1e1fbdd28e7..5618a8f3118 100644
--- a/games/hunt/huntd/driver.c
+++ b/games/hunt/huntd/driver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: driver.c,v 1.5 1999/03/14 02:07:30 pjanzen Exp $ */
+/* $OpenBSD: driver.c,v 1.6 1999/03/22 00:29:15 pjanzen Exp $ */
/* $NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $ */
/*
* Hunt
@@ -26,13 +26,10 @@
#include "conf.h"
#include "server.h"
-int Seed = 0;
-
char *First_arg; /* pointer to argv[0] */
char *Last_arg; /* pointer to end of argv/environ */
u_int16_t Server_port = HUNT_PORT;
int Server_socket; /* test socket to answer datagrams */
-FLAG inetd_spawned; /* invoked via inetd */
FLAG should_announce = TRUE; /* true if listening on standard port */
u_short sock_port; /* port # of tcp listen socket */
u_short stat_port; /* port # of statistics tcp socket */
@@ -373,9 +370,9 @@ init()
len = sizeof (struct sockaddr_in);
if (getsockname(STDIN_FILENO, (struct sockaddr *) &test_port, &len) >= 0
&& test_port.sin_family == AF_INET) {
- /* We are probably running from inetd: */
- inetd_spawned = TRUE;
+ /* We are probably running from inetd: don't log to stderr */
Server_socket = STDIN_FILENO;
+ conf_logerr = 0;
if (test_port.sin_port != htons((u_short) Server_port)) {
should_announce = FALSE;
Server_port = ntohs(test_port.sin_port);
@@ -401,7 +398,7 @@ init()
Num_fds = Server_socket + 1;
/* Initialise the random seed: */
- Seed = getpid() + time((time_t *) NULL);
+ srandom(getpid() + time((time_t *) NULL));
/* Dig the maze: */
makemaze();
@@ -852,8 +849,7 @@ rand_num(range)
{
if (range == 0)
return 0;
- Seed = Seed * 11109 + 13849;
- return (((Seed >> 16) & 0xffff) % range);
+ return (random() % range);
}
/*
@@ -952,6 +948,7 @@ send_stats()
request_init(&ri, RQ_DAEMON, "huntd", RQ_FILE, s, 0);
fromhost(&ri);
if (hosts_access(&ri) == 0) {
+ logx(LOG_INFO, "rejected connection from %s", eval_client(&ri));
close(s);
return;
}
@@ -1086,8 +1083,10 @@ handle_wkport(fd)
}
/* Do we allow access? */
- if (hosts_access(&ri) == 0)
+ if (hosts_access(&ri) == 0) {
+ logx(LOG_INFO, "rejected connection from %s", eval_client(&ri));
return;
+ }
query = ntohs(query);