aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cfg_file.h3
-rw-r--r--src/cfg_utils.c2
-rw-r--r--src/main.c14
-rw-r--r--src/main.h2
-rw-r--r--src/util.c8
5 files changed, 23 insertions, 6 deletions
diff --git a/src/cfg_file.h b/src/cfg_file.h
index 7bacb8aa9..78ad6e93a 100644
--- a/src/cfg_file.h
+++ b/src/cfg_file.h
@@ -153,7 +153,8 @@ struct config_file {
int controller_enabled; /**< whether controller is enabled */
char *control_password; /**< controller password */
- int no_fork; /**< if 1 do not call daemon() */
+ gboolean no_fork; /**< if 1 do not call daemon() */
+ gboolean config_test; /**< if TRUE do only config file test */
unsigned int workers_number; /**< number of workers */
enum rspamd_log_type log_type; /**< log type */
diff --git a/src/cfg_utils.c b/src/cfg_utils.c
index 2785e18d9..e90fe11cb 100644
--- a/src/cfg_utils.c
+++ b/src/cfg_utils.c
@@ -681,7 +681,7 @@ parse_err (const char *fmt, ...)
r += vsnprintf (logbuf + r, sizeof (logbuf) - r, fmt, aq);
va_end (aq);
- g_error ("%s", logbuf);
+ g_critical ("%s", logbuf);
}
void
diff --git a/src/main.c b/src/main.c
index 6a170726a..9c2da60b7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -265,9 +265,16 @@ main (int argc, char **argv, char **env)
rspamd->cfg->cfg_name = memory_pool_strdup (rspamd->cfg->cfg_pool, FIXED_CONFIG_FILE);
read_cmd_line (argc, argv, rspamd->cfg);
+
+ if (cfg->config_test) {
+ cfg->log_level = G_LOG_LEVEL_DEBUG;
+ }
+ else {
+ cfg->log_level = G_LOG_LEVEL_CRITICAL;
+ }
/* First set logger to console logger */
- cfg->log_fd = 2;
+ cfg->log_fd = STDERR_FILENO;
g_log_set_default_handler (file_log_function, cfg);
#ifndef HAVE_SETPROCTITLE
@@ -287,6 +294,11 @@ main (int argc, char **argv, char **env)
}
fclose (f);
+
+ if (cfg->config_test) {
+ fprintf (stderr, "syntax OK\n");
+ return EXIT_SUCCESS;
+ }
config_logger (rspamd, TRUE);
diff --git a/src/main.h b/src/main.h
index fab8a9040..8661346f1 100644
--- a/src/main.h
+++ b/src/main.h
@@ -17,7 +17,7 @@
#include "buffer.h"
/* Default values */
-#define FIXED_CONFIG_FILE "./rspamd.conf"
+#define FIXED_CONFIG_FILE CMAKE_PREFIX "/etc/rspamd.conf"
/* Time in seconds to exit for old worker */
#define SOFT_SHUTDOWN_TIME 60
/* Default metric name */
diff --git a/src/util.c b/src/util.c
index cffa5e06b..a7aea229c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -118,7 +118,7 @@ void
read_cmd_line (int argc, char **argv, struct config_file *cfg)
{
int ch;
- while ((ch = getopt(argc, argv, "hfc:")) != -1) {
+ while ((ch = getopt(argc, argv, "thfc:")) != -1) {
switch (ch) {
case 'f':
cfg->no_fork = 1;
@@ -128,13 +128,17 @@ read_cmd_line (int argc, char **argv, struct config_file *cfg)
cfg->cfg_name = memory_pool_strdup (cfg->cfg_pool, optarg);
}
break;
+ case 't':
+ cfg->config_test = 1;
+ break;
case 'h':
case '?':
default:
/* Show help message and exit */
printf ("Rspamd version " RVERSION "\n"
- "Usage: rspamd [-h] [-n] [-f] [-c config_file]\n"
+ "Usage: rspamd [-t] [-h] [-n] [-f] [-c config_file]\n"
"-h: This help message\n"
+ "-t: Do config test and exit\n"
"-f: Do not daemonize main process\n"
"-c: Specify config file (./rspamd.conf is used by default)\n");
exit (0);