Blame SOURCES/0010-sysprep-set-networking-for-key-ID-clevis.patch

7b180b
From c2917c9a7f0c23b94d30af2a5a14e67c46e38242 Mon Sep 17 00:00:00 2001
7b180b
From: Laszlo Ersek <lersek@redhat.com>
7b180b
Date: Tue, 28 Jun 2022 13:57:02 +0200
7b180b
Subject: [PATCH] sysprep: set networking for "--key ID:clevis"
7b180b
7b180b
Similarly to virt-customize, virt-sysprep has prior "--network" and
7b180b
"--no-network" options. Unlike virt-customize though, virt-sysprep
7b180b
defaults to disabling the appliance network. Therefore we can't tell
7b180b
whether the network is disabled "by default" or because the user requested
7b180b
it.
7b180b
7b180b
That's a problem: "--key ID:clevis" is supposed to override the former,
7b180b
but not the latter. Add a separate option for tracking "--no-network", and
7b180b
only if "--no-network" is absent, permit "--network" or "--key ID:clevis"
7b180b
to turn on the network.
7b180b
7b180b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
7b180b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
7b180b
Message-Id: <20220628115702.5584-5-lersek@redhat.com>
7b180b
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
7b180b
(cherry picked from commit 1cce13223e9321d1ef333d6ae356c24203990a4a)
7b180b
---
7b180b
 sysprep/main.ml | 7 +++++--
7b180b
 1 file changed, 5 insertions(+), 2 deletions(-)
7b180b
7b180b
diff --git a/sysprep/main.ml b/sysprep/main.ml
7b180b
index b760618ad..1f722dfb0 100644
7b180b
--- a/sysprep/main.ml
7b180b
+++ b/sysprep/main.ml
7b180b
@@ -44,6 +44,7 @@ let main () =
7b180b
     let libvirturi = ref "" in
7b180b
     let mount_opts = ref "" in
7b180b
     let network = ref false in
7b180b
+    let no_network = ref false in
7b180b
     let operations = ref None in
7b180b
 
7b180b
     let format = ref "auto" in
7b180b
@@ -131,7 +132,7 @@ let main () =
7b180b
       [ L"list-operations" ], Getopt.Unit list_operations, s_"List supported operations";
7b180b
       [ L"mount-options" ], Getopt.Set_string (s_"opts", mount_opts),  s_"Set mount options (eg /:noatime;/var:rw,noatime)";
7b180b
       [ L"network" ], Getopt.Set network,           s_"Enable appliance network";
7b180b
-      [ L"no-network" ], Getopt.Clear network,      s_"Disable appliance network (default)";
7b180b
+      [ L"no-network" ], Getopt.Set no_network,     s_"Disable appliance network (default)";
7b180b
       [ L"operation"; L"operations" ],  Getopt.String (s_"operations", set_operations), s_"Enable/disable specific operations";
7b180b
     ] in
7b180b
     let args = basic_args @ Sysprep_operation.extra_args () in
7b180b
@@ -188,6 +189,7 @@ read the man page virt-sysprep(1).
7b180b
     (* Dereference the rest of the args. *)
7b180b
     let dryrun = !dryrun in
7b180b
     let network = !network in
7b180b
+    let no_network = !no_network in
7b180b
     let operations = !operations in
7b180b
 
7b180b
     (* At this point we know which operations are enabled.  So call the
7b180b
@@ -208,7 +210,8 @@ read the man page virt-sysprep(1).
7b180b
 
7b180b
     (* Connect to libguestfs. *)
7b180b
     let g = open_guestfs () in
7b180b
-    g#set_network network;
7b180b
+    g#set_network (not no_network &&
7b180b
+                   (network || key_store_requires_network opthandle.ks));
7b180b
     add g dryrun;
7b180b
     g#launch ();
7b180b
 
7b180b
-- 
7b180b
2.31.1
7b180b