#include <openvas/base/kb.h>
#include <openvas/misc/arglists.h>
Go to the source code of this file.
◆ mandatory_requirements_met()
Check whether mandatory requirements for plugin are met.
- Parameters
-
| kb | The arglist knowledge base with all keys. |
| plugin | The arglist plugin. |
- Returns
- 1 if all mandatory requirements for the plugin are met. 0 if it is not the case.
Definition at line 299 of file plugs_req.c.
References scheduler_plugin::oid.
302 char *mandatory_keys;
305 mandatory_keys = nvticache_get_mandatory_keys (plugin->
oid);
306 ret = check_mandatory_keys (kb, mandatory_keys);
308 g_free (mandatory_keys);
◆ requirements_common_ports()
Returns <port> if the lists of the required ports between.
plugin 1 and plugin 2 have at least one port in common.
Definition at line 95 of file plugs_req.c.
References scheduler_plugin::oid.
98 struct arglist *ret = NULL;
100 char *ports1, *ports2, **array1, **array2;
102 if (!plugin1 || !plugin2)
105 ports1 = nvticache_get_required_ports (plugin1->
oid);
106 ports2 = nvticache_get_required_ports (plugin2->
oid);
107 if (!ports1 || !ports2)
113 array1 = g_strsplit (ports1,
", ", 0);
114 array2 = g_strsplit (ports2,
", ", 0);
117 if (!array1 || !array2)
124 for (i = 0; array1[i] != NULL; i ++)
126 for (j = 0; array2[j] != NULL; j ++)
128 if (!strcmp (array2[j], array1[i]))
131 ret = g_malloc0 (
sizeof (
struct arglist));
132 arg_add_value (ret, array2[j], ARG_INT, (
void *) 1);
◆ requirements_plugin()
Determine if the plugin requirements are met.
- Returns
- Returns NULL is everything is ok, else an error message.
Definition at line 320 of file plugs_req.c.
References scheduler_plugin::oid.
322 static char error[64];
323 char *errkey = NULL, *keys, *tcp, *udp;
324 const char *opti = prefs_get (
"optimization_level");
329 error[
sizeof (error) - 1] =
'\0';
330 tcp = nvticache_get_required_ports (plugin->
oid);
331 if (tcp && *tcp && (get_closed_ports (kb, tcp,
"tcp")) == 0)
333 strncpy (error,
"none of the required tcp ports are open",
340 udp = nvticache_get_required_udp_ports (plugin->
oid);
341 if (udp && *udp && (get_closed_ports (kb, udp,
"udp")) == 0)
343 strncpy (error,
"none of the required udp ports are open",
350 if (opti != NULL && (strcmp (opti,
"open_ports") == 0 || atoi (opti) == 1))
356 keys = nvticache_get_required_keys (plugin->
oid);
357 if (kb_missing_keyname_of_namelist (kb, keys, &errkey))
359 snprintf (error,
sizeof (error),
"because the key %s is missing", errkey);
366 if (opti != NULL && (strcmp (opti,
"required_keys") == 0 || atoi (opti) == 2))
372 keys = nvticache_get_excluded_keys (plugin->
oid);
373 if (kb_present_keyname_of_namelist (kb, keys, &errkey))
375 snprintf (error,
sizeof (error),
"because the key %s is present", errkey);