OpenVAS Scanner  7.0.0~git
pluginlaunch.h File Reference

pluginlaunch.c header. More...

#include "pluginload.h"
#include "pluginscheduler.h"
Include dependency graph for pluginlaunch.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void pluginlaunch_init (const char *)
 
void pluginlaunch_wait (kb_t)
 Waits and 'pushes' processes until num_running_processes is 0. More...
 
void pluginlaunch_wait_for_free_process (kb_t)
 Waits and 'pushes' processes until the number of running processes has changed. More...
 
void pluginlaunch_stop ()
 
int plugin_launch (struct scan_globals *, struct scheduler_plugin *, struct in6_addr *, GSList *, kb_t, nvti_t *)
 
void pluginlaunch_disable_parallel_checks (void)
 
void pluginlaunch_enable_parallel_checks (void)
 
int wait_for_children (void)
 

Detailed Description

pluginlaunch.c header.

Definition in file pluginlaunch.h.

Function Documentation

◆ plugin_launch()

int plugin_launch ( struct scan_globals globals,
struct scheduler_plugin plugin,
struct in6_addr *  ip,
GSList *  vhosts,
kb_t  kb,
nvti_t *  nvti 
)
Returns
PID of process that is connected to the plugin as returned by plugin classes pl_launch function (<=0 means there was a problem).

Definition at line 343 of file pluginlaunch.c.

345 {
346  int p;
347 
348  /* Wait for a free slot */
350  p = next_free_process (kb, plugin);
351  if (p < 0)
352  return -1;
353  processes[p].plugin = plugin;
354  processes[p].timeout = plugin_timeout (nvti);
355  gettimeofday (&(processes[p].start), NULL);
356  processes[p].pid = nasl_plugin_launch (globals, ip, vhosts, kb, plugin->oid);
357 
358  if (processes[p].pid > 0)
360  else
362 
363  return processes[p].pid;
364 }

References nasl_plugin_launch(), next_free_process(), num_running_processes, scheduler_plugin::oid, running::pid, pid, running::plugin, PLUGIN_STATUS_UNRUN, plugin_timeout(), pluginlaunch_wait_for_free_process(), processes, scheduler_plugin::running_state, and running::timeout.

Referenced by launch_plugin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pluginlaunch_disable_parallel_checks()

void pluginlaunch_disable_parallel_checks ( void  )

Definition at line 290 of file pluginlaunch.c.

291 {
293 }

References max_running_processes.

Referenced by get_next_in_range().

Here is the caller graph for this function:

◆ pluginlaunch_enable_parallel_checks()

void pluginlaunch_enable_parallel_checks ( void  )

Definition at line 296 of file pluginlaunch.c.

References max_running_processes, and old_max_running_processes.

Referenced by get_next_in_range().

Here is the caller graph for this function:

◆ pluginlaunch_init()

void pluginlaunch_init ( const char *  )

Definition at line 265 of file pluginlaunch.c.

266 {
267  int i;
268 
269  char **split = g_strsplit (prefs_get ("non_simult_ports"), ", ", 0);
270  for (i = 0; split[i]; i++)
271  non_simult_ports = g_slist_prepend (non_simult_ports, g_strdup (split[i]));
272  g_strfreev (split);
275  hostname = host;
276 
278  {
279  g_debug ("max_checks (%d) > MAX_PROCESSES (%d) - modify "
280  "openvas/openvas/pluginlaunch.c",
283  }
284 
286  bzero (&(processes), sizeof (processes));
287 }

References get_max_checks_number(), hostname, MAX_PROCESSES, max_running_processes, non_simult_ports, num_running_processes, old_max_running_processes, and processes.

Referenced by attack_host().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pluginlaunch_stop()

void pluginlaunch_stop ( )

Definition at line 302 of file pluginlaunch.c.

303 {
304  int i;
305 
306  for (i = 0; i < MAX_PROCESSES; i++)
307  {
308  if (processes[i].pid > 0)
309  {
310  terminate_process (processes[i].pid * -1);
313  bzero (&(processes[i]), sizeof (struct running));
314  }
315  }
316 }

References MAX_PROCESSES, num_running_processes, pid, running::plugin, PLUGIN_STATUS_DONE, processes, scheduler_plugin::running_state, and terminate_process().

Referenced by attack_host(), handle_scan_stop_signal(), and launch_plugin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pluginlaunch_wait()

void pluginlaunch_wait ( kb_t  )

Waits and 'pushes' processes until num_running_processes is 0.

Definition at line 370 of file pluginlaunch.c.

371 {
372  while (num_running_processes)
373  {
376  waitpid (-1, NULL, 0);
377  }
378 }

References num_running_processes, and update_running_processes().

Referenced by attack_host().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pluginlaunch_wait_for_free_process()

void pluginlaunch_wait_for_free_process ( kb_t  )

Waits and 'pushes' processes until the number of running processes has changed.

Definition at line 403 of file pluginlaunch.c.

404 {
406  return;
408  /* Max number of processes are still running, wait for a child to exit or
409  * to timeout. */
411  {
412  sigset_t mask;
413  struct timespec ts = {0, 0};
414 
415  ts.tv_sec = timeout_running_processes ();
416  assert (ts.tv_sec);
417  sigemptyset (&mask);
418  sigaddset (&mask, SIGCHLD);
419  if (sigtimedwait (&mask, NULL, &ts) < 0 && errno != EAGAIN)
420  g_warning ("%s: %s", __FUNCTION__, strerror (errno));
422  }
423 }

References max_running_processes, num_running_processes, timeout_running_processes(), and update_running_processes().

Referenced by attack_host(), and plugin_launch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_for_children()

int wait_for_children ( void  )
terminate_process
int terminate_process(pid_t pid)
Send SIGTERM to the pid process. Try to wait the the process. In case of the process has still not ch...
Definition: processes.c:58
plugin_timeout
static int plugin_timeout(nvti_t *nvti)
Definition: pluginlaunch.c:319
non_simult_ports
static GSList * non_simult_ports
Definition: pluginlaunch.c:75
running::timeout
int timeout
Definition: pluginlaunch.c:67
running
Structure to represent a process in the sense of a running NVT.
Definition: pluginlaunch.c:62
pid
static pid_t pid
Definition: nasl_builtin_nmap.c:499
num_running_processes
static int num_running_processes
Definition: pluginlaunch.c:72
PLUGIN_STATUS_DONE
@ PLUGIN_STATUS_DONE
Definition: pluginscheduler.h:37
scheduler_plugin::running_state
enum plugin_status running_state
Definition: pluginscheduler.h:44
next_free_process
static int next_free_process(kb_t kb, struct scheduler_plugin *upcoming)
Definition: pluginlaunch.c:242
MAX_PROCESSES
#define MAX_PROCESSES
'Hard' limit of the max. number of concurrent plugins per host.
Definition: pluginlaunch.c:57
running::pid
pid_t pid
Definition: pluginlaunch.c:66
update_running_processes
static void update_running_processes(kb_t kb)
Definition: pluginlaunch.c:82
scheduler_plugin::oid
char * oid
Definition: pluginscheduler.h:42
PLUGIN_STATUS_UNRUN
@ PLUGIN_STATUS_UNRUN
Definition: pluginscheduler.h:35
host
Host information, implemented as doubly linked list.
Definition: hosts.c:46
get_max_checks_number
int get_max_checks_number(void)
Definition: utils.c:174
pluginlaunch_wait_for_free_process
void pluginlaunch_wait_for_free_process(kb_t kb)
Waits and 'pushes' processes until the number of running processes has changed.
Definition: pluginlaunch.c:403
hostname
const char * hostname
Definition: pluginlaunch.c:76
running::plugin
struct scheduler_plugin * plugin
Definition: pluginlaunch.c:64
timeout_running_processes
static int timeout_running_processes()
Return shortest timeout of the running processes.
Definition: pluginlaunch.c:384
nasl_plugin_launch
int nasl_plugin_launch(struct scan_globals *globals, struct in6_addr *ip, GSList *vhosts, kb_t kb, const char *oid)
Launch a NASL plugin.
Definition: nasl_plugins.c:151
max_running_processes
static int max_running_processes
Definition: pluginlaunch.c:73
processes
static struct running processes[MAX_PROCESSES]
Definition: pluginlaunch.c:71
old_max_running_processes
static int old_max_running_processes
Definition: pluginlaunch.c:74