Skip to content

Commit

Permalink
Use terminate_process() when stopping scans.
Browse files Browse the repository at this point in the history
  • Loading branch information
kroosec committed May 15, 2019
1 parent 93b95d7 commit 9ee5e84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ launch_plugin (struct scan_globals *globals, struct scheduler_plugin *plugin,
if (kb_item_get_int (kb, "Host/dead") > 0)
{
g_message ("The remote host %s is dead", ip_str);
pluginlaunch_stop (1);
pluginlaunch_stop ();
plugin->running_state = PLUGIN_STATUS_DONE;
ret = ERR_HOST_DEAD;
goto finish_launch_plugin;
Expand Down Expand Up @@ -523,7 +523,7 @@ attack_host (struct scan_globals *globals, struct in6_addr *ip, GSList *vhosts,
parent = getppid ();
if (parent <= 1 || process_alive (parent) == 0)
{
pluginlaunch_stop (1);
pluginlaunch_stop ();
return;
}

Expand Down Expand Up @@ -583,7 +583,7 @@ attack_host (struct scan_globals *globals, struct in6_addr *ip, GSList *vhosts,
last_status = (cur_plug * 100) / num_plugs + 2;
if (comm_send_status (kb, ip_str, cur_plug, num_plugs) < 0)
{
pluginlaunch_stop (1);
pluginlaunch_stop ();
goto host_died;
}
}
Expand All @@ -599,7 +599,7 @@ attack_host (struct scan_globals *globals, struct in6_addr *ip, GSList *vhosts,
comm_send_status (kb, ip_str, num_plugs, num_plugs);

host_died:
pluginlaunch_stop (1);
pluginlaunch_stop ();
plugins_scheduler_free (sched);
}

Expand Down Expand Up @@ -959,7 +959,7 @@ check_kb_access (int soc)
static void
handle_scan_stop_signal ()
{
pluginlaunch_stop (0);
pluginlaunch_stop ();
global_scan_stop = 1;
}

Expand Down
14 changes: 2 additions & 12 deletions src/pluginlaunch.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,25 +297,15 @@ pluginlaunch_enable_parallel_checks (void)
}

void
pluginlaunch_stop (int soft_stop)
pluginlaunch_stop ()
{
int i;

if (soft_stop)
{
for (i = 0; i < MAX_PROCESSES; i++)
{
if (processes[i].pid > 0)
kill (processes[i].pid, SIGTERM);
}
usleep (20000);
}

for (i = 0; i < MAX_PROCESSES; i++)
{
if (processes[i].pid > 0)
{
kill (processes[i].pid, SIGKILL);
terminate_process (processes[i].pid * -1);
num_running_processes--;
processes[i].plugin->running_state = PLUGIN_STATUS_DONE;
bzero (&(processes[i]), sizeof (struct running));
Expand Down
4 changes: 3 additions & 1 deletion src/pluginlaunch.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ void
pluginlaunch_init (const char *);
void pluginlaunch_wait (kb_t);
void pluginlaunch_wait_for_free_process (kb_t);

void
pluginlaunch_stop (int);
pluginlaunch_stop ();

int
plugin_launch (struct scan_globals *, struct scheduler_plugin *,
struct in6_addr *, GSList *, kb_t, nvti_t *);
Expand Down

0 comments on commit 9ee5e84

Please sign in to comment.