diff options
author | Doug Barton <dougb@FreeBSD.org> | 2010-02-07 22:14:10 +0000 |
---|---|---|
committer | Doug Barton <dougb@FreeBSD.org> | 2010-02-07 22:14:10 +0000 |
commit | e6787144c0a7f2ccb1b75e05abbd390f0fd225cd (patch) | |
tree | 50d7895dd5f9a44b6f2457ee55c873eba97cd43a /bin/named/unix/os.c | |
parent | fd8f060cacf6f8a8f24ef704e9c2b81f1063ac14 (diff) | |
download | src-13faad81590cea39da0f17cdb52a1b0fd3fb5ac1.tar.gz src-13faad81590cea39da0f17cdb52a1b0fd3fb5ac1.zip |
Vendor import of BIND 9.4-ESVvendor/bind9/9.4-ESV
Diffstat (limited to 'bin/named/unix/os.c')
-rw-r--r-- | bin/named/unix/os.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/bin/named/unix/os.c b/bin/named/unix/os.c index ad26a8e9b0e9..c41692df2f9a 100644 --- a/bin/named/unix/os.c +++ b/bin/named/unix/os.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006, 2008, 2009 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: os.c,v 1.66.18.17 2008/10/24 01:43:17 tbox Exp $ */ +/* $Id: os.c,v 1.66.18.21 2009/03/02 03:06:25 marka Exp $ */ /*! \file */ @@ -405,10 +405,12 @@ ns_os_started(void) { char buf = 0; /* - * Signal to the parent that we stated successfully. + * Signal to the parent that we started successfully. */ if (dfd[0] != -1 && dfd[1] != -1) { - write(dfd[1], &buf, 1); + if (write(dfd[1], &buf, 1) != 1) + ns_main_earlyfatal("unable to signal parent that we " + "otherwise started successfully."); close(dfd[1]); dfd[0] = dfd[1] = -1; } @@ -448,10 +450,14 @@ ns_os_chroot(const char *root) { ns_smf_chroot = 0; #endif if (root != NULL) { +#ifdef HAVE_CHROOT if (chroot(root) < 0) { isc__strerror(errno, strbuf, sizeof(strbuf)); ns_main_earlyfatal("chroot(): %s", strbuf); } +#else + ns_main_earlyfatal("chroot(): disabled"); +#endif if (chdir("/") < 0) { isc__strerror(errno, strbuf, sizeof(strbuf)); ns_main_earlyfatal("chdir(/): %s", strbuf); @@ -584,7 +590,8 @@ safe_open(const char *filename, isc_boolean_t append) { fd = open(filename, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); else { - (void)unlink(filename); + if (unlink(filename) < 0 && errno != ENOENT) + return (-1); fd = open(filename, O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); } @@ -593,8 +600,11 @@ safe_open(const char *filename, isc_boolean_t append) { static void cleanup_pidfile(void) { + int n; if (pidfile != NULL) { - (void)unlink(pidfile); + n = unlink(pidfile); + if (n == -1 && errno != ENOENT) + ns_main_earlywarning("unlink '%s': failed", pidfile); free(pidfile); } pidfile = NULL; |