os.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * Copyright (C) 1999, 2000 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark 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
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * copyright notice and this permission notice appear in all copies.
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
7ace3277956c49f7554b7130ef761bde3b35db30Mark Andrews/* $Id: os.c,v 1.29 2000/08/01 01:12:21 tale Exp $ */
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
#ifdef HAVE_LINUXTHREADS
#ifdef HAVE_LINUX_CAPABILITY_H
* and <string.h>) on 2.3 kernels.
#define _LINUX_FS_H
#ifdef HAVE_LINUX_PRCTL_H
#ifndef SYS_capset
linux_initialprivs(void) {
unsigned int caps;
caps = 0;
linux_minprivs(void) {
unsigned int caps;
caps = 0;
linux_keepcaps(void) {
if (getuid() != 0)
int options;
#ifdef LOG_NDELAY
#ifdef HAVE_LINUX_CAPABILITY_H
#ifdef HAVE_LINUXTHREADS
ns_os_daemonize(void) {
int fd;
if (pid != 0)
_exit(0);
#ifdef HAVE_LINUXTHREADS
static isc_boolean_t
all_digits(const char *s) {
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
endpwent();
if (getuid() == 0) {
ns_os_changeuser(void) {
#ifdef HAVE_LINUXTHREADS
if (!non_root_caps)
ns_os_minprivs(void) {
#ifdef HAVE_LINUX_CAPABILITY_H
cleanup_pidfile(void) {
int fd;
if (fd < 0)
#ifdef HAVE_LINUXTHREADS
filename);
filename);
ns_os_shutdown(void) {
closelog();