43 #include <sys/types.h>
44 #include <sys/param.h>
67 # define MAXPATHLEN 4096
109 struct sigaction action;
112 config.
debug =
false;
125 log_msg(&config, LOG_ERR,
"Malloc for config struct failed");
132 if ((program = strrchr(argv[0],
'/'))) {
144 log_msg(&config, LOG_INFO,
"%s starting...", PACKAGE_NAME);
146 #ifdef ENFORCER_TIMESHIFT
147 if (getenv(
"ENFORCER_TIMESHIFT")) {
148 log_msg(&config, LOG_INFO,
"Timeshift mode detected, running once only!");
149 fprintf(stderr,
"WARNING: Timeshift mode detected, running once only!\n");
157 if(config.
debug)
log_msg(&config, LOG_INFO,
"%s DEBUG ON.", PACKAGE_NAME);
162 switch ((config.
pid = fork())) {
166 log_msg(&config, LOG_ERR,
"fork failed: %s", strerror(errno));
170 fprintf(stdout,
"OpenDNSSEC ods-enforcerd started (version %s), pid %d\n", PACKAGE_VERSION, (
int) config.
pid);
171 log_msg(&config, LOG_INFO,
"%s Parent exiting...", PACKAGE_NAME);
176 if (setsid() == -1) {
177 log_msg(&config, LOG_ERR,
"setsid() failed: %s", strerror(errno));
181 if ((fd = open(
"/dev/null", O_RDWR, 0)) != -1) {
182 (void)dup2(fd, STDIN_FILENO);
183 (void)dup2(fd, STDOUT_FILENO);
184 (void)dup2(fd, STDERR_FILENO);
188 log_msg(&config, LOG_INFO,
"%s forked OK...", PACKAGE_NAME);
190 log_msg(&config, LOG_INFO,
"%s in debug mode - not forking...", PACKAGE_NAME);
194 sigfillset(&action.sa_mask);
196 sigaction(SIGTERM, &action, NULL);
197 sigaction(SIGHUP, &action, NULL);
198 sigaction(SIGINT, &action, NULL);
199 sigaction(SIGILL, &action, NULL);
200 sigaction(SIGUSR1, &action, NULL);
201 sigaction(SIGALRM, &action, NULL);
202 sigaction(SIGCHLD, &action, NULL);
203 action.sa_handler = SIG_IGN;
204 sigaction(SIGPIPE, &action, NULL);
229 config.
uid = geteuid();
230 config.
gid = getegid();
231 config.
pid = getpid();
235 log_msg(&config, LOG_NOTICE,
"%s started (version %s), pid %d", PACKAGE_NAME, PACKAGE_VERSION,