[Libguestfs] [PATCH v6 4/7] New API: yara_destroy
Richard W.M. Jones
rjones at redhat.com
Tue Apr 18 08:10:54 UTC 2017
On Thu, Apr 06, 2017 at 11:41:04PM +0300, Matteo Cafasso wrote:
> 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>
This one looks fine, ACK.
Rich.
> daemon/yara.c | 14 ++++++++++++++
> generator/actions_yara.ml | 8 ++++++++
> generator/proc_nr.ml | 1 +
> lib/MAX_PROC_NR | 2 +-
> 4 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/daemon/yara.c b/daemon/yara.c
> index 0d33d83cd..186a330c1 100644
> --- a/daemon/yara.c
> +++ b/daemon/yara.c
> @@ -107,6 +107,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;
> +}
> +
> /* Compile source code rules and load them.
> * Return ERROR_SUCCESS on success, Yara error code type on error.
> */
> diff --git a/generator/actions_yara.ml b/generator/actions_yara.ml
> index 3e55206ec..9d93d9f11 100644
> --- a/generator/actions_yara.ml
> +++ b/generator/actions_yara.ml
> @@ -45,4 +45,12 @@ it is recommended to compile them first.
>
> Previously loaded rules will be destroyed." };
>
> + { defaults with
> + name = "yara_destroy"; added = (1, 37, 9);
> + style = RErr, [], [];
> + optional = Some "libyara";
> + shortdesc = "destroy previously loaded yara rules";
> + longdesc = "\
> +Destroy previously loaded Yara rules in order to free libguestfs resources." };
> +
> ]
> diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
> index d50cc9efa..d471b1a83 100644
> --- a/generator/proc_nr.ml
> +++ b/generator/proc_nr.ml
> @@ -480,6 +480,7 @@ let proc_nr = [
> 470, "internal_find_inode";
> 471, "mksquashfs";
> 472, "yara_load";
> +473, "yara_destroy";
> ]
>
> (* End of list. If adding a new entry, add it at the end of the list
> diff --git a/lib/MAX_PROC_NR b/lib/MAX_PROC_NR
> index 68cfb10d1..8410b8b89 100644
> --- a/lib/MAX_PROC_NR
> +++ b/lib/MAX_PROC_NR
> @@ -1 +1 @@
> -472
> +473
> --
> 2.11.0
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
More information about the Libguestfs
mailing list