[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ossec-cvs] ossec-hids: config.c (HEAD) main.c (HEAD) [dcid]
Module name: ossec-hids
Changes by: dcid 07/08/22 21:01:44
Modified files:
config.c main.c
Log message:
Description: More database fixes (better handling error conditions, etc)
Reviewed by: dcid
Bug:
Index: config.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/os_dbd/config.c,v
diff -u -r1.2 -r1.3
--- config.c 14 Aug 2007 00:29:34 -0000 1.2
+++ config.c 23 Aug 2007 00:01:44 -0000 1.3
@@ -37,6 +37,7 @@
db_config->user = NULL;
db_config->pass = NULL;
db_config->db = NULL;
+ db_config->db_type = 0;
/* Reading configuration */
@@ -51,18 +52,30 @@
free(tmp_config);
+ /* Checking if dbd isn't supposed to run. */
+ if(!db_config->host &&
+ !db_config->user &&
+ !db_config->pass &&
+ !db_config->db &&
+ !db_config->db_type)
+ {
+ return(0);
+ }
+
+
/* Checking for a valid config. */
if(!db_config->host ||
!db_config->user ||
!db_config->pass ||
- !db_config->db)
+ !db_config->db ||
+ !db_config->db_type)
{
merror(DB_MISS_CONFIG, ARGV0);
return(OS_INVALID);
}
- return(0);
+ return(1);
}
/* EOF */
Index: main.c
===================================================================
RCS file: /usr/cvsroot/ossec-hids/src/os_dbd/main.c,v
diff -u -r1.3 -r1.4
--- main.c 18 Aug 2007 03:38:34 -0000 1.3
+++ main.c 23 Aug 2007 00:01:44 -0000 1.4
@@ -25,6 +25,31 @@
#include "dbd.h"
+/* Prints information regarding enabled databases */
+void db_info()
+{
+ print_out("");
+ print_out("%s %s - %s", __name, __version, __author);
+
+ #ifdef UMYSQL
+ print_out("Compiled with MySQL support.");
+ #endif
+
+ #ifdef UPOSTGRES
+ print_out("Compiled with PostgreSQL support.");
+ #endif
+
+ #if !defined(UMYSQL) && !defined(UPOSTGRES)
+ print_out("Compiled without any Database support.");
+ #endif
+
+ print_out("");
+ print_out("%s",__license);
+
+ exit(1);
+}
+
+
int main(int argc, char **argv)
{
@@ -51,6 +76,9 @@
case 'V':
print_version();
break;
+ case 'v':
+ db_info();
+ break;
case 'h':
help();
break;
@@ -101,12 +129,31 @@
/* Reading configuration */
- if(OS_ReadDBConf(test_config, cfg, &db_config) < 0)
+ if((c = OS_ReadDBConf(test_config, cfg, &db_config)) < 0)
{
ErrorExit(CONFIG_ERROR, ARGV0, cfg);
}
+ /* Exit here if test config is set */
+ if(test_config)
+ exit(0);
+
+
+ /* Going on daemon mode */
+ nowDaemon();
+ goDaemon();
+
+
+
+ /* Not configured */
+ if(c == 0)
+ {
+ verbose("%s: Database not configured. Clean exit.", ARGV0);
+ exit(0);
+ }
+
+
/* Maybe disable this debug? */
debug1("%s: DEBUG: Connecting to '%s', using '%s', '%s', '%s'.",
ARGV0, db_config.host, db_config.user,
@@ -124,14 +171,6 @@
debug1("%s: DEBUG: db connected.", ARGV0);
- /* Going on daemon mode */
- if(!test_config)
- {
- nowDaemon();
- goDaemon();
- }
-
-
/* Privilege separation */
if(Privsep_SetGroup(gid) < 0)
ErrorExit(SETGID_ERROR,ARGV0,group);
@@ -161,11 +200,6 @@
}
- /* Exit here if test config is set */
- if(test_config)
- exit(0);
-
-
/* Changing user */
if(Privsep_SetUser(uid) < 0)
ErrorExit(SETUID_ERROR,ARGV0,user);
OSSEC home |
Main Index |
Thread Index
OSSEC project: www.ossec.net.
Mailling list information: http://www.ossec.net/en/mailing_lists.html.