summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>2001-04-05 22:37:35 +0000
committerTed Lemon <source@isc.org>2001-04-05 22:37:35 +0000
commitee8a36530f781f3654114143e8976aea7082560a (patch)
treef315de2ef41db87b3965e289e2f7d1336b2b926a /client
parent4cefd70b813fa24839ce60593f9e865b4cc836c3 (diff)
downloadisc-dhcp-ee8a36530f781f3654114143e8976aea7082560a.tar.gz
Make sure we have a stdin, stdout and stderr.
Diffstat (limited to 'client')
-rw-r--r--client/dhclient.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/client/dhclient.c b/client/dhclient.c
index 3500bc6f..904158cb 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -41,7 +41,7 @@
#ifndef lint
static char ocopyright[] =
-"$Id: dhclient.c,v 1.126 2001/04/05 20:42:11 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.127 2001/04/05 22:37:35 mellon Exp $ Copyright (c) 1995-2001 Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -112,6 +112,16 @@ int main (argc, argv, envp)
int no_dhclient_script = 0;
char *s;
+ /* Make sure we have stdin, stdout and stderr. */
+ i = open ("/dev/null", O_RDWR);
+ if (i == 0)
+ i = open ("/dev/null", O_RDWR);
+ if (i == 1) {
+ i = open ("/dev/null", O_RDWR);
+ log_perror = 0; /* No sense logging to /dev/null. */
+ } else if (i != -1)
+ close (i);
+
#ifdef SYSLOG_4_2
openlog ("dhclient", LOG_NDELAY);
log_priority = LOG_DAEMON;
@@ -2066,8 +2076,10 @@ void rewrite_client_leases ()
if (leaseFile)
fclose (leaseFile);
leaseFile = fopen (path_dhclient_db, "w");
- if (!leaseFile)
- log_fatal ("can't create %s: %m", path_dhclient_db);
+ if (!leaseFile) {
+ log_error ("can't create %s: %m", path_dhclient_db);
+ return;
+ }
/* Write out all the leases attached to configured interfaces that
we know about. */
@@ -2159,8 +2171,10 @@ int write_client_lease (client, lease, rewrite, makesure)
if (!leaseFile) { /* XXX */
leaseFile = fopen (path_dhclient_db, "w");
- if (!leaseFile)
- log_fatal ("can't create %s: %m", path_dhclient_db);
+ if (!leaseFile) {
+ log_error ("can't create %s: %m", path_dhclient_db);
+ return 0;
+ }
}
errno = 0;