OpenDNSSEC-enforcer
1.4.9
Main Page
Data Structures
Files
File List
Globals
enforcer
common
daemon.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008-2009 Nominet UK. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions
6
* are met:
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
*
13
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
*
25
*/
26
27
#ifndef ENFORCER_DAEMON_H
28
#define ENFORCER_DAEMON_H
29
/*
30
* daemon.h code needed to get a daemon up and running
31
*
32
* edit the DAEMONCONFIG and cmlParse function
33
* in daemon_util.[c|h] to add options specific
34
* to your app
35
*
36
* gcc -o daemon daemon_util.c daemon.c
37
*
38
* Most of this is based on stuff I have seen in NSD
39
*/
40
#include "config.h"
41
#include <inttypes.h>
42
43
#ifdef HAVE_STDBOOL_H
44
# include <stdbool.h>
45
#else
46
# ifndef HAVE__BOOL
47
# ifdef __cplusplus
48
typedef
bool
_Bool
;
49
# else
50
# define _Bool signed char
51
# endif
/* __cplusplus */
52
# endif
/* HAVE__BOOL */
53
# define bool _Bool
54
# define false 0
55
# define true 1
56
# define __bool_true_false_are_defined 1
57
#endif
/* HAVE_STDBOOL_H */
58
59
#include <stdint.h>
60
#include <unistd.h>
61
#include <syslog.h>
62
63
/* Define some lengths of the char*s in the struct
64
MySQL allows e.g. 81 characters for the username,
65
set these stupidly high though */
66
#define MAX_PROG_NAME_LENGTH 255
67
#define MAX_USER_LENGTH 255
68
#define MAX_HOST_LENGTH 255
69
#define MAX_PASSWORD_LENGTH 255
70
#define MAX_SCHEMA_LENGTH 255
71
#define MAX_PORT_LENGTH 16
72
#define MAX_PID_LENGTH 255
73
#define MAX_LOG_USER_LENGTH 32
74
75
#ifdef LOG_DAEMON
76
#define DEFAULT_LOG_FACILITY LOG_DAEMON
77
#define DEFAULT_LOG_FACILITY_STRING "LOG_DAEMON"
78
#else
79
#define DEFAULT_LOG_FACILITY LOG_USER
80
#define DEFAULT_LOG_FACILITY_STRING "LOG_USER"
81
#endif
/* LOG_DAEMON */
82
83
/* struct to hold configuration */
84
typedef
struct
85
{
86
/* stuff that daemons always have */
87
const
char
*
program
;
88
bool
debug
;
89
bool
once
;
90
pid_t
pid
;
91
char
*
pidfile
;
92
uid_t
uid
;
93
gid_t
gid
;
94
char
*
username
;
95
char
*
groupname
;
96
#if 0
97
char
*chrootdir;
98
#endif
99
/* flag to indicate that SIGTERM was recieved */
100
int
term
;
101
102
/* Add app specific stuff here */
103
char
*
configfile
;
104
unsigned
char
*
user
;
105
unsigned
char
*
host
;
106
unsigned
char
*
password
;
107
unsigned
char
*
schema
;
108
unsigned
char
*
port
;
109
uint16_t
interval
;
110
uint16_t
keygeninterval
;
/* TODO remove this */
111
int
keycreate
;
112
int
manualKeyGeneration
;
113
int
rolloverNotify
;
114
char
*
DSSubmitCmd
;
115
int
DSSubCKA_ID
;
116
char
*
policy
;
117
118
int
log_user
;
/* log facility (or default of LOG_DAEMON) */
119
int
pidfile_set
;
120
121
}
DAEMONCONFIG
;
122
123
extern
int
daemon_our_pidfile
;
124
125
#define AUTHOR_NAME "John Dickinson"
126
#define COPYRIGHT_STR "Copyright (C) 2008 2009 Nominet UK"
127
128
#endif
/* ENFORCER_DAEMON_H */
DAEMONCONFIG::password
unsigned char * password
Definition:
daemon.h:106
DAEMONCONFIG::schema
unsigned char * schema
Definition:
daemon.h:107
DAEMONCONFIG::once
bool once
Definition:
daemon.h:89
DAEMONCONFIG::pid
pid_t pid
Definition:
daemon.h:90
DAEMONCONFIG
Definition:
daemon.h:84
DAEMONCONFIG::pidfile
char * pidfile
Definition:
daemon.h:91
DAEMONCONFIG::DSSubmitCmd
char * DSSubmitCmd
Definition:
daemon.h:114
DAEMONCONFIG::log_user
int log_user
Definition:
daemon.h:118
DAEMONCONFIG::program
const char * program
Definition:
daemon.h:87
DAEMONCONFIG::interval
uint16_t interval
Definition:
daemon.h:109
DAEMONCONFIG::username
char * username
Definition:
daemon.h:94
DAEMONCONFIG::uid
uid_t uid
Definition:
daemon.h:92
DAEMONCONFIG::rolloverNotify
int rolloverNotify
Definition:
daemon.h:113
DAEMONCONFIG::keygeninterval
uint16_t keygeninterval
Definition:
daemon.h:110
DAEMONCONFIG::configfile
char * configfile
Definition:
daemon.h:103
DAEMONCONFIG::host
unsigned char * host
Definition:
daemon.h:105
DAEMONCONFIG::pidfile_set
int pidfile_set
Definition:
daemon.h:119
DAEMONCONFIG::manualKeyGeneration
int manualKeyGeneration
Definition:
daemon.h:112
DAEMONCONFIG::term
int term
Definition:
daemon.h:100
DAEMONCONFIG::debug
bool debug
Definition:
daemon.h:88
DAEMONCONFIG::policy
char * policy
Definition:
daemon.h:116
DAEMONCONFIG::gid
gid_t gid
Definition:
daemon.h:93
daemon_our_pidfile
int daemon_our_pidfile
Definition:
daemon.c:98
DAEMONCONFIG::groupname
char * groupname
Definition:
daemon.h:95
DAEMONCONFIG::port
unsigned char * port
Definition:
daemon.h:108
DAEMONCONFIG::keycreate
int keycreate
Definition:
daemon.h:111
DAEMONCONFIG::user
unsigned char * user
Definition:
daemon.h:104
DAEMONCONFIG::DSSubCKA_ID
int DSSubCKA_ID
Definition:
daemon.h:115
_Bool
#define _Bool
Definition:
daemon.h:50
Generated by
1.8.11