import guestfs-tools-1.48.2-8.el9

This commit is contained in:
CentOS Sources 2023-05-09 05:17:58 +00:00 committed by Stepan Oksanichenko
parent 9017331702
commit 0b0a106c04
4 changed files with 380 additions and 3 deletions

View File

@ -0,0 +1,340 @@
From 1bbc3f0f3f61f00230ed5edab0cdd72729423b58 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 10 Oct 2022 13:54:52 +0100
Subject: [PATCH] customize: Support Rocky Linux
Also updates common submodule with equivalent fix for
common/mlcustomize
Reported-by: Harry Benson
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2133443
(cherry picked from commit 8858fc63e63ae3f7c76d3ca96cbf63f43e76c834)
---
common | 2 +-
customize/hostname.ml | 3 ++-
customize/password.ml | 3 ++-
customize/random_seed.ml | 3 ++-
4 files changed, 7 insertions(+), 4 deletions(-)
Submodule common fd964c1ba..85f3e4d08:
diff --git a/common/mlcustomize/firstboot.ml b/common/mlcustomize/firstboot.ml
index 5c7fd0d..0c76283 100644
--- a/common/mlcustomize/firstboot.ml
+++ b/common/mlcustomize/firstboot.ml
@@ -151,7 +151,8 @@ WantedBy=%s
and install_sysvinit_service g root distro major =
match distro with
- | "fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based" ->
+ | "fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"rocky"|
+ "redhat-based" ->
install_sysvinit_redhat g
| "opensuse"|"sles"|"suse-based" ->
install_sysvinit_suse g
diff --git a/common/mlpcre/pcre-c.c b/common/mlpcre/pcre-c.c
index f780832..6d119ae 100644
--- a/common/mlpcre/pcre-c.c
+++ b/common/mlpcre/pcre-c.c
@@ -278,7 +278,6 @@ guestfs_int_pcre_sub (value nv)
CAMLparam1 (nv);
const int n = Int_val (nv);
CAMLlocal1 (strv);
- CLEANUP_FREE char *str = NULL;
const struct last_match *m = pthread_getspecific (last_match);
PCRE2_SIZE len;
int r;
diff --git a/common/mltools/on_exit.ml b/common/mltools/on_exit.ml
index cae12e7..f8ef74e 100644
--- a/common/mltools/on_exit.ml
+++ b/common/mltools/on_exit.ml
@@ -23,39 +23,39 @@ open Common_gettext.Gettext
open Unix
open Printf
-(* List of files to unlink. *)
-let files = ref []
+type action =
+ | Unlink of string (* filename *)
+ | Rm_rf of string (* directory *)
+ | Kill of int * int (* signal, pid *)
+ | Fn of (unit -> unit) (* generic function *)
-(* List of directories to remove. *)
-let rmdirs = ref []
-
-(* List of PIDs to kill. *)
-let kills = ref []
-
-(* List of functions to call. *)
-let fns = ref []
+(* List of (priority, action). *)
+let actions = ref []
(* Perform a single exit action, printing any exception but
* otherwise ignoring failures.
*)
-let do_action f arg =
- try f arg with exn -> debug "%s" (Printexc.to_string exn)
+let do_action action =
+ try
+ match action with
+ | Unlink file -> Unix.unlink file
+ | Rm_rf dir ->
+ let cmd = sprintf "rm -rf -- %s" (Filename.quote dir) in
+ ignore (Tools_utils.shell_command cmd)
+ | Kill (signal, pid) ->
+ kill pid signal
+ | Fn f -> f ()
+ with exn -> debug "%s" (Printexc.to_string exn)
(* Make sure the actions are performed only once. *)
let done_actions = ref false
-(* Perform the exit actions. *)
+(* Perform the exit actions in priority order (lowest prio first). *)
let do_actions () =
if not !done_actions then (
- List.iter (do_action (fun f -> f ())) !fns;
- List.iter (do_action (fun (signal, pid) -> kill pid signal)) !kills;
- List.iter (do_action (fun file -> Unix.unlink file)) !files;
- List.iter (do_action (
- fun dir ->
- let cmd = sprintf "rm -rf -- %s" (Filename.quote dir) in
- ignore (Tools_utils.shell_command cmd)
- )
- ) !rmdirs;
+ let actions = List.sort (fun (a, _) (b, _) -> compare a b) !actions in
+ let actions = List.map snd actions in
+ List.iter do_action actions
);
done_actions := true
@@ -94,18 +94,18 @@ let register () =
);
registered := true
-let f fn =
+let f ?(prio = 5000) fn =
register ();
- List.push_front fn fns
+ List.push_front (prio, Fn fn) actions
-let unlink filename =
+let unlink ?(prio = 5000) filename =
register ();
- List.push_front filename files
+ List.push_front (prio, Unlink filename) actions
-let rm_rf dir =
+let rm_rf ?(prio = 5000) dir =
register ();
- List.push_front dir rmdirs
+ List.push_front (prio, Rm_rf dir) actions
-let kill ?(signal = Sys.sigterm) pid =
+let kill ?(prio = 5000) ?(signal = Sys.sigterm) pid =
register ();
- List.push_front (signal, pid) kills
+ List.push_front (prio, Kill (signal, pid)) actions
diff --git a/common/mltools/on_exit.mli b/common/mltools/on_exit.mli
index 9bcf104..66a8554 100644
--- a/common/mltools/on_exit.mli
+++ b/common/mltools/on_exit.mli
@@ -28,6 +28,12 @@
killing another process, so we provide simple
wrappers for those common actions here.
+ Actions can be ordered by setting the optional [?prio]
+ parameter in the range 0..9999. By default actions
+ have priority 5000. Lower numbered actions run first.
+ Higher numbered actions run last. So to have an action
+ run at the very end before exit you might use [~prio:9999]
+
Note this module registers signal handlers for
SIGINT, SIGQUIT, SIGTERM and SIGHUP. This means
that any program that links with mltools.cmxa
@@ -39,18 +45,20 @@
Your cleanup action might no longer run unless the
program calls {!Stdlib.exit}. *)
-val f : (unit -> unit) -> unit
+val f : ?prio:int -> (unit -> unit) -> unit
(** Register a function [f] which runs when the program exits.
Similar to [Stdlib.at_exit] but also runs if the program is
- killed with a signal that we can catch. *)
+ killed with a signal that we can catch.
-val unlink : string -> unit
+ [?prio] is the priority, default 5000. See the description above. *)
+
+val unlink : ?prio:int -> string -> unit
(** Unlink a single temporary file on exit. *)
-val rm_rf : string -> unit
+val rm_rf : ?prio:int -> string -> unit
(** Recursively remove a temporary directory on exit (using [rm -rf]). *)
-val kill : ?signal:int -> int -> unit
+val kill : ?prio:int -> ?signal:int -> int -> unit
(** Kill [PID] on exit. The signal sent defaults to [Sys.sigterm].
Use this with care since you can end up unintentionally killing
diff --git a/common/options/decrypt.c b/common/options/decrypt.c
index 97c8b88..19fe93c 100644
--- a/common/options/decrypt.c
+++ b/common/options/decrypt.c
@@ -38,6 +38,10 @@
#include "options.h"
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
+
static void
append_char (size_t *idx, char *buffer, char c)
{
@@ -55,6 +59,8 @@ append_char (size_t *idx, char *buffer, char c)
++*idx;
}
+
+
/**
* Make a LUKS map name from the partition or logical volume name, eg.
* C<"/dev/vda2" =E<gt> "cryptvda2">, or C<"/dev/vg-ssd/lv-root7" =E<gt>
@@ -196,8 +202,8 @@ decrypt_mountables (guestfs_h *g, const char * const *mountables,
void
inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
{
+ const char *lvm2_feature[] = { "lvm2", NULL };
CLEANUP_FREE_STRING_LIST char **partitions = guestfs_list_partitions (g);
- CLEANUP_FREE_STRING_LIST char **lvs = NULL;
bool need_rescan;
if (partitions == NULL)
@@ -205,13 +211,17 @@ inspect_do_decrypt (guestfs_h *g, struct key_store *ks)
need_rescan = decrypt_mountables (g, (const char * const *)partitions, ks);
- if (need_rescan) {
- if (guestfs_lvm_scan (g, 1) == -1)
+ if (guestfs_feature_available (g, (char **) lvm2_feature) > 0) {
+ CLEANUP_FREE_STRING_LIST char **lvs = NULL;
+
+ if (need_rescan) {
+ if (guestfs_lvm_scan (g, 1) == -1)
+ exit (EXIT_FAILURE);
+ }
+
+ lvs = guestfs_lvs (g);
+ if (lvs == NULL)
exit (EXIT_FAILURE);
+ decrypt_mountables (g, (const char * const *)lvs, ks);
}
-
- lvs = guestfs_lvs (g);
- if (lvs == NULL)
- exit (EXIT_FAILURE);
- decrypt_mountables (g, (const char * const *)lvs, ks);
}
diff --git a/common/utils/guestfs-utils.h b/common/utils/guestfs-utils.h
index d568ed3..fdd85ca 100644
--- a/common/utils/guestfs-utils.h
+++ b/common/utils/guestfs-utils.h
@@ -32,6 +32,7 @@
#ifndef GUESTFS_UTILS_H_
#define GUESTFS_UTILS_H_
+#include <stdio.h>
#include <stdbool.h>
#include "guestfs-internal-all.h"
diff --git a/common/utils/utils.c b/common/utils/utils.c
index 70e55cb..0144dc4 100644
--- a/common/utils/utils.c
+++ b/common/utils/utils.c
@@ -654,7 +654,8 @@ guestfs_int_hexdump (const void *data, size_t len, FILE *fp)
const char *
guestfs_int_strerror (int errnum, char *buf, size_t buflen)
{
-#ifdef _GNU_SOURCE
+#ifdef HAVE_DECL_STRERROR_R
+#ifdef STRERROR_R_CHAR_P
/* GNU strerror_r */
return strerror_r (errnum, buf, buflen);
#else
@@ -664,4 +665,7 @@ guestfs_int_strerror (int errnum, char *buf, size_t buflen)
snprintf (buf, buflen, "error number %d", errnum);
return buf;
#endif
+#else /* !HAVE_DECL_STRERROR_R */
+ return strerror (errnum); /* YOLO it. */
+#endif
}
diff --git a/common/windows/windows.c b/common/windows/windows.c
index b441097..355d79a 100644
--- a/common/windows/windows.c
+++ b/common/windows/windows.c
@@ -58,8 +58,6 @@ is_windows (guestfs_h *g, const char *root)
return w;
}
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
/**
* Resolves C<path> as possible Windows path according to C<root>,
* giving a new path that can be used in libguestfs API calls.
@@ -125,7 +123,6 @@ windows_path (guestfs_h *g, const char *root, const char *path, int readonly)
return ret;
}
-#pragma GCC diagnostic pop
static void
mount_drive_letter (guestfs_h *g, char drive_letter, const char *root,
diff --git a/customize/hostname.ml b/customize/hostname.ml
index df64a2dab..fabba3cfd 100644
--- a/customize/hostname.ml
+++ b/customize/hostname.ml
@@ -36,7 +36,8 @@ let rec set_hostname (g : Guestfs.guestfs) root hostname =
update_etc_machine_info g hostname;
true
- | "linux", ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v
+ | "linux", ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"rocky"|
+ "redhat-based"), v
when v >= 7 ->
update_etc_hostname g hostname;
update_etc_machine_info g hostname;
diff --git a/customize/password.ml b/customize/password.ml
index 608bf95dc..b37b31fcd 100644
--- a/customize/password.ml
+++ b/customize/password.ml
@@ -160,7 +160,8 @@ and default_crypto g root =
let distro = g#inspect_get_distro root in
let major = g#inspect_get_major_version root in
match distro, major with
- | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v when v >= 9 ->
+ | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"rocky"|
+ "redhat-based"), v when v >= 9 ->
`YESCRYPT
| ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v when v >= 6 ->
`SHA512
diff --git a/customize/random_seed.ml b/customize/random_seed.ml
index f32d3194e..2dcb700ea 100644
--- a/customize/random_seed.ml
+++ b/customize/random_seed.ml
@@ -47,7 +47,8 @@ let rec set_random_seed (g : Guestfs.guestfs) root =
let distro = g#inspect_get_distro root in
let file =
match typ, distro with
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|
+ "rocky"|"redhat-based") ->
Some "/var/lib/random-seed"
| "linux", ("debian"|"ubuntu"|"kalilinux") ->
Some "/var/lib/urandom/random-seed"
--
2.31.1

View File

@ -0,0 +1,29 @@
From 888ecde429ef6fab9567359abae1e2d04d552666 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 21 Nov 2022 13:03:22 +0000
Subject: [PATCH] RHEL: builder: Disable opensuse repository
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2145160
(cherry picked from commit 8e0e91c923bd7076fd906a71678ddd3f328ae2c0)
---
builder/opensuse.conf.in | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/builder/opensuse.conf.in b/builder/opensuse.conf.in
index 19f979699..a57fc6977 100644
--- a/builder/opensuse.conf.in
+++ b/builder/opensuse.conf.in
@@ -1,3 +1,7 @@
-[opensuse.org]
-uri=http://download.opensuse.org/repositories/Virtualization:/virt-builder-images/images/index
-gpgkey=file://@SYSCONFDIR@/virt-builder/repos.d/opensuse.gpg
+# https://bugzilla.redhat.com/show_bug.cgi?id=2145160
+# This is disabled in RHEL by default, but you can enable it by
+# uncommenting the lines below.
+
+#[opensuse.org]
+#uri=http://download.opensuse.org/repositories/Virtualization:/virt-builder-images/images/index
+#gpgkey=file://@SYSCONFDIR@/virt-builder/repos.d/opensuse.gpg
--
2.31.1

View File

@ -7,7 +7,7 @@ set -e
# ./copy-patches.sh
project=guestfs-tools
rhel_version=9.1
rhel_version=9.2
# Check we're in the right directory.
if [ ! -f $project.spec ]; then

View File

@ -26,7 +26,7 @@
Summary: Tools to access and modify virtual machine disk images
Name: guestfs-tools
Version: 1.48.2
Release: 5%{?dist}
Release: 8%{?dist}
License: GPLv2+
# Build only for architectures that have a kernel
@ -52,7 +52,7 @@ Source2: libguestfs.keyring
Source3: copy-patches.sh
# Patches are maintained in the following repository:
# https://github.com/rwmjones/guestfs-tools/commits/rhel-9.1
# https://github.com/rwmjones/guestfs-tools/commits/rhel-9.2
# Patches.
Patch0001: 0001-sysprep-remove-lvm2-s-default-system.devices-file.patch
@ -68,6 +68,8 @@ Patch0010: 0010-sysprep-set-networking-for-key-ID-clevis.patch
Patch0011: 0011-sysprep-make-an-effort-to-cope-with-LUKS-on-LVM.patch
Patch0012: 0012-sysprep-advise-against-cloning-VMs-with-internal-ful.patch
Patch0013: 0013-builder-dib-Replace-On_exit.rmdir-with-On_exit.rm_rf.patch
Patch0014: 0014-customize-Support-Rocky-Linux.patch
Patch0015: 0015-RHEL-builder-Disable-opensuse-repository.patch
%if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool, gettext-devel
@ -438,6 +440,12 @@ end
%changelog
* Thu Nov 24 2022 Richard W.M. Jones <rjones@redhat.com> - 1.48.2-8
- Support Rocky Linux in virt-customize
resolves: rhbz#2133443
- Disable OpenSUSE repo in virt-builder
resolves: rhbz#2145160
* Fri Jul 15 2022 Richard W.M. Jones <rjones@redhat.com> - 1.48.2-5
- Rebase to guestfs-tools 1.48.2
resolves: rhbz#2059286