The yara_destroy API allows to claim resources back via the removal of
the previously loaded Yara rules.
Signed-off-by: Matteo Cafasso <noxdafox(a)gmail.com>
---
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 be53322..fe1f69a 100644
--- a/daemon/yara.c
+++ b/daemon/yara.c
@@ -93,6 +93,20 @@ do_yara_load (void)
return (ret == ERROR_SUCCESS) ? 0 : -1;
}
+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 f69564a..152c651 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -13271,6 +13271,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.2