fix the mistake of swapping function parameters of read_proc_environ_var

Resolves: bz2024976
Upstream: Fedora
Conflict: None

commit 5111c01334046dd4176d4446075b02106fb9db4a
Author: Coiby Xu <coxu@redhat.com>
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 <coxu@redhat.com>
    Reviewed-by: Pingfan Liu <piliu@redhat.com>
This commit is contained in:
Coiby Xu 2022-02-08 11:14:53 +08:00
parent 32276a35f2
commit 7a61e066b7
1 changed files with 6 additions and 2 deletions

View File

@ -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()