projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge tag 'upstream/2.7'
[ossec-hids.git]
/
src
/
os_dbd
/
main.c
diff --git
a/src/os_dbd/main.c
b/src/os_dbd/main.c
index
d674e33
..
6e0b2a2
100755
(executable)
--- a/
src/os_dbd/main.c
+++ b/
src/os_dbd/main.c
@@
-1,14
+1,15
@@
-/* @(#) $Id: main.c,v 1.17 2009/11/18 19:07:40 dcid Exp $ */
+/* @(#) $Id: ./src/os_dbd/main.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
* Foundation.
*
* 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
*/
* online at: http://www.ossec.net/en/licensing.html
*/
@@
-30,7
+31,7
@@
void db_info()
{
print_out(" ");
print_out("%s %s - %s", __name, __version, __author);
{
print_out(" ");
print_out("%s %s - %s", __name, __version, __author);
-
+
#ifdef UMYSQL
print_out("Compiled with MySQL support.");
#endif
#ifdef UMYSQL
print_out("Compiled with MySQL support.");
#endif
@@
-42,7
+43,7
@@
void db_info()
#if !defined(UMYSQL) && !defined(UPOSTGRES)
print_out("Compiled without any Database support.");
#endif
#if !defined(UMYSQL) && !defined(UPOSTGRES)
print_out("Compiled without any Database support.");
#endif
-
+
print_out(" ");
print_out("%s",__license);
print_out(" ");
print_out("%s",__license);
@@
-70,7
+71,7
@@
int main(int argc, char **argv)
/* Setting the name */
OS_SetName(ARGV0);
/* Setting the name */
OS_SetName(ARGV0);
-
+
while((c = getopt(argc, argv, "vVdhtfu:g:D:c:")) != -1){
switch(c){
while((c = getopt(argc, argv, "vVdhtfu:g:D:c:")) != -1){
switch(c){
@@
-79,7
+80,7
@@
int main(int argc, char **argv)
break;
case 'v':
db_info();
break;
case 'v':
db_info();
- break;
+ break;
case 'h':
help(ARGV0);
break;
case 'h':
help(ARGV0);
break;
@@
-103,13
+104,14
@@
int main(int argc, char **argv)
if(!optarg)
ErrorExit("%s: -D needs an argument",ARGV0);
dir=optarg;
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':
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);
break;
default:
help(ARGV0);
@@
-142,9
+144,9
@@
int main(int argc, char **argv)
/* Exit here if test config is set */
if(test_config)
exit(0);
/* Exit here if test config is set */
if(test_config)
exit(0);
-
-
- if(!run_foreground)
+
+
+ if(!run_foreground)
{
/* Going on daemon mode */
nowDaemon();
{
/* Going on daemon mode */
nowDaemon();
@@
-152,7
+154,7
@@
int main(int argc, char **argv)
}
}
-
+
/* Not configured */
if(c == 0)
{
/* Not configured */
if(c == 0)
{
@@
-160,10
+162,10
@@
int main(int argc, char **argv)
exit(0);
}
exit(0);
}
-
+
/* Maybe disable this debug? */
debug1("%s: DEBUG: Connecting to '%s', using '%s', '%s', '%s', %d,'%s'.",
/* Maybe disable this debug? */
debug1("%s: DEBUG: Connecting to '%s', using '%s', '%s', '%s', %d,'%s'.",
- ARGV0, db_config.host, db_config.user,
+ ARGV0, db_config.host, db_config.user,
db_config.pass, db_config.db,db_config.port,db_config.sock);
db_config.pass, db_config.db,db_config.port,db_config.sock);
@@
-174,13
+176,13
@@
int main(int argc, char **argv)
/* Getting maximum reconned attempts */
db_config.maxreconnect = getDefine_Int("dbd",
"reconnect_attempts", 1, 9999);
/* Getting maximum reconned attempts */
db_config.maxreconnect = getDefine_Int("dbd",
"reconnect_attempts", 1, 9999);
-
-
+
+
/* Connecting to the database */
c = 0;
while(c <= (db_config.maxreconnect * 10))
{
/* Connecting to the database */
c = 0;
while(c <= (db_config.maxreconnect * 10))
{
- db_config.conn = osdb_connect(db_config.host, db_config.user,
+ db_config.conn = osdb_connect(db_config.host, db_config.user,
db_config.pass, db_config.db,
db_config.port,db_config.sock);
db_config.pass, db_config.db,
db_config.port,db_config.sock);
@@
-192,7
+194,7
@@
int main(int argc, char **argv)
c++;
sleep(c * 60);
c++;
sleep(c * 60);
-
+
}
}
@@
-202,18
+204,18
@@
int main(int argc, char **argv)
merror(DB_CONFIGERR, ARGV0);
ErrorExit(CONFIG_ERROR, ARGV0, cfg);
}
merror(DB_CONFIGERR, ARGV0);
ErrorExit(CONFIG_ERROR, ARGV0, cfg);
}
-
+
/* We must notify that we connected -- easy debugging */
/* We must notify that we connected -- easy debugging */
- verbose("%s: Connected to database '%s' at '%s'.",
+ verbose("%s: Connected to database '%s' at '%s'.",
ARGV0, db_config.db, db_config.host);
ARGV0, db_config.db, db_config.host);
-
+
/* Privilege separation */
if(Privsep_SetGroup(gid) < 0)
ErrorExit(SETGID_ERROR,ARGV0,group);
/* Privilege separation */
if(Privsep_SetGroup(gid) < 0)
ErrorExit(SETGID_ERROR,ARGV0,group);
-
+
/* chrooting */
if(Privsep_Chroot(dir) < 0)
ErrorExit(CHROOT_ERROR,ARGV0,dir);
/* chrooting */
if(Privsep_Chroot(dir) < 0)
ErrorExit(CHROOT_ERROR,ARGV0,dir);
@@
-237,8
+239,8
@@
int main(int argc, char **argv)
ErrorExit(CONFIG_ERROR, ARGV0, cfg);
}
ErrorExit(CONFIG_ERROR, ARGV0, cfg);
}
-
- /* Changing user */
+
+ /* Changing user */
if(Privsep_SetUser(uid) < 0)
ErrorExit(SETUID_ERROR,ARGV0,user);
if(Privsep_SetUser(uid) < 0)
ErrorExit(SETUID_ERROR,ARGV0,user);
@@
-250,15
+252,15
@@
int main(int argc, char **argv)
/* Signal manipulation */
StartSIG(ARGV0);
/* Signal manipulation */
StartSIG(ARGV0);
-
+
/* Creating PID files */
if(CreatePID(ARGV0, getpid()) < 0)
ErrorExit(PID_ERROR,ARGV0);
/* Creating PID files */
if(CreatePID(ARGV0, getpid()) < 0)
ErrorExit(PID_ERROR,ARGV0);
-
+
/* Start up message */
verbose(STARTUP_MSG, ARGV0, (int)getpid());
/* Start up message */
verbose(STARTUP_MSG, ARGV0, (int)getpid());
-
+
/* the real daemon now */
OS_DBD(&db_config);
/* the real daemon now */
OS_DBD(&db_config);