[Openvas-commits] r5499 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Oct 12 15:46:05 CEST 2009
Author: mattm
Date: 2009-10-12 15:46:02 +0200 (Mon, 12 Oct 2009)
New Revision: 5499
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage.h
trunk/openvas-manager/src/omp.c
trunk/openvas-manager/src/omp.h
trunk/openvas-manager/src/ompd.c
trunk/openvas-manager/src/ompd.h
trunk/openvas-manager/src/openvasmd.c
trunk/openvas-manager/src/tasks_sql.h
Log:
Add a --database option.
* src/tasks_sql.h (manage_migrate, init_manage_process, init_manage): Add
database arg. Use to init database. Update callers.
* src/manage.h: Update headers.
* src/omp.c (init_omp, init_omp_process): Add database arg. Update
callers.
* src/omp.h: Update headers.
* src/ompd.c (init_ompd, serve_omp): Add database arg. Update callers.
* src/ompd.h: Update headers.
* src/openvasmd.c (database): New variable.
(main): Add --database.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/ChangeLog 2009-10-12 13:46:02 UTC (rev 5499)
@@ -1,5 +1,23 @@
2009-10-09 Matthew Mundell <matthew.mundell at intevation.de>
+ Add a --database option.
+
+ * src/tasks_sql.h (manage_migrate, init_manage_process, init_manage): Add
+ database arg. Use to init database. Update callers.
+ * src/manage.h: Update headers.
+
+ * src/omp.c (init_omp, init_omp_process): Add database arg. Update
+ callers.
+ * src/omp.h: Update headers.
+
+ * src/ompd.c (init_ompd, serve_omp): Add database arg. Update callers.
+ * src/ompd.h: Update headers.
+
+ * src/openvasmd.c (database): New variable.
+ (main): Add --database.
+
+2009-10-09 Matthew Mundell <matthew.mundell at intevation.de>
+
Add FILE to OMP MODIFY_TASK, for clients to send files referenced by
preferences. Associate files with tasks instead of with configs.
Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/src/manage.h 2009-10-12 13:46:02 UTC (rev 5499)
@@ -52,10 +52,10 @@
extern scanner_t scanner;
int
-init_manage (GSList*, int);
+init_manage (GSList*, int, const gchar*);
void
-init_manage_process ();
+init_manage_process (int, const gchar*);
void
cleanup_manage_process ();
@@ -96,7 +96,7 @@
manage_db_version ();
int
-manage_migrate (GSList *log_config);
+manage_migrate (GSList*, const gchar*);
/* Task structures. */
Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/src/omp.c 2009-10-12 13:46:02 UTC (rev 5499)
@@ -5246,34 +5246,36 @@
/**
* @brief Initialise OMP library.
*
- * @param[in] log_config Logging configuration list.
+ * @param[in] log_config Logging configuration list.
* @param[in] nvt_cache_mode True when running in NVT caching mode.
+ * @param[in] database Location of manage database.
*
* @return 0 success, -1 error, -2 database is wrong version, -3 database
* needs to be initialized from server.
*/
int
-init_omp (GSList *log_config, int nvt_cache_mode)
+init_omp (GSList *log_config, int nvt_cache_mode, const gchar *database)
{
g_log_set_handler (G_LOG_DOMAIN,
ALL_LOG_LEVELS,
(GLogFunc) openvas_log_func,
log_config);
- return init_manage (log_config, nvt_cache_mode);
+ return init_manage (log_config, nvt_cache_mode, database);
}
/**
* @brief Initialise OMP library data for a process.
*
* @param[in] update_nvt_cache If true, process will just update NVT cache.
+ * @param[in] database Location of manage database.
*
* This should run once per process, before the first call to \ref
* process_omp_client_input.
*/
void
-init_omp_process (int update_nvt_cache)
+init_omp_process (int update_nvt_cache, const gchar *database)
{
- init_manage_process (update_nvt_cache);
+ init_manage_process (update_nvt_cache, database);
/* Create the XML parser. */
xml_parser.start_element = omp_xml_handle_start_element;
xml_parser.end_element = omp_xml_handle_end_element;
Modified: trunk/openvas-manager/src/omp.h
===================================================================
--- trunk/openvas-manager/src/omp.h 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/src/omp.h 2009-10-12 13:46:02 UTC (rev 5499)
@@ -36,10 +36,10 @@
#define TO_CLIENT_BUFFER_SIZE 26214400
int
-init_omp (GSList*, int);
+init_omp (GSList*, int, const gchar*);
void
-init_omp_process ();
+init_omp_process (int, const gchar*);
int
process_omp_client_input ();
Modified: trunk/openvas-manager/src/ompd.c
===================================================================
--- trunk/openvas-manager/src/ompd.c 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/src/ompd.c 2009-10-12 13:46:02 UTC (rev 5499)
@@ -95,14 +95,15 @@
*
* @param[in] log_config Log configuration
* @param[in] nvt_cache_mode True when running in NVT caching mode.
+ * @param[in] database Location of manage database.
*
* @return 0 success, -1 error, -2 database is wrong version, -3 database
* needs to be initialized from server.
*/
int
-init_ompd (GSList *log_config, int nvt_cache_mode)
+init_ompd (GSList *log_config, int nvt_cache_mode, const gchar *database)
{
- return init_omp (log_config, nvt_cache_mode);
+ return init_omp (log_config, nvt_cache_mode, database);
}
/**
@@ -495,6 +496,7 @@
* @param[in] scanner_credentials The TSL server credentials.
* @param[in] client_socket The socket connected to the client, if any.
* @param[in] scanner_socket_addr The socket connected to the scanner.
+ * @param[in] database Location of manage database.
*
* @return 0 on success, -1 on error.
*/
@@ -503,7 +505,8 @@
gnutls_session_t* scanner_session,
gnutls_certificate_credentials_t* client_credentials,
gnutls_certificate_credentials_t* scanner_credentials,
- int client_socket, int* scanner_socket_addr)
+ int client_socket, int* scanner_socket_addr,
+ const gchar* database)
{
int nfds, ret;
time_t last_client_activity_time;
@@ -530,7 +533,7 @@
init_otp_data ();
/* Initialise the XML parser and the manage library. */
- init_omp_process (ompd_nvt_cache_mode);
+ init_omp_process (ompd_nvt_cache_mode, database);
#if 0
// FIX consider free_omp_data (); on return
if (tasks) free_tasks ();
Modified: trunk/openvas-manager/src/ompd.h
===================================================================
--- trunk/openvas-manager/src/ompd.h 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/src/ompd.h 2009-10-12 13:46:02 UTC (rev 5499)
@@ -31,13 +31,13 @@
#include <gnutls/gnutls.h>
int
-init_ompd (GSList*, int);
+init_ompd (GSList*, int, const gchar*);
int
serve_omp (gnutls_session_t*, gnutls_session_t*,
gnutls_certificate_credentials_t*,
gnutls_certificate_credentials_t*,
- int, int*);
+ int, int*, const gchar*);
// FIX Temporarily, for omp.c SEND_TO_CLIENT.
extern char to_client[];
Modified: trunk/openvas-manager/src/openvasmd.c
===================================================================
--- trunk/openvas-manager/src/openvasmd.c 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/src/openvasmd.c 2009-10-12 13:46:02 UTC (rev 5499)
@@ -205,6 +205,11 @@
*/
gnutls_certificate_credentials_t client_credentials;
+/**
+ * @brief Location of the manage database.
+ */
+static gchar *database = NULL;
+
/* Forking, serving the client. */
@@ -300,7 +305,8 @@
/* It's up to serve_omp to openvas_server_free client_*. */
if (serve_omp (&client_session, &scanner_session,
&client_credentials, &scanner_credentials,
- client_socket, &scanner_socket))
+ client_socket, &scanner_socket,
+ database))
goto server_fail;
break;
case PROTOCOL_CLOSE:
@@ -517,6 +523,7 @@
GOptionContext *option_context;
static GOptionEntry option_entries[]
= {
+ { "database", 'd', 0, G_OPTION_ARG_STRING, &database, "Use <file> as database.", "<file>" },
{ "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Run in foreground.", NULL },
{ "listen", 'a', 0, G_OPTION_ARG_STRING, &manager_address_string, "Listen on <address>.", "<address>" },
{ "migrate", 'm', 0, G_OPTION_ARG_NONE, &migrate_database, "Migrate the database and exit.", NULL },
@@ -565,7 +572,7 @@
tracef (" Migrating database.\n");
/* Migrate the database to the version supported by this manager. */
- switch (manage_migrate (log_config))
+ switch (manage_migrate (log_config, database))
{
case 0:
tracef (" Migration succeeded.\n");
@@ -627,7 +634,7 @@
/* Initialise OMP daemon. */
- switch (init_ompd (log_config, 1))
+ switch (init_ompd (log_config, 1, database))
{
case 0:
break;
@@ -720,7 +727,8 @@
if (serve_omp (NULL, &scanner_session,
NULL, &scanner_credentials,
- -1, &scanner_socket))
+ -1, &scanner_socket,
+ database))
{
openvas_server_free (scanner_socket,
scanner_session,
@@ -794,7 +802,7 @@
/* Initialise OMP daemon. */
- switch (init_ompd (log_config, 0))
+ switch (init_ompd (log_config, 0, database))
{
case 0:
break;
Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h 2009-10-12 12:54:54 UTC (rev 5498)
+++ trunk/openvas-manager/src/tasks_sql.h 2009-10-12 13:46:02 UTC (rev 5499)
@@ -476,10 +476,13 @@
/**
* @brief Migrate database to version supported by this manager.
*
+ * @param[in] log_config Log configuration.
+ * @param[in] database Location of manage database.
+ *
* @return 0 success, 1 already on supported version, 2 too hard, -1 error.
*/
int
-manage_migrate (GSList *log_config)
+manage_migrate (GSList *log_config, const gchar *database)
{
gchar *backup_file;
migrator_t *migrators;
@@ -493,7 +496,7 @@
(GLogFunc) openvas_log_func,
log_config);
- init_manage_process (0);
+ init_manage_process (0, database);
old_version = manage_db_version ();
new_version = manage_db_supported_version ();
@@ -702,9 +705,10 @@
* Open the SQL database.
*
* @param[in] update_nvt_cache If true, clear the NVT cache.
+ * @param[in] database Location of manage database.
*/
void
-init_manage_process (int update_nvt_cache)
+init_manage_process (int update_nvt_cache, const gchar *database)
{
gchar *mgr_dir;
int ret;
@@ -735,7 +739,9 @@
}
/* Open the database. */
- if (sqlite3_open (OPENVAS_STATE_DIR "/mgr/tasks.db", &task_db))
+ if (sqlite3_open (database ? database
+ : OPENVAS_STATE_DIR "/mgr/tasks.db",
+ &task_db))
{
g_warning ("%s: sqlite3_open failed: %s\n",
__FUNCTION__,
@@ -891,12 +897,13 @@
*
* @param[in] log_config Log configuration.
* @param[in] nvt_cache_mode True when running in NVT caching mode.
+ * @param[in] database Location of database.
*
* @return 0 success, -1 error, -2 database is wrong version, -3 database needs
* to be initialised from server.
*/
int
-init_manage (GSList *log_config, int nvt_cache_mode)
+init_manage (GSList *log_config, int nvt_cache_mode, const gchar *database)
{
const char *database_version;
task_t index;
@@ -907,7 +914,7 @@
(GLogFunc) openvas_log_func,
log_config);
- init_manage_process (0);
+ init_manage_process (0, database);
/* Check that the version of the database is correct. */
More information about the Openvas-commits
mailing list