#include <gmime/gmime.h>
#endif
+#define CMAKE_PREFIX "${CMAKE_INSTALL_PREFIX}"
+
/* Forwarded declaration */
struct module_ctx;
struct config_file;
# log_facility = "LOG_MAIL";
# Log file is used with log type "file"
- # log_file = /var/log/rspamd.log
+ # log_file = "/var/log/rspamd.log"
};
# Limit for statfile pool size
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 */
r += vsnprintf (logbuf + r, sizeof (logbuf) - r, fmt, aq);
va_end (aq);
- g_error ("%s", logbuf);
+ g_critical ("%s", logbuf);
}
void
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
}
fclose (f);
+
+ if (cfg->config_test) {
+ fprintf (stderr, "syntax OK\n");
+ return EXIT_SUCCESS;
+ }
config_logger (rspamd, TRUE);
#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 */
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;
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);