[Libguestfs] [PATCH v3 3/6] New API: yara_destroy

Matteo Cafasso noxdafox at gmail.com
Sun Dec 18 10:47:08 UTC 2016


The yara_destroy API allows to claim resources back via the removal of
the previously loaded Yara rules.

Signed-off-by: Matteo Cafasso <noxdafox at 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 0e4128a..cb49593 100644
--- a/daemon/yara.c
+++ b/daemon/yara.c
@@ -105,6 +105,20 @@ do_yara_load (const char *namespace)
   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;
+}
+
 /* Compile source code rules and load them.
  * Return ERROR_SUCCESS on success, Yara error code type on error.
  */
diff --git a/generator/actions.ml b/generator/actions.ml
index c5ffc4d..b9055c4 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -13286,6 +13286,15 @@ it is recommended to compile them first.
 Different rules files can be loaded sequentially. The optional parameter
 C<namespace> can be used to distinguish rules with the same identifier
 but belonging to different files." };
+
+  { defaults with
+    name = "yara_destroy"; added = (1, 35, 19);
+    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




More information about the Libguestfs mailing list