[Libguestfs] [PATCH] customize: avoid Array.mem for now

Pino Toscano ptoscano at redhat.com
Wed Feb 7 13:16:50 UTC 2018


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. *)
+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




More information about the Libguestfs mailing list