os.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1999-2002, 2004, 2005, 2007-2009, 2012-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <config.h>
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <io.h>
#include <process.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <isc/strerror.h>
#include <named/ntservice.h>
static int devnullfd = -1;
static int lockfilefd = -1;
static char *version_error =
"named requires Windows 2000 Service Pack 2 or later to run correctly";
void
ns_paths_init(void) {
if (!Initialized)
Initialized = TRUE;
}
/*
* Due to Knowledge base article Q263823 we need to make sure that
* Windows 2000 systems have Service Pack 2 or later installed and
* warn when it isn't.
*/
static void
version_check(const char *progname) {
if ((isc_win32os_versioncheck(4, 0, 0, 0) >= 0) &&
(isc_win32os_versioncheck(5, 0, 0, 0) < 0))
return; /* No problem with Version 4.0 */
if (ntservice_isservice())
else
}
static void
setup_syslog(const char *progname) {
int options;
#ifdef LOG_NDELAY
options |= LOG_NDELAY;
#endif
}
void
ns_os_init(const char *progname) {
/*
* XXXMPA. We may need to split ntservice_init() in two and
* just mark as running in ns_os_started(). If we do that
* this is where the first part of ntservice_init() should be
* called from.
*
* XXX970 Remove comment if no problems by 9.7.0.
*
* ntservice_init();
*/
}
void
ns_os_daemonize(void) {
/*
* on even if it fails.
*/
if (devnullfd != -1) {
}
}
}
}
}
void
ns_os_opendevnull(void) {
}
void
ns_os_closedevnull(void) {
devnullfd = -1;
}
}
void
ns_os_chroot(const char *root) {
ns_main_earlyfatal("chroot(): isn't supported by Win32 API");
}
void
ns_os_inituserinfo(const char *username) {
}
void
ns_os_changeuser(void) {
}
void
ns_os_adjustnofile(void) {
}
void
ns_os_minprivs(void) {
}
static int
int fd;
return (-1);
return (-1);
if (append)
else {
}
return (fd);
}
static void
cleanup_pidfile(void) {
}
}
static void
cleanup_lockfile(void) {
if (lockfilefd != -1) {
lockfilefd = -1;
}
}
}
FILE *
char strbuf[ISC_STRERRORSIZE];
int fd;
if (fd < 0) {
ns_main_earlywarning("could not open file '%s': %s",
return (NULL);
}
ns_main_earlywarning("could not fdopen() file '%s': %s",
}
return (fp);
}
void
char strbuf[ISC_STRERRORSIZE];
void (*report)(const char *, ...);
/*
* The caller must ensure any required synchronization.
*/
return;
return;
}
if (pidlockfile == NULL) {
return;
}
(void)fclose(pidlockfile);
return;
}
(void)fclose(pidlockfile);
return;
}
(void)fclose(pidlockfile);
}
ns_os_issingleton(const char *filename) {
char strbuf[ISC_STRERRORSIZE];
OVERLAPPED o;
if (lockfilefd != -1)
return (ISC_TRUE);
return (ISC_TRUE);
ns_main_earlyfatal("couldn't allocate memory for '%s': %s",
}
/*
* ns_os_openfile() uses safeopen() which removes any existing
* files. We can't use that here.
*/
if (lockfilefd == -1) {
return (ISC_FALSE);
}
memset(&o, 0, sizeof(o));
/* Expect ERROR_LOCK_VIOLATION if already locked */
0, 0, 1, &o)) {
return (ISC_FALSE);
}
return (ISC_TRUE);
}
void
ns_os_shutdown(void) {
closelog();
if (lockfilefd != -1) {
0, 0, 0, 1);
lockfilefd = -1;
}
ntservice_shutdown(); /* This MUST be the last thing done */
}
int n;
return ((n == 0) ? ISC_R_SUCCESS : ISC_R_FAILURE);
}
void
}
void
ns_os_tzset(void) {
#ifdef HAVE_TZSET
tzset();
#endif
}
void
ns_os_started(void) {
}
static void
getuname(void) {
char *fvi;
char *arch;
if (fvilen == 0) {
goto err;
}
goto err;
}
goto err;
}
ffilen = 0;
goto err;
}
switch (sysinfo.wProcessorArchitecture) {
arch = "x86";
break;
arch = "arm";
break;
arch = "ia64";
break;
arch = "x64";
break;
default:
arch = "unknown architecture";
break;
}
"Windows %d %d build %d %d for %s\n",
arch);
err:
}
}
/*
* GetVersionEx() returns 6.2 (aka Windows 8.1) since it was obsoleted
* so we had to switch to the recommended way to get the Windows version.
*/
char *
ns_os_uname(void) {
getuname();
return (unamep);
}