Pino Toscano
2018-Feb-07 13:16 UTC
[Libguestfs] [PATCH] customize: avoid Array.mem for now
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
Richard W.M. Jones
2018-Feb-07 15:45 UTC
Re: [Libguestfs] [PATCH] customize: avoid Array.mem for now
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@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
Seemingly Similar Threads
- [PATCH] customize: allow missing SELINUXTYPE in SELinux config
- [common PATCH 0/3] SELinux_relabel: relabel only if enforcing (RHBZ#1828952)
- [PATCH libguestfs-common 1/2] mlcustomize: Refactor SELinux_relabel code.
- Re: [common PATCH 3/3] mlcustomize: do not relabel if not enforcing (RHBZ#1828952)
- [common PATCH 3/3] mlcustomize: do not relabel if not enforcing (RHBZ#1828952)