[Openvas-commits] r6282 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 30 18:49:48 CET 2009
Author: mattm
Date: 2009-12-30 18:49:46 +0100 (Wed, 30 Dec 2009)
New Revision: 6282
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage.c
trunk/openvas-manager/src/omp.c
trunk/openvas-manager/src/ompd.c
trunk/openvas-manager/src/tasks_sql.h
Log:
* src/tasks_sql.h (where_levels): Neaten doc formatting.
* src/ompd.c (serve_omp): Just read and log a character on select
exception, instead of failing. Recalculate nfds after recreating
the scanner session.
* src/omp.c (omp_xml_handle_end_element): Correct entity name in error
message. In the task start mechanism prevent the child from forking
instead of the parent.
(process_omp_client_input): Flag start_task children specially.
* src/manage.c (start_task): Clear current report in the child on failure
and in the parent always.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2009-12-30 12:50:17 UTC (rev 6281)
+++ trunk/openvas-manager/ChangeLog 2009-12-30 17:49:46 UTC (rev 6282)
@@ -1,3 +1,19 @@
+2009-12-30 Matthew Mundell <matthew.mundell at intevation.de>
+
+ * src/tasks_sql.h (where_levels): Neaten doc formatting.
+
+ * src/ompd.c (serve_omp): Just read and log a character on select
+ exception, instead of failing. Recalculate nfds after recreating
+ the scanner session.
+
+ * src/omp.c (omp_xml_handle_end_element): Correct entity name in error
+ message. In the task start mechanism prevent the child from forking
+ instead of the parent.
+ (process_omp_client_input): Flag start_task children specially.
+
+ * src/manage.c (start_task): Clear current report in the child on failure
+ and in the parent always.
+
2009-12-30 Felix Wolfsteller <felix.wolfsteller at intevation.de>
Applied patch from Vladimir Nadvornik to build static libraries only,
@@ -2,3 +18,3 @@
as shared libs are neither installed nor used.
-
+
* src/CMakeLists.txt: Declared libraries as static.
Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c 2009-12-30 12:50:17 UTC (rev 6281)
+++ trunk/openvas-manager/src/manage.c 2009-12-30 17:49:46 UTC (rev 6282)
@@ -879,15 +879,18 @@
__FUNCTION__,
strerror (errno));
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -9;
break;
default:
/* Parent. Return, in order to respond to client. */
+ current_report = (report_t) 0;
return 0;
break;
}
- /* Every fail exit from here must reset to this run status. */
+ /* Every fail exit from here must reset to this run status, and must
+ * clear current_report. */
// FIX On fail exits only, if another process has set a request state then
// honour that request. (stop_task, request_delete_task)
@@ -907,6 +910,7 @@
free (target);
free (hosts);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -919,6 +923,7 @@
free (hosts);
tracef (" task config is NULL.\n");
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -936,6 +941,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -947,6 +953,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
if (send_to_server ("ntp_client_accepts_notes <|> yes\n"))
@@ -955,6 +962,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
// FIX still getting FINISHED msgs
@@ -964,6 +972,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
if (send_to_server ("ntp_short_status <|> no\n"))
@@ -972,6 +981,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -983,6 +993,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
if (send_config_preferences (config, "PLUGINS_PREFS"))
@@ -991,6 +1002,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -1027,6 +1039,7 @@
free (config);
cleanup_iterator (&credentials);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
}
@@ -1042,6 +1055,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -1067,6 +1081,7 @@
/* Free the list. */
g_slist_free (last);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
files = g_slist_next (files);
@@ -1081,6 +1096,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -1089,6 +1105,7 @@
free (hosts);
free (config);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -1097,6 +1114,7 @@
{
free (hosts);
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
@@ -1109,6 +1127,7 @@
if (fail)
{
set_task_run_status (task, run_status);
+ current_report = (report_t) 0;
return -10;
}
scanner_active = 1;
Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c 2009-12-30 12:50:17 UTC (rev 6281)
+++ trunk/openvas-manager/src/omp.c 2009-12-30 17:49:46 UTC (rev 6282)
@@ -402,7 +402,7 @@
/* Global variables. */
/**
- * @brief Hack for returning error value from the callbacks.
+ * @brief Hack for returning forked process status from the callbacks.
*/
int current_error;
@@ -5991,7 +5991,7 @@
{
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_lsc_credential",
- "CREATE_LSC_CREDENTIAL user must both be at"
+ "CREATE_LSC_CREDENTIAL login must be at"
" least one character long"));
}
else switch (create_lsc_credential (modify_task_name,
@@ -6393,9 +6393,9 @@
return;
}
}
- else if (forked)
- /* Prevent the process from forking again, as then both children
- * would be using the same server session. */
+ else if (forked == 2)
+ /* Prevent the forked child from forking again, as then both
+ * forked children would be using the same server session. */
abort (); // FIX respond with error or something
else
{
@@ -8118,6 +8118,8 @@
{
if (current_error)
{
+ /* This is the return status for a forked child. */
+ forked = 2; /* Prevent further forking. */
g_error_free (error);
return current_error;
}
Modified: trunk/openvas-manager/src/ompd.c
===================================================================
--- trunk/openvas-manager/src/ompd.c 2009-12-30 12:50:17 UTC (rev 6281)
+++ trunk/openvas-manager/src/ompd.c 2009-12-30 17:49:46 UTC (rev 6282)
@@ -698,6 +698,8 @@
/* Setup for select. */
+ /** @todo nfds must only include a socket if it's in >= one set. */
+
fds = 0;
FD_ZERO (&exceptfds);
FD_ZERO (&readfds);
@@ -791,22 +793,40 @@
if (client_active && FD_ISSET (client_socket, &exceptfds))
{
- g_warning ("%s: exception on client in child select\n",
- __FUNCTION__);
- openvas_server_free (client_socket,
- *client_session,
- *client_credentials);
- return -1;
+ char ch;
+ if (recv (client_socket, &ch, 1, MSG_OOB) < 1)
+ {
+ g_warning ("%s: after exception on client in child select:"
+ " recv failed\n",
+ __FUNCTION__);
+ openvas_server_free (client_socket,
+ *client_session,
+ *client_credentials);
+ return -1;
+ }
+ g_warning ("%s: after exception on client in child select:"
+ " recv: %c\n",
+ __FUNCTION__,
+ ch);
}
if (FD_ISSET (scanner_socket, &exceptfds))
{
- g_warning ("%s: exception on scanner in child select\n",
- __FUNCTION__);
- openvas_server_free (client_socket,
- *client_session,
- *client_credentials);
- return -1;
+ char ch;
+ if (recv (scanner_socket, &ch, 1, MSG_OOB) < 1)
+ {
+ g_warning ("%s: after exception on scanner in child select:"
+ " recv failed\n",
+ __FUNCTION__);
+ openvas_server_free (client_socket,
+ *client_session,
+ *client_credentials);
+ return -1;
+ }
+ g_warning ("%s: after exception on scanner in child select:"
+ " recv: %c\n",
+ __FUNCTION__,
+ ch);
}
if ((fds & FD_CLIENT_READ) == FD_CLIENT_READ
@@ -895,6 +915,8 @@
*client_credentials);
return -1;
}
+ nfds = 1 + (client_socket > scanner_socket
+ ? client_socket : scanner_socket);
*scanner_socket_addr = scanner_socket;
/* Skip the rest of the loop because the scanner socket is
* a new socket. This is asking for select trouble, really. */
@@ -1030,6 +1052,8 @@
*client_credentials);
return -1;
}
+ nfds = 1 + (client_socket > scanner_socket
+ ? client_socket : scanner_socket);
*scanner_socket_addr = scanner_socket;
}
else if (ret == 2)
@@ -1148,6 +1172,8 @@
*client_credentials);
return -1;
}
+ nfds = 1 + (client_socket > scanner_socket
+ ? client_socket : scanner_socket);
*scanner_socket_addr = scanner_socket;
/* Skip the rest of the loop because the scanner socket is
* a new socket. This is asking for select trouble, really. */
@@ -1235,6 +1261,8 @@
*client_credentials);
return -1;
}
+ nfds = 1 + (client_socket > scanner_socket
+ ? client_socket : scanner_socket);
*scanner_socket_addr = scanner_socket;
}
else if (ret == 2)
Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h 2009-12-30 12:50:17 UTC (rev 6281)
+++ trunk/openvas-manager/src/tasks_sql.h 2009-12-30 17:49:46 UTC (rev 6282)
@@ -4392,10 +4392,10 @@
/**
* @brief Return SQL WHERE for restricting a SELECT to levels.
*
- * @param[in] levels String describing threat levels (message types)
- * to include in report (for example, "hmlgd" for
- * High, Medium, Low, loG and Debug). All levels if
- * NULL.
+ * @param[in] levels String describing threat levels (message types)
+ * to include in report (for example, "hmlgd" for
+ * High, Medium, Low, loG and Debug). All levels if
+ * NULL.
*
* @return WHERE clause for levels.
*/
More information about the Openvas-commits
mailing list