From 66bc4fb27179121dfcd69490aaa0a5d65f319c7d Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Thu, 3 Jan 2008 17:40:32 +0000 Subject: Eric Leblond - add a call to autoheader which is needed to compile ulogd2 from subversion. - add a warning message to ulogd2 when it exits on error. It simply tell to look at the configuration file. - add an empty section which is needed to have NFCT logging working. --- src/ulogd.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/ulogd.c') diff --git a/src/ulogd.c b/src/ulogd.c index 0742925..2f23d2a 100644 --- a/src/ulogd.c +++ b/src/ulogd.c @@ -315,6 +315,13 @@ void __ulogd_log(int level, char *file, int line, const char *format, ...) } } +static void warn_and_exit(int daemonize) +{ + if (!daemonize) + fprintf(stderr, "Fatal error, check logfile.\n"); + exit(1); +} + /* clean results (set all values to 0 and free pointers) */ static void ulogd_clean_results(struct ulogd_pluginstance *pi) { @@ -914,44 +921,44 @@ int main(int argc, char* argv[]) if (config_register_file(ulogd_configfile)) { ulogd_log(ULOGD_FATAL, "error registering configfile \"%s\"\n", ulogd_configfile); - exit(1); + warn_and_exit(daemonize); } /* parse config file */ if (parse_conffile("global", &ulogd_kset)) { ulogd_log(ULOGD_FATAL, "parse_conffile\n"); - exit(1); + warn_and_exit(daemonize); } if (llist_empty(&ulogd_pi_stacks)) { ulogd_log(ULOGD_FATAL, "not even a single working plugin stack\n"); - exit(1); + warn_and_exit(daemonize); } if (change_uid) { ulogd_log(ULOGD_NOTICE, "Changing UID / GID\n"); if (setgid(gid)) { ulogd_log(ULOGD_FATAL, "can't set GID %u\n", gid); - exit(1); + warn_and_exit(daemonize); } if (setegid(gid)) { ulogd_log(ULOGD_FATAL, "can't sett effective GID %u\n", gid); - exit(1); + warn_and_exit(daemonize); } if (initgroups(user, gid)) { ulogd_log(ULOGD_FATAL, "can't set user secondary GID\n"); - exit(1); + warn_and_exit(daemonize); } if (setuid(uid)) { ulogd_log(ULOGD_FATAL, "can't set UID %u\n", uid); - exit(1); + warn_and_exit(daemonize); } if (seteuid(uid)) { ulogd_log(ULOGD_FATAL, "can't set effective UID %u\n", uid); - exit(1); + warn_and_exit(daemonize); } } -- cgit v1.2.3