os.c revision 52254f75267c734acf1f1fb982b6a3be05e93507
7d32c065c7bb56f281651ae3dd2888f32ce4f1d9Bob Halley * Copyright (C) 1999-2002, 2004-2011, 2013-2016 Internet Systems Consortium, Inc. ("ISC")
bb556a9bf3a15c7160fa4f1b71773ce12b1bedf6Bob Halley * This Source Code Form is subject to the terms of the Mozilla Public
bb556a9bf3a15c7160fa4f1b71773ce12b1bedf6Bob Halley * License, v. 2.0. If a copy of the MPL was not distributed with this
bb556a9bf3a15c7160fa4f1b71773ce12b1bedf6Bob Halley * file, You can obtain one at http://mozilla.org/MPL/2.0/.
15a44745412679c30a6d022733925af70a38b715David Lawrence#include <sys/types.h> /* dev_t FreeBSD 2.1 */
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <grp.h> /* Required for initgroups() on IRIX. */
#ifdef HAVE_LIBSCF
#ifndef ISC_FACILITY
* If there's no <linux/capability.h>, we don't care about <sys/prctl.h>
#ifndef HAVE_LINUX_CAPABILITY_H
#ifdef HAVE_LINUXTHREADS
#ifdef HAVE_LINUX_CAPABILITY_H
#ifdef HAVE_SYS_CAPABILITY_H
#ifdef HAVE_LINUX_TYPES_H
* and <string.h>) on 2.3 kernels.
#define _LINUX_FS_H
#include <syscall.h>
#ifndef SYS_capset
#ifndef __NR_capset
#ifdef HAVE_SYS_PRCTL_H
#ifndef PR_SET_KEEPCAPS
#ifdef HAVE_LIBCAP
typedef unsigned int cap_t;
#ifndef HAVE_LIBCAP
#ifndef HAVE_LIBCAP
#ifdef HAVE_LIBCAP
strbuf);
#ifdef HAVE_LIBCAP
#define INIT_CAP \
#define FREE_CAP \
linux_initialprivs(void) {
#ifdef HAVE_LIBCAP
int err;
* support named.conf options, this is now being added to test.
#ifdef HAVE_LIBCAP
linux_minprivs(void) {
#ifdef HAVE_LIBCAP
int err;
* support named.conf options, this is now being added to test.
#ifdef HAVE_LIBCAP
#ifdef HAVE_SYS_PRCTL_H
linux_keepcaps(void) {
if (getuid() != 0)
int options;
#ifdef LOG_NDELAY
#ifdef HAVE_LINUX_CAPABILITY_H
#ifdef HAVE_LINUXTHREADS
#ifdef SIGXFSZ
ns_os_daemonize(void) {
if (pid != 0) {
char buf;
_exit(0);
#ifdef HAVE_LINUXTHREADS
ns_os_started(void) {
char buf = 0;
ns_os_opendevnull(void) {
ns_os_closedevnull(void) {
static isc_boolean_t
all_digits(const char *s) {
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
#ifdef HAVE_LIBSCF
ns_smf_chroot = 0;
#ifdef HAVE_CHROOT
#ifdef HAVE_LIBSCF
endpwent();
if (getuid() == 0) {
ns_os_changeuser(void) {
#ifdef HAVE_LINUXTHREADS
#ifdef HAVE_LINUX_CAPABILITY_H
if (!non_root_caps)
strbuf);
ns_os_adjustnofile(void) {
#ifdef HAVE_LINUXTHREADS
ns_os_minprivs(void) {
#ifdef HAVE_SYS_PRCTL_H
#ifdef HAVE_LINUXTHREADS
int fd;
if (append)
return (fd);
cleanup_pidfile(void) {
cleanup_lockfile(void) {
unsigned int mode;
strbuf);
goto error;
goto error;
strbuf);
goto error;
strbuf);
#if defined(HAVE_SETEGID)
#if defined(HAVE_SETEUID)
FILE *
int fd;
if (f == NULL) {
return (NULL);
free(f);
return (NULL);
free(f);
#ifndef HAVE_LINUXTHREADS
#ifndef HAVE_LINUXTHREADS
#ifndef HAVE_LINUXTHREADS
if (fd < 0) {
return (NULL);
return (fp);
void (*report)(const char *, ...);
#ifdef HAVE_LINUXTHREADS
return (ISC_TRUE);
return (ISC_TRUE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
ns_os_shutdown(void) {
closelog();
char *res;
return (res);
#ifdef HAVE_LINUXTHREADS
ns_os_tzset(void) {
#ifdef HAVE_TZSET
tzset();
getuname(void) {
#ifdef HAVE_UNAME
ns_os_uname(void) {
getuname();
return (unamep);