os.c File Reference

#include <config.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <syslog.h>
#include <unistd.h>
#include <isc/buffer.h>
#include <isc/file.h>
#include <isc/print.h>
#include <isc/resource.h>
#include <isc/result.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <named/main.h>
#include <named/os.h>

Go to the source code of this file.

Defines

#define ISC_FACILITY   LOG_DAEMON

Functions

static void setup_syslog (const char *progname)
void ns_os_init (const char *progname)
void ns_os_daemonize (void)
void ns_os_started (void)
void ns_os_opendevnull (void)
void ns_os_closedevnull (void)
static isc_boolean_t all_digits (const char *s)
void ns_os_chroot (const char *root)
void ns_os_inituserinfo (const char *username)
void ns_os_changeuser (void)
void ns_os_adjustnofile (void)
void ns_os_minprivs (void)
static int safe_open (const char *filename, mode_t mode, isc_boolean_t append)
static void cleanup_pidfile (void)
static void cleanup_lockfile (void)
static int mkdirpath (char *filename, void(*report)(const char *,...))
static void setperms (uid_t uid, gid_t gid)
FILE * ns_os_openfile (const char *filename, mode_t mode, isc_boolean_t switch_user)
void ns_os_writepidfile (const char *filename, isc_boolean_t first_time)
isc_boolean_t ns_os_issingleton (const char *filename)
void ns_os_shutdown (void)
isc_result_t ns_os_gethostname (char *buf, size_t len)
static char * next_token (char **stringp, const char *delim)
void ns_os_shutdownmsg (char *command, isc_buffer_t *text)
void ns_os_tzset (void)

Variables

static char * pidfile = NULL
static char * lockfile = NULL
static int devnullfd = -1
static int singletonfd = -1
static struct passwd * runas_pw = NULL
static isc_boolean_t done_setuid = ISC_FALSE
static int dfd [2] = { -1, -1 }


Detailed Description

Definition in file os.c.


Define Documentation

#define ISC_FACILITY   LOG_DAEMON

Definition at line 60 of file os.c.


Function Documentation

static void setup_syslog ( const char *  progname  )  [static]

Definition at line 371 of file os.c.

References ISC_FACILITY, and isc_file_basename().

Referenced by ns_os_init().

void ns_os_init ( const char *  progname  ) 

Definition at line 382 of file os.c.

References setup_syslog().

Referenced by main().

void ns_os_daemonize ( void   ) 

Definition at line 396 of file os.c.

References devnullfd, dfd, isc__strerror(), ISC_STRERRORSIZE, and ns_main_earlyfatal().

Referenced by setup().

void ns_os_started ( void   ) 

Definition at line 468 of file os.c.

References dfd, and ns_main_earlyfatal().

Referenced by view_loaded().

void ns_os_opendevnull ( void   ) 

Definition at line 484 of file os.c.

References devnullfd.

Referenced by setup().

void ns_os_closedevnull ( void   ) 

Definition at line 489 of file os.c.

References devnullfd.

Referenced by main().

static isc_boolean_t all_digits ( const char *  s  )  [static]

Definition at line 499 of file os.c.

References ISC_FALSE, and ISC_TRUE.

Referenced by ns_os_inituserinfo().

void ns_os_chroot ( const char *  root  ) 

Definition at line 511 of file os.c.

References isc__strerror(), ISC_STRERRORSIZE, and ns_main_earlyfatal().

Referenced by setup().

void ns_os_inituserinfo ( const char *  username  ) 

Definition at line 537 of file os.c.

References all_digits(), isc__strerror(), ISC_STRERRORSIZE, ns_main_earlyfatal(), and runas_pw.

Referenced by setup().

void ns_os_changeuser ( void   ) 

Definition at line 561 of file os.c.

References done_setuid, isc__strerror(), ISC_STRERRORSIZE, ISC_TRUE, ns_main_earlyfatal(), ns_main_earlywarning(), and runas_pw.

Referenced by load_configuration(), and ns_os_minprivs().

void ns_os_adjustnofile ( void   ) 

Definition at line 608 of file os.c.

References ISC_R_SUCCESS, isc_resource_openfiles, isc_resource_setlimit(), ISC_RESOURCE_UNLIMITED, and ns_main_earlywarning().

Referenced by setup().

void ns_os_minprivs ( void   ) 

Definition at line 626 of file os.c.

References ns_os_changeuser().

Referenced by setup().

static int safe_open ( const char *  filename,
mode_t  mode,
isc_boolean_t  append 
) [static]

Definition at line 641 of file os.c.

Referenced by ns_os_openfile().

static void cleanup_pidfile ( void   )  [static]

Definition at line 664 of file os.c.

References free(), ns_main_earlywarning(), and pidfile.

static void cleanup_lockfile ( void   )  [static]

Definition at line 676 of file os.c.

References free(), lockfile, ns_main_earlywarning(), and singletonfd.

static int mkdirpath ( char *  filename,
void(*)(const char *,...)  report 
) [static]

Definition at line 697 of file os.c.

References error(), isc__strerror(), ISC_STRERRORSIZE, report(), and runas_pw.

Referenced by ns_os_openfile().

static void setperms ( uid_t  uid,
gid_t  gid 
) [static]

Definition at line 751 of file os.c.

References isc__strerror(), ISC_STRERRORSIZE, and ns_main_earlywarning().

Referenced by ns_os_openfile().

FILE* ns_os_openfile ( const char *  filename,
mode_t  mode,
isc_boolean_t  switch_user 
)

Definition at line 793 of file os.c.

References free(), isc__strerror(), ISC_FALSE, ISC_STRERRORSIZE, mkdirpath(), ns_main_earlywarning(), runas_pw, safe_open(), setperms(), and strdup().

Referenced by generate_session_key().

void ns_os_writepidfile ( const char *  filename,
isc_boolean_t  first_time 
)

Definition at line 871 of file os.c.

Referenced by load_configuration().

isc_boolean_t ns_os_issingleton ( const char *  filename  ) 

Definition at line 922 of file os.c.

Referenced by check_lockfile().

void ns_os_shutdown ( void   ) 

Definition at line 977 of file os.c.

Referenced by fatal(), and main().

isc_result_t ns_os_gethostname ( char *  buf,
size_t  len 
)

Definition at line 984 of file os.c.

Referenced by do_hostname_lookup(), do_id_lookup(), and ns_client_addopt().

static char* next_token ( char **  stringp,
const char *  delim 
) [static]

Definition at line 992 of file os.c.

void ns_os_shutdownmsg ( char *  command,
isc_buffer_t text 
)

Definition at line 1004 of file os.c.

Referenced by ns_control_docommand().

void ns_os_tzset ( void   ) 

Definition at line 1038 of file os.c.

Referenced by setup().


Variable Documentation

char* pidfile = NULL [static]

Definition at line 54 of file os.c.

Referenced by cleanup_pidfile().

char* lockfile = NULL [static]

Definition at line 55 of file os.c.

Referenced by cleanup_lockfile().

int devnullfd = -1 [static]

Definition at line 56 of file os.c.

Referenced by ns_os_closedevnull(), ns_os_daemonize(), and ns_os_opendevnull().

int singletonfd = -1 [static]

Definition at line 57 of file os.c.

Referenced by cleanup_lockfile().

struct passwd* runas_pw = NULL [static]

Definition at line 111 of file os.c.

Referenced by mkdirpath(), ns_os_changeuser(), ns_os_inituserinfo(), and ns_os_openfile().

isc_boolean_t done_setuid = ISC_FALSE [static]

Definition at line 112 of file os.c.

Referenced by ns_os_changeuser().

int dfd[2] = { -1, -1 } [static]

Definition at line 113 of file os.c.

Referenced by ns_os_daemonize(), and ns_os_started().


Generated on Tue Apr 28 17:41:19 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha