On Wed, Jan 19, 2022 at 04:49:45PM +0800, Pingfan Liu wrote:
On Wed, Jan 19, 2022 at 2:33 PM Coiby Xu <coxu(a)redhat.com>
wrote:
>
> The environment variable entries in /proc/[pid]/environ are separated by
> null bytes instead of by spaces. Update the sed regex to fix this issue.
>
> Note this patch also fixes a issue which is kdumpctl would try to reset
> crashkernel even osbuild has provided custom crashkernel value.
>
> Fixes: ddd428a ("set up kernel crashkernel for osbuild in kernel hook")
> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
> ---
> kdumpctl | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/kdumpctl b/kdumpctl
> index 8107487..b32fac0 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -1578,7 +1578,7 @@ reset_crashkernel_after_update()
>
> _is_osbuild()
> {
> - [[ $(sed -n -E 's/.*(^|\s)container=(\S*).*/\2/p' <
/proc/1/environ) == bwrap-osbuild ]]
> + [[ $(sed -n -E 's/.*(^|\x00)container=([^\x00]*).*/\2/p' <
/proc/1/environ) == bwrap-osbuild ]]
It looks right, but could you input some data, so I can be more sure about it.
Sure, I'll rewrite this function in order to add some unit tests which I
guess will be the data your need.
> }
>
> reset_crashkernel_for_installed_kernel()
> @@ -1590,8 +1590,10 @@ reset_crashkernel_for_installed_kernel()
> exit 1
> fi
>
> - if _is_osbuild && ! grep -qs crashkernel= /etc/kernel/cmdline; then
> - reset_crashkernel "--kernel=$_installed_kernel"
> + if _is_osbuild; then
> + if ! grep -qs crashkernel= /etc/kernel/cmdline; then
> + reset_crashkernel "--kernel=$_installed_kernel"
> + fi
> return
> fi
>
> --
> 2.31.1
Else, LGTM,
Reviewed-by: Pingfan Liu <piliu(a)redhat.com>
Thanks for reviewing this patch!
>
--
Best regards,
Coiby