On Mon, Feb 7, 2022 at 8:33 AM Coiby Xu <coxu(a)redhat.com>
wrote:
> _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 <coxu(a)redhat.com
> ---
> kdumpctl | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
> diff --git a/kdumpctl b/kdumpctl
> index 3ccfa97..bf74c75 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -1580,15 +1580,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()
> --
> 2.34.1
Reviewed-by: Pingfan Liu <piliu(a)redhat.com>