From 7a61e066b78358650b774f4052cb0eea69023aee Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 8 Feb 2022 11:14:53 +0800 Subject: [PATCH] fix the mistake of swapping function parameters of read_proc_environ_var Resolves: bz2024976 Upstream: Fedora Conflict: None commit 5111c01334046dd4176d4446075b02106fb9db4a Author: Coiby Xu Date: Mon Feb 7 08:08:01 2022 +0800 fix the mistake of swapping function parameters of read_proc_environ_var _is_osbuild fails because it expects the 1st and 2nd function parameter to be the environment variable and environ file path respectively. Fix it by swapping the parameters in read_proc_environ_var. Note the osbuild environ file path is defined in _OSBUILD_ENVIRON_PATH so _is_osbuild can be unit-tested by overwriting _OSBUILD_ENVIRON_PATH. Fixes: 6a3ce83 ("fix the error of parsing the container environ variable for osbuild") Signed-off-by: Coiby Xu Reviewed-by: Pingfan Liu --- kdumpctl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index a8384c8..e670295 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1606,15 +1606,19 @@ reset_crashkernel_after_update() # # The environment variable entries in /proc/[pid]/environ are separated # by null bytes instead of by spaces. +# +# $1: environment variable +# $2: environ file path read_proc_environ_var() { - local _environ_path=$1 _var=$2 + local _var=$1 _environ_path=$2 sed -n -E "s/.*(^|\x00)${_var}=([^\x00]*).*/\2/p" < "$_environ_path" } +_OSBUILD_ENVIRON_PATH='/proc/1/environ' _is_osbuild() { - [[ $(read_proc_environ_var container /proc/1/environ) == bwrap-osbuild ]] + [[ $(read_proc_environ_var container "$_OSBUILD_ENVIRON_PATH") == bwrap-osbuild ]] } reset_crashkernel_for_installed_kernel()