From: Ted Lemon Date: Thu, 5 Apr 2001 22:37:35 +0000 (+0000) Subject: Make sure we have a stdin, stdout and stderr. X-Git-Tag: V3-BETA-2-PATCH-24~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee8a36530f781f3654114143e8976aea7082560a;p=thirdparty%2Fdhcp.git Make sure we have a stdin, stdout and stderr. --- diff --git a/client/dhclient.c b/client/dhclient.c index 3500bc6f3..904158cbc 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;