[Libguestfs] [PATCH] customize: avoid Array.mem for now
Richard W.M. Jones
rjones at redhat.com
Wed Feb 7 15:45:44 UTC 2018
On Wed, Feb 07, 2018 at 02:16:50PM +0100, Pino Toscano wrote:
> Since it is available only in OCaml >= 4.03, which is higher than our
> requirement, add a simple reimplementation of it.
>
> Fixes commit 719d68fa247cc3885ecf7ec1c010faf83267d786.
> ---
> customize/SELinux_relabel.ml | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/customize/SELinux_relabel.ml b/customize/SELinux_relabel.ml
> index e7d440c29..7cc166edb 100644
> --- a/customize/SELinux_relabel.ml
> +++ b/customize/SELinux_relabel.ml
> @@ -24,6 +24,10 @@ open Printf
>
> module G = Guestfs
>
> +(* Simple reimplementation of Array.mem, available only with OCaml >= 40.3. *)
This should be OCaml >= 4.03.
ACK with that one fixed.
Rich.
> +let array_find a l =
> + List.mem a (Array.to_list l)
> +
> let relabel (g : G.guestfs) =
> (* Is the guest using SELinux? *)
> if g#is_file ~followsymlinks:true "/usr/sbin/load_policy" &&
> @@ -44,7 +48,7 @@ let relabel (g : G.guestfs) =
> let config_path = "/files/etc/selinux/config" in
> let selinuxtype_path = config_path ^ "/SELINUXTYPE" in
> let keys = g#aug_ls config_path in
> - if Array.mem selinuxtype_path keys then
> + if array_find selinuxtype_path keys then
> g#aug_get selinuxtype_path
> else
> "targeted" in
> --
> 2.14.3
>
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages. http://libguestfs.org
More information about the Libguestfs
mailing list