os.c revision 0956e3d6074b197eb6aeadd6aa985e60e0dbd15d
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * Copyright (C) 1999-2001 Internet Software Consortium.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1d32b1df372d6be6bac6450739b9e5ea23819995Evan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
8aee18709f238406719768b8a6b843a15c5075f8Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30a60d2aff0ec1810262a8b8efc532e28b32bd57Evan Hunt/* $Id: os.c,v 1.17 2002/08/03 01:31:48 mayer Exp $ */
c634c94d673f1bab17e7f65d332f989b683e712cDavid Lawrence "named requires Windows 2000 Service Pack 2 or later to run correctly";
28002bd7cb4baa0eab9f47e1e51069c5ea7ea5d4Andreas Gustafsson ns_g_conffile = isc_ntpaths_get(NAMED_CONF_PATH);
28002bd7cb4baa0eab9f47e1e51069c5ea7ea5d4Andreas Gustafsson lwresd_g_conffile = isc_ntpaths_get(LWRES_CONF_PATH);
222d38735f97f771054e223b03f84c5858252332Evan Hunt lwresd_g_resolvconffile = isc_ntpaths_get(RESOLV_CONF_PATH);
b5b934a0bb46aded1552a17473652b5a7f4a3274Evan Hunt ns_g_defaultpidfile = isc_ntpaths_get(NAMED_PID_PATH);
b5b934a0bb46aded1552a17473652b5a7f4a3274Evan Hunt lwresd_g_defaultpidfile = isc_ntpaths_get(LWRESD_PID_PATH);
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer ns_g_keyfile = isc_ntpaths_get(RNDC_KEY_PATH);
c3c6770e537ea916265c78d0294ad108233e17c1Michael Sawyer * Due to Knowledge base article Q263823 we need to make sure that
222d38735f97f771054e223b03f84c5858252332Evan Hunt * Windows 2000 systems have Service Pack 2 or later installed and
c634c94d673f1bab17e7f65d332f989b683e712cDavid Lawrence * warn when it isn't.
c634c94d673f1bab17e7f65d332f989b683e712cDavid Lawrence return; /* No problem with Version 4.0 */
222d38735f97f771054e223b03f84c5858252332Evan Hunt * Try to set stdin, stdout, and stderr to /dev/null, but press
9069215eac23e32f4ef1c8e44ad7ff2865cfcdacEvan Hunt * on even if it fails.
b5b934a0bb46aded1552a17473652b5a7f4a3274Evan Hunt * XXXMLG The close() calls here are unneeded on all but NetBSD, but
b5b934a0bb46aded1552a17473652b5a7f4a3274Evan Hunt * are harmless to include everywhere. dup2() is supposed to close
222d38735f97f771054e223b03f84c5858252332Evan Hunt * the FD if it is in use, but unproven-pthreads-0.16 is broken
b5b934a0bb46aded1552a17473652b5a7f4a3274Evan Hunt * and will end up closing the wrong FD. This will be fixed eventually,
b5b934a0bb46aded1552a17473652b5a7f4a3274Evan Hunt * and these calls will be removed.
222d38735f97f771054e223b03f84c5858252332Evan Huntsafe_open(const char *filename, isc_boolean_t append) {
47e70d820ed07895a25e5b3520adf953114ac01eEvan Hunt return (-1);
d58e33bfabfee19a035031dac633d36659738d56Evan Hunt return (-1);
6de9744cf9c64be2145f663e4051196a4eaa9d45Evan Huntns_os_writepidfile(const char *filename, isc_boolean_t first_time) {
6de9744cf9c64be2145f663e4051196a4eaa9d45Evan Hunt void (*report)(const char *, ...);
6de9744cf9c64be2145f663e4051196a4eaa9d45Evan Hunt * The caller must ensure any required synchronization.
222d38735f97f771054e223b03f84c5858252332Evan Hunt report = first_time ? ns_main_earlyfatal : ns_main_earlywarning;
6de9744cf9c64be2145f663e4051196a4eaa9d45Evan Hunt (*report)("couldn't malloc '%s': %s", filename, strbuf);
cba23be7ba724b527f6a60c14caaeca9502fbc79Evan Hunt /* This is safe. */
cba23be7ba724b527f6a60c14caaeca9502fbc79Evan Hunt (*report)("couldn't open pid file '%s': %s", filename, strbuf);
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews if (fprintf(lockfile, "%ld\n", (long)pid) < 0) {
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews (*report)("fprintf() to pid file '%s' failed", filename);
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews (*report)("fflush() to pid file '%s' failed", filename);
c5272fb3303425f794dab68f734f6a2a45dce01eMichael Sawyer ntservice_shutdown(); /* This MUST be the last thing done */
222d38735f97f771054e223b03f84c5858252332Evan Hunt return ((n == 0) ? ISC_R_SUCCESS : ISC_R_FAILURE);