The yara_destroy API allows to claim resources back via the removal of the previously loaded Yara rules.
Signed-off-by: Matteo Cafasso <[email protected]> --- daemon/yara.c | 14 ++++++++++++++ generator/actions.ml | 9 +++++++++ src/MAX_PROC_NR | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/daemon/yara.c b/daemon/yara.c index 0d085a8..a6b9fe2 100644 --- a/daemon/yara.c +++ b/daemon/yara.c @@ -98,6 +98,20 @@ do_yara_load (void) return 0; } +int +do_yara_destroy (void) +{ + if (rules == NULL) { + reply_with_error ("no yara rules loaded"); + return -1; + } + + yr_rules_destroy (rules); + rules = NULL; + + return 0; +} + /* Upload rules file on a temporary file. * Return 0 on success, -1 on error. */ diff --git a/generator/actions.ml b/generator/actions.ml index 14659bd..966e012 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -13268,6 +13268,15 @@ Rules in source code format cannot include external files. In such cases, it is recommended to compile them first. Previously loaded rules will be destroyed." }; + + { defaults with + name = "yara_destroy"; added = (1, 35, 15); + style = RErr, [], []; + proc_nr = Some 472; + optional = Some "libyara"; + shortdesc = "destroy previously loaded yara rules"; + longdesc = "\ +Destroy previously loaded Yara rules in order to free libguestfs resources." }; ] (* Non-API meta-commands available only in guestfish. diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index c305aa5..68cfb10 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -471 +472 -- 2.10.1 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
