Hi Coiby,
On Wed, 29 Mar 2023 17:03:48 +0800
Coiby Xu <coxu(a)redhat.com> wrote:
> Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=2151504
>
> When a NetworManager connection profile contains a colon in the name,
> "nmcli --get-values UUID,FILENAME" by default would escape the colon
> because a colon is also used for separating the values. In this case,
> 99kdumpbase fails to get the correct connection profile path,
> kdumpctl[5439]: cp: cannot stat
'/run/NetworkManager/system-connections/static-52\\\:54\\\:01.nmconnection': No
such file or directory
> kdumpctl[5440]: sed: can't read /tmp/1977-DRACUT_KDUMP_NM/ifcfg-static-52-54-01:
No such file or directory
> kdumpctl[5449]: dracut-install: ERROR: installing
'/tmp/1977-DRACUT_KDUMP_NM/ifcfg-static-52-54-01' to
'/etc/NetworkManager/system-connections/ifcfg-static-52-54-01'
>
> As a result, dumping vmcore to a remote nfs would fail.
>
> In our case of getting connection profile path, there is no need to escape the
> colon so pass "-escape no" to nmcli,
>
> [root@localhost ~]# nmcli --get-values UUID,FILENAME c show
>
659e09c1-a6bd-3549-9be4-a07a1a9a8ffd:/etc/NetworkManager/system-connections/aa\:bb.nmconnection
>
> [root@localhost ~]# nmcli -escape no --get-values UUID,FILENAME c show
>
659e09c1-a6bd-3549-9be4-a07a1a9a8ffd:/etc/NetworkManager/system-connections/aa:bb.nmconnection
>
> Suggested-by: Beniamino Galvani <bgalvani(a)redhat.com>
> Reported-by: Martin Pitt <mpitt(a)redhat.com>
> Signed-off-by: Coiby Xu <coxu(a)redhat.com>
> ---
> dracut-module-setup.sh | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index ab398414..c8015cb5 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -318,7 +318,9 @@ clone_and_modify_nmconnection() {
> # connection profile based on MAC address
> _match_nmconnection_by_mac "$_uuid" "$_dev"
>
> - _cloned_nmconnection_file_path=$(nmcli --get-values UUID,FILENAME connection
show | sed -n "s/^${_uuid}://p")
> + # If a value contain ":", nmcli by default escape it with
"\:" because it
> + # also uses ":" as the delimiter to separate values. In our case,
escaping is not needed.
> + _cloned_nmconnection_file_path=$(nmcli --escape no --get-values UUID,FILENAME
connection show | sed -n "s/^${_uuid}://p")
> _tmp_nmconnection_file_path=$_DRACUT_KDUMP_NM_TMP_DIR/$(basename
"$_nmconnection_file_path")
> cp "$_cloned_nmconnection_file_path"
"$_tmp_nmconnection_file_path"
> # change uuid back to old value in case it's refered by other connection
Looks good to me
Reviewed-by: Philipp Rudo <prudo(a)redhat.com>