2511 struct arglist *desc = lexic->script_infos;
2516 struct kb_item *kbitem, *kbitem_tmp;
2534 if (key && key[0] !=
'\0')
2539 if (cert && cert[0] !=
'\0')
2544 if (cafile && cafile[0] !=
'\0')
2549 if (test_ssl_s != NULL)
2551 if (strcmp (test_ssl_s,
"None") == 0)
2563 if (pempass != NULL)
2569 signal (SIGTERM, sigterm);
2570 signal (SIGCHLD, sigchld);
2571 if (num_sons_s != NULL)
2572 num_sons = atoi (num_sons_s);
2583 for (i = 0; i < num_sons; i++)
2586 sons_args[i] = NULL;
2592 kbitem = kb_item_get_pattern (
kb,
"Ports/tcp/*");
2595 kbitem_tmp = kbitem;
2596 while (kbitem_tmp != NULL)
2599 kbitem_tmp = kbitem_tmp->
next;
2602 port_per_son = num_ports / num_sons;
2607 kbitem_tmp = kbitem;
2609 for (i = 0; i < num_sons; i = i + 1)
2613 if (kbitem_tmp != NULL)
2615 for (j = 0; j < port_per_son && kbitem_tmp != NULL;)
2617 if (sons_args[i] == NULL)
2618 sons_args[i] = g_malloc0 (
sizeof (
struct arglist));
2622 kbitem_tmp = kbitem_tmp->
next;
2630 for (i = 0; (i < num_ports % num_sons) && kbitem_tmp != NULL;)
2632 if (sons_args[i] == NULL)
2633 sons_args[i] = g_malloc0 (
sizeof (
struct arglist));
2636 kbitem_tmp = kbitem_tmp->
next;
2642 for (i = 0; i < num_sons; i++)
2643 if (sons_args[i] == NULL)
2650 for (i = 0; i < num_sons; i++)
2653 if (sons_args[i] != NULL)
2655 if (socketpair (AF_UNIX, SOCK_STREAM, 0, sons_pipe[i]) < 0)
2657 perror (
"socketpair ");
2668 close (sons_pipe[i][1]);
2670 soc = sons_pipe[i][0];
2671 arg_set_value (globals,
"global_socket", GSIZE_TO_POINTER (soc));
2672 signal (SIGTERM, _exit);
2673 plugin_do_run (desc, sons_args[i], test_ssl);
2678 close (sons_pipe[i][0]);
2698 for (i = 0; i < num_sons; i++)
2700 if (sons[i] != 0 && (sons_pipe[i][1] >= 0))
2702 FD_SET (sons_pipe[i][1], &rd);
2703 if (sons_pipe[i][1] >
max)
2704 max = sons_pipe[i][1];
2709 tv.tv_usec = 100000;
2711 e = select (
max + 1, &rd, NULL, NULL, &tv);
2712 if (e < 0 && errno == EINTR)
2717 for (i = 0; i < num_sons; i++)
2719 if (sons[i] != 0 && sons_pipe[i][1] >= 0
2720 && FD_ISSET (sons_pipe[i][1], &rd) != 0)
2722 if (fwd_data (sons_pipe[i][1], unix_sock, sons[i]) < 0)
2724 close (sons_pipe[i][1]);
2725 sons_pipe[i][1] = -1;
2726 while (waitpid (sons[i], NULL, WNOHANG)
2733 for (i = 0; i < num_sons; i++)
2737 while (waitpid (sons[i], NULL, WNOHANG) && errno == EINTR);
2739 if (kill (sons[i], 0) < 0)
2741 fwd_data (sons_pipe[i][1], unix_sock, sons[i]);
2742 close (sons_pipe[i][1]);
2743 sons_pipe[i][1] = -1;
void kb_item_free(struct kb_item *)
Release a KB item (or a list).
void nvticache_reset()
Reset connection to KB. To be called after a fork().
int arg_set_value(struct arglist *arglst, const char *name, void *value)
Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked lis...
void plug_set_ssl_CA_file(struct arglist *args, char *key)
void arg_free(struct arglist *arg)
const char * get_plugin_preference_fname(struct arglist *desc, const char *filename)
Get the file name of a plugins preference that is of type "file".
void plug_set_ssl_pem_password(struct arglist *args, char *key)
kb_t plug_get_kb(struct arglist *args)
void arg_add_value(struct arglist *arglst, const char *name, int type, void *value)
Top-level KB. This is to be inherited by KB implementations.
struct timeval timeval(unsigned long val)
int arg_get_value_int(struct arglist *args, const char *name)
void plug_set_ssl_cert(struct arglist *args, char *cert)
void plug_set_ssl_key(struct arglist *args, char *key)
void * arg_get_value(struct arglist *args, const char *name)
char * get_plugin_preference(const char *oid, const char *name)