41 #include <sys/types.h>
42 #include <sys/param.h>
65 # define MAXPATHLEN 4096
112 struct sigaction action;
115 config.
debug =
false;
129 log_msg(&config, LOG_ERR,
"Malloc for config struct failed");
136 if ((program = strrchr(argv[0],
'/'))) {
148 log_msg(&config, LOG_INFO,
"%s starting...", PACKAGE_NAME);
150 #ifdef ENFORCER_TIMESHIFT
151 if (getenv(
"ENFORCER_TIMESHIFT")) {
152 log_msg(&config, LOG_INFO,
"Timeshift mode detected, running once only!");
153 fprintf(stderr,
"WARNING: Timeshift mode detected, running once only!\n");
161 if(config.
debug)
log_msg(&config, LOG_INFO,
"%s DEBUG ON.", PACKAGE_NAME);
166 switch ((config.
pid = fork())) {
170 log_msg(&config, LOG_ERR,
"fork failed: %s", strerror(errno));
174 fprintf(stdout,
"OpenDNSSEC ods-enforcerd started (version %s), pid %d\n", PACKAGE_VERSION, (
int) config.
pid);
175 log_msg(&config, LOG_INFO,
"%s Parent exiting...", PACKAGE_NAME);
180 if (setsid() == -1) {
181 log_msg(&config, LOG_ERR,
"setsid() failed: %s", strerror(errno));
185 if ((fd = open(
"/dev/null", O_RDWR, 0)) != -1) {
186 (void)dup2(fd, STDIN_FILENO);
187 (void)dup2(fd, STDOUT_FILENO);
188 (void)dup2(fd, STDERR_FILENO);
192 log_msg(&config, LOG_INFO,
"%s forked OK...", PACKAGE_NAME);
194 log_msg(&config, LOG_INFO,
"%s in debug mode - not forking...", PACKAGE_NAME);
198 sigfillset(&action.sa_mask);
200 sigaction(SIGTERM, &action, NULL);
201 sigaction(SIGHUP, &action, NULL);
202 sigaction(SIGINT, &action, NULL);
203 sigaction(SIGILL, &action, NULL);
204 sigaction(SIGUSR1, &action, NULL);
205 sigaction(SIGALRM, &action, NULL);
206 sigaction(SIGCHLD, &action, NULL);
207 action.sa_handler = SIG_IGN;
208 sigaction(SIGPIPE, &action, NULL);
233 config.
uid = geteuid();
234 config.
gid = getegid();
235 config.
pid = getpid();
239 log_msg(&config, LOG_NOTICE,
"%s started (version %s), pid %d", PACKAGE_NAME, PACKAGE_VERSION,