OpenDNSSEC-enforcer
1.3.4
|
00001 /* 00002 * $Id: daemon.h 3078 2010-03-22 21:52:57Z sion $ 00003 * 00004 * Copyright (c) 2008-2009 Nominet UK. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00016 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00017 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00018 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00019 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00020 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00021 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00023 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 00025 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 */ 00028 00029 #ifndef ENFORCER_DAEMON_H 00030 #define ENFORCER_DAEMON_H 00031 /* 00032 * daemon.h code needed to get a daemon up and running 00033 * 00034 * edit the DAEMONCONFIG and cmlParse function 00035 * in daemon_util.[c|h] to add options specific 00036 * to your app 00037 * 00038 * gcc -o daemon daemon_util.c daemon.c 00039 * 00040 * Most of this is based on stuff I have seen in NSD 00041 */ 00042 #include "config.h" 00043 #include <inttypes.h> 00044 00045 #ifdef HAVE_STDBOOL_H 00046 # include <stdbool.h> 00047 #else 00048 # ifndef HAVE__BOOL 00049 # ifdef __cplusplus 00050 typedef bool _Bool; 00051 # else 00052 # define _Bool signed char 00053 # endif /* __cplusplus */ 00054 # endif /* HAVE__BOOL */ 00055 # define bool _Bool 00056 # define false 0 00057 # define true 1 00058 # define __bool_true_false_are_defined 1 00059 #endif /* HAVE_STDBOOL_H */ 00060 00061 #include <stdint.h> 00062 #include <unistd.h> 00063 #include <syslog.h> 00064 00065 /* Define some lengths of the char*s in the struct 00066 MySQL allows e.g. 81 characters for the username, 00067 set these stupidly high though */ 00068 #define MAX_PROG_NAME_LENGTH 255 00069 #define MAX_USER_LENGTH 255 00070 #define MAX_HOST_LENGTH 255 00071 #define MAX_PASSWORD_LENGTH 255 00072 #define MAX_SCHEMA_LENGTH 255 00073 #define MAX_PORT_LENGTH 16 00074 #define MAX_PID_LENGTH 255 00075 #define MAX_LOG_USER_LENGTH 32 00076 00077 #ifdef LOG_DAEMON 00078 #define DEFAULT_LOG_FACILITY LOG_DAEMON 00079 #define DEFAULT_LOG_FACILITY_STRING "LOG_DAEMON" 00080 #else 00081 #define DEFAULT_LOG_FACILITY LOG_USER 00082 #define DEFAULT_LOG_FACILITY_STRING "LOG_USER" 00083 #endif /* LOG_DAEMON */ 00084 00085 /* struct to hold configuration */ 00086 typedef struct 00087 { 00088 /* stuff that daemons always have */ 00089 const char *program; 00090 bool debug; 00091 bool once; 00092 pid_t pid; 00093 char *pidfile; 00094 uid_t uid; 00095 gid_t gid; 00096 char *username; 00097 char *groupname; 00098 #if 0 00099 char *chrootdir; 00100 #endif 00101 /* flag to indicate that SIGTERM was recieved */ 00102 int term; 00103 00104 /* Add app specific stuff here */ 00105 char *configfile; 00106 unsigned char* user; 00107 unsigned char* host; 00108 unsigned char* password; 00109 unsigned char* schema; 00110 unsigned char* port; 00111 uint16_t interval; 00112 uint16_t keygeninterval; /* TODO remove this */ 00113 int keycreate; 00114 int manualKeyGeneration; 00115 int rolloverNotify; 00116 char* DSSubmitCmd; 00117 00118 int log_user; /* log facility (or default of LOG_DAEMON) */ 00119 00120 } DAEMONCONFIG; 00121 00122 00123 #define AUTHOR_NAME "John Dickinson" 00124 #define COPYRIGHT_STR "Copyright (C) 2008 2009 Nominet UK" 00125 00126 #endif /* ENFORCER_DAEMON_H */