Blame SOURCES/0002-kpatch-clarify-unload-unsupport.patch

fa8c55
kpatch: clarify that "kpatch unload" isn't supported
fa8c55
fa8c55
Add a user-prompt to the kpatch unload subcommand and make a similiar
fa8c55
mention in the manual page.
fa8c55
fa8c55
Provide an undocumented force option so that QE and dev scripts can
fa8c55
still run unload kpatch modules from scripts.
fa8c55
fa8c55
RHEL-only.
fa8c55
fa8c55
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
fa8c55
diff -Nupr kpatch-0.6.1.old/kpatch/kpatch kpatch-0.6.1/kpatch/kpatch
707f0e
--- kpatch-0.9.2.old/kpatch/kpatch	2019-08-28 10:35:01.191259434 -0400
707f0e
+++ kpatch-0.9.2/kpatch/kpatch	2019-08-28 16:11:13.067926576 -0400
fa8c55
@@ -49,8 +49,8 @@ usage () {
fa8c55
 	echo >&2
fa8c55
 	usage_cmd "load --all" "load all installed patch modules into the running kernel"
fa8c55
 	usage_cmd "load <module>" "load patch module into the running kernel"
fa8c55
-	usage_cmd "unload --all" "unload all patch modules from the running kernel"
fa8c55
-	usage_cmd "unload <module>" "unload patch module from the running kernel"
fa8c55
+	usage_cmd "unload --all (UNSUPPORTED)" "unload all patch modules from the running kernel"
fa8c55
+	usage_cmd "unload <module> (UNSUPPORTED)" "unload patch module from the running kernel"
fa8c55
 	echo >&2
fa8c55
 	usage_cmd "info <module>" "show information about a patch module"
fa8c55
 	echo >&2
fa8c55
@@ -71,6 +71,16 @@ die() {
fa8c55
 	exit 1
fa8c55
 }
fa8c55
 
fa8c55
+confirm_prompt() {
fa8c55
+	local prompt="$1"
fa8c55
+	local answer
fa8c55
+	while true; do
fa8c55
+		read -rp "$prompt [Y/N] " answer
fa8c55
+		[[ $answer == 'Y' || $answer == 'y' ]] && return 0
fa8c55
+		[[ $answer == 'N' || $answer == 'n' ]] && return 1
fa8c55
+	done
fa8c55
+}
fa8c55
+
fa8c55
 __find_module () {
fa8c55
 	MODULE="$1"
fa8c55
 	[[ -f "$MODULE" ]] && return
fa8c55
@@ -406,6 +416,19 @@ unset MODULE
fa8c55
 init_sysfs_var
fa8c55
 
fa8c55
 [[ "$#" -lt 1 ]] && usage
fa8c55
+
fa8c55
+# RHEL-specific support options
fa8c55
+case "$1" in
fa8c55
+"force")
fa8c55
+	# For scripting purposes, support "kpatch force unload".
fa8c55
+	# Shift out the "force" to avoid the user-prompt check below.
fa8c55
+	shift
fa8c55
+	;;
fa8c55
+"unload")
fa8c55
+	confirm_prompt "WARNING: Red Hat doesn't support unloading of kpatches, continue anyway?" || exit 1
fa8c55
+	;;
fa8c55
+esac
fa8c55
+
fa8c55
 case "$1" in
fa8c55
 "load")
fa8c55
 	[[ "$#" -ne 2 ]] && usage
fa8c55
diff -Nupr kpatch-0.6.1.old/man/kpatch.1 kpatch-0.6.1/man/kpatch.1
707f0e
--- kpatch-0.9.2.old/man/kpatch.1	2019-08-28 10:35:01.191259434 -0400
707f0e
+++ kpatch-0.9.2/man/kpatch.1	2019-08-28 14:51:23.268198897 -0400
fa8c55
@@ -23,10 +23,10 @@ load --all
fa8c55
 load <module>
fa8c55
        load patch module into the running kernel
fa8c55
 
fa8c55
-unload --all
fa8c55
+unload --all (UNSUPPORTED)
fa8c55
        unload all patch modules from the running kernel
fa8c55
 
fa8c55
-unload <module>
fa8c55
+unload <module> (UNSUPPORTED)
fa8c55
        unload patch module from the running kernel
fa8c55
 
fa8c55
 info <module>