43 #include <sys/types.h>
44 #include <sys/param.h>
67 # define MAXPATHLEN 4096
114 struct sigaction action;
117 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,