-/* @(#) $Id$ */
+/* @(#) $Id: ./src/os_csyslogd/main.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
* License (version 2) as published by the FSF - Free Software
* Foundation.
*
- * License details at the LICENSE file included with OSSEC or
+ * License details at the LICENSE file included with OSSEC or
* online at: http://www.ossec.net/en/licensing.html
*/
/* Setting the name */
OS_SetName(ARGV0);
-
+
while((c = getopt(argc, argv, "vVdhtfu:g:D:c:")) != -1){
switch(c){
break;
case 'v':
print_version();
- break;
+ break;
case 'h':
help(ARGV0);
break;
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
dir=optarg;
+ break;
case 'c':
if(!optarg)
ErrorExit("%s: -c needs an argument",ARGV0);
cfg = optarg;
break;
case 't':
- test_config = 1;
+ test_config = 1;
break;
default:
help(ARGV0);
if(ltmp)
*ltmp = '\0';
}
-
+
/* Exit here if test config is set */
if(test_config)
exit(0);
-
-
- if (!run_foreground)
+
+
+ if (!run_foreground)
{
/* Going on daemon mode */
nowDaemon();
}
-
+
/* Not configured */
if(!syslog_config || !syslog_config[0])
{
exit(0);
}
-
+
/* Privilege separation */
if(Privsep_SetGroup(gid) < 0)
ErrorExit(SETGID_ERROR,ARGV0,group);
-
+
/* chrooting */
if(Privsep_Chroot(dir) < 0)
ErrorExit(CHROOT_ERROR,ARGV0,dir);
nowChroot();
-
- /* Changing user */
+
+ /* Changing user */
if(Privsep_SetUser(uid) < 0)
ErrorExit(SETUID_ERROR,ARGV0,user);
/* Signal manipulation */
StartSIG(ARGV0);
-
+
/* Creating PID files */
if(CreatePID(ARGV0, getpid()) < 0)
ErrorExit(PID_ERROR, ARGV0);
-
+
/* Start up message */
verbose(STARTUP_MSG, ARGV0, (int)getpid());
-
+
/* the real daemon now */
OS_CSyslogD(syslog_config);