41 #include <sys/types.h> 42 #include <sys/param.h> 65 # define MAXPATHLEN 4096 112 struct sigaction action;
115 config.
debug =
false;
130 log_msg(&config, LOG_ERR,
"Malloc for config struct failed");
137 if ((program = strrchr(argv[0],
'/'))) {
149 log_msg(&config, LOG_INFO,
"%s starting...", PACKAGE_NAME);
151 #ifdef ENFORCER_TIMESHIFT 152 if (getenv(
"ENFORCER_TIMESHIFT")) {
153 log_msg(&config, LOG_INFO,
"Timeshift mode detected, running once only!");
154 fprintf(stderr,
"WARNING: Timeshift mode detected, running once only!\n");
162 if(config.
debug)
log_msg(&config, LOG_INFO,
"%s DEBUG ON.", PACKAGE_NAME);
167 switch ((config.
pid = fork())) {
171 log_msg(&config, LOG_ERR,
"fork failed: %s", strerror(errno));
175 fprintf(stdout,
"OpenDNSSEC ods-enforcerd started (version %s), pid %d\n", PACKAGE_VERSION, (
int) config.
pid);
176 log_msg(&config, LOG_INFO,
"%s Parent exiting...", PACKAGE_NAME);
181 if (setsid() == -1) {
182 log_msg(&config, LOG_ERR,
"setsid() failed: %s", strerror(errno));
186 if ((fd = open(
"/dev/null", O_RDWR, 0)) != -1) {
187 (void)dup2(fd, STDIN_FILENO);
188 (void)dup2(fd, STDOUT_FILENO);
189 (void)dup2(fd, STDERR_FILENO);
193 log_msg(&config, LOG_INFO,
"%s forked OK...", PACKAGE_NAME);
195 log_msg(&config, LOG_INFO,
"%s in debug mode - not forking...", PACKAGE_NAME);
199 sigfillset(&action.sa_mask);
201 sigaction(SIGTERM, &action, NULL);
202 sigaction(SIGHUP, &action, NULL);
203 sigaction(SIGINT, &action, NULL);
204 sigaction(SIGILL, &action, NULL);
205 sigaction(SIGUSR1, &action, NULL);
206 sigaction(SIGALRM, &action, NULL);
207 sigaction(SIGCHLD, &action, NULL);
208 action.sa_handler = SIG_IGN;
209 sigaction(SIGPIPE, &action, NULL);
234 config.
uid = geteuid();
235 config.
gid = getegid();
236 config.
pid = getpid();
240 log_msg(&config, LOG_NOTICE,
"%s started (version %s), pid %d", PACKAGE_NAME, PACKAGE_VERSION,
void server_main(DAEMONCONFIG *config)
int main(int argc, char *argv[])
#define DEFAULT_LOG_FACILITY
void sig_handler(int sig)
int privdrop(const char *username, const char *groupname, const char *newroot)
int getPermsForDrop(DAEMONCONFIG *config)
void cmdlParse(DAEMONCONFIG *config, int *argc, char **argv)
void log_init(int facility, const char *program_name)
#define MAX_PASSWORD_LENGTH
void MsgRegister(int min, int max, const char **message, MSG_OUTPUT_FUNCTION output)
void ksm_log_msg(const char *format)
int createPidDir(DAEMONCONFIG *config)
#define MAX_SCHEMA_LENGTH
void log_msg(DAEMONCONFIG *config, int priority, const char *format,...)
int server_init(DAEMONCONFIG *config)