Blame SOURCES/0005-RHEL-8-Reject-use-of-libguestfs-winsupport-features-.patch

aba816
From cb2ac63562447e2780bd7103ed060fd6013b9054 Mon Sep 17 00:00:00 2001
df3bb2
From: "Richard W.M. Jones" <rjones@redhat.com>
df3bb2
Date: Tue, 7 Jul 2015 09:28:03 -0400
df3bb2
Subject: [PATCH] RHEL 8: Reject use of libguestfs-winsupport features except
df3bb2
 for virt-* tools (RHBZ#1240276).
df3bb2
aba816
Fix the tests: it doesn't let us use guestfish for arbitrary Windows
aba816
edits.
df3bb2
---
aba816
 generator/c.ml                             | 16 ++++++++++++++++
aba816
 test-data/phony-guests/make-windows-img.sh |  1 +
aba816
 tests/charsets/test-charset-fidelity.c     |  2 ++
aba816
 3 files changed, 19 insertions(+)
df3bb2
df3bb2
diff --git a/generator/c.ml b/generator/c.ml
aba816
index 86d3b26f8..a625361a9 100644
df3bb2
--- a/generator/c.ml
df3bb2
+++ b/generator/c.ml
aba816
@@ -1846,6 +1846,22 @@ and generate_client_actions actions () =
df3bb2
     check_args_validity c_name style;
df3bb2
     trace_call name c_name style;
df3bb2
 
df3bb2
+    (* RHEL 8 *)
df3bb2
+    if name = "mount" || name = "mount_ro" || name = "mount_options" ||
df3bb2
+       name = "mount_vfs" then (
df3bb2
+      pr "  if (g->program && !STRPREFIX (g->program, \"virt-\")) {\n";
df3bb2
+      pr "    CLEANUP_FREE char *vfs_type = guestfs_vfs_type (g, mountable);\n";
df3bb2
+      pr "    if (vfs_type && STREQ (vfs_type, \"ntfs\")) {\n";
df3bb2
+      pr "      error (g, \"mount: unsupported filesystem type\");\n";
df3bb2
+      pr "      if (trace_flag)\n";
df3bb2
+      pr "        guestfs_int_trace (g, \"%%s = %%s (error)\",\n";
df3bb2
+      pr "                              \"%s\", \"-1\");\n" name;
df3bb2
+      pr "      return %s;\n" (string_of_errcode errcode);
df3bb2
+      pr "    }\n";
df3bb2
+      pr "  }\n";
df3bb2
+      pr "\n";
df3bb2
+    );
df3bb2
+
df3bb2
     (* Calculate the total size of all FileIn arguments to pass
df3bb2
      * as a progress bar hint.
df3bb2
      *)
aba816
diff --git a/test-data/phony-guests/make-windows-img.sh b/test-data/phony-guests/make-windows-img.sh
aba816
index 30908a918..73cf5144e 100755
aba816
--- a/test-data/phony-guests/make-windows-img.sh
aba816
+++ b/test-data/phony-guests/make-windows-img.sh
aba816
@@ -37,6 +37,7 @@ fi
aba816
 
aba816
 # Create a disk image.
aba816
 guestfish <
aba816
+set-program virt-testing
aba816
 sparse windows.img-t 512M
aba816
 run
aba816
 
aba816
diff --git a/tests/charsets/test-charset-fidelity.c b/tests/charsets/test-charset-fidelity.c
aba816
index 39ccc2068..2b2e2d8a9 100644
aba816
--- a/tests/charsets/test-charset-fidelity.c
aba816
+++ b/tests/charsets/test-charset-fidelity.c
aba816
@@ -94,6 +94,8 @@ main (int argc, char *argv[])
aba816
   if (g == NULL)
aba816
     error (EXIT_FAILURE, 0, "failed to create handle");
aba816
 
aba816
+  guestfs_set_program (g, "virt-testing");
aba816
+
aba816
   if (guestfs_add_drive_scratch (g, 1024*1024*1024, -1) == -1)
aba816
     exit (EXIT_FAILURE);
aba816
 
df3bb2
-- 
aba816
2.31.1
df3bb2