OpenVAS Scanner  7.0.1~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.

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().

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 }
static int plugin_timeout(nvti_t *nvti)
Definition: pluginlaunch.c:319
static struct running processes[MAX_PROCESSES]
Definition: pluginlaunch.c:71
struct scheduler_plugin * plugin
Definition: pluginlaunch.c:64
static pid_t pid
static int next_free_process(kb_t kb, struct scheduler_plugin *upcoming)
Definition: pluginlaunch.c:242
void pluginlaunch_wait_for_free_process(kb_t kb)
Waits and &#39;pushes&#39; processes until the number of running processes has changed.
Definition: pluginlaunch.c:403
static int num_running_processes
Definition: pluginlaunch.c:72
pid_t pid
Definition: pluginlaunch.c:66
int timeout
Definition: pluginlaunch.c:67
enum plugin_status running_state
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
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.

References max_running_processes.

Referenced by get_next_in_range().

291 {
293 }
static int max_running_processes
Definition: pluginlaunch.c:73
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().

297 {
299 }
static int old_max_running_processes
Definition: pluginlaunch.c:74
static int max_running_processes
Definition: pluginlaunch.c:73
Here is the caller graph for this function:

◆ pluginlaunch_init()

void pluginlaunch_init ( const char *  )

Definition at line 265 of file pluginlaunch.c.

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().

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 }
static struct running processes[MAX_PROCESSES]
Definition: pluginlaunch.c:71
static int old_max_running_processes
Definition: pluginlaunch.c:74
#define MAX_PROCESSES
&#39;Hard&#39; limit of the max. number of concurrent plugins per host.
Definition: pluginlaunch.c:57
static GSList * non_simult_ports
Definition: pluginlaunch.c:75
Host information, implemented as doubly linked list.
Definition: hosts.c:47
static int num_running_processes
Definition: pluginlaunch.c:72
static int max_running_processes
Definition: pluginlaunch.c:73
const char * hostname
Definition: pluginlaunch.c:76
int get_max_checks_number(void)
Definition: utils.c:174
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.

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().

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 }
static struct running processes[MAX_PROCESSES]
Definition: pluginlaunch.c:71
struct scheduler_plugin * plugin
Definition: pluginlaunch.c:64
#define MAX_PROCESSES
&#39;Hard&#39; limit of the max. number of concurrent plugins per host.
Definition: pluginlaunch.c:57
static pid_t pid
static int num_running_processes
Definition: pluginlaunch.c:72
Structure to represent a process in the sense of a running NVT.
Definition: pluginlaunch.c:62
enum plugin_status running_state
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
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.

References num_running_processes, and update_running_processes().

Referenced by attack_host().

371 {
372  while (num_running_processes)
373  {
376  waitpid (-1, NULL, 0);
377  }
378 }
static int num_running_processes
Definition: pluginlaunch.c:72
static void update_running_processes(kb_t kb)
Definition: pluginlaunch.c:82
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.

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

Referenced by attack_host(), and plugin_launch().

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 }
static int num_running_processes
Definition: pluginlaunch.c:72
static int timeout_running_processes()
Return shortest timeout of the running processes.
Definition: pluginlaunch.c:384
static int max_running_processes
Definition: pluginlaunch.c:73
static void update_running_processes(kb_t kb)
Definition: pluginlaunch.c:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_for_children()

int wait_for_children ( void  )