suricata: add daemon-directory config variable

It is now possible to use the 'daemon-directory' configuration
variable to specify the working directory of suricata in daemon
mode. This will permit to specify the place for core and other
related files.
pull/184/merge
Eric Leblond 13 years ago committed by Victor Julien
parent 3061452c5e
commit a1d1abfc05

@ -28,6 +28,7 @@
#include "runmodes.h"
#include "util-daemon.h"
#include "util-debug.h"
#include "conf.h"
#ifndef OS_WIN32
@ -116,6 +117,7 @@ void Daemonize (void) {
exit(EXIT_FAILURE);
} else if (pid == 0) {
/* Child continues here */
char *daemondir;
umask(027);
@ -125,15 +127,19 @@ void Daemonize (void) {
exit(EXIT_FAILURE);
}
/** \todo The daemon runs on the current directory, but later we'll want
to allow through the configuration file (or other means) to
change the running directory */
/* if ((chdir(DAEMON_WORKING_DIRECTORY)) < 0) {
SCLogError(SC_ERR_DAEMON, "Error changing to working directory");
exit(EXIT_FAILURE);
} */
chdir("/");
if (ConfGet("daemon-directory", &daemondir) == 1) {
if ((chdir(daemondir)) < 0) {
SCLogError(SC_ERR_DAEMON, "Error changing to working directory");
exit(EXIT_FAILURE);
}
}
#ifndef OS_WIN32
else {
if (chdir("/") < 0) {
SCLogError(SC_ERR_DAEMON, "Error changing to working directory '/'");
}
}
#endif
SetupLogging();

@ -41,6 +41,11 @@
# Will use this file if no --pidfile in command options.
#pid-file: /var/run/suricata.pid
# Daemon working directory
# Suricata will change directory to this one if provided
# Default: "/"
#daemon-directory: "/"
# Preallocated size for packet. Default is 1514 which is the classical
# size for pcap on ethernet. You should adjust this value to the highest
# packet size (MTU + hardware header) on your system.

Loading…
Cancel
Save