From 1c9362c10def4106931ba2b17da7150afe0748cb Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Thu, 18 Dec 2014 14:07:48 +0800 Subject: [PATCH] dracut-module-setup.sh: make some clean up Chao pointed out that it's better to use get_option_value to get get a specific config_val. And also there's a potential risk when use below sed command to do the replacement. sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf Say user configure kdump.conf like the following. Then sed may replace "/var/crash/post.sh" with something else, depanding on mount point. kdump_post /var/crash/post.sh path /var/crash So in this patch clean them up. Signed-off-by: Baoquan He Acked-by: WANG Chao Acked-by: Dave Young --- dracut-module-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..793495a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -313,7 +313,7 @@ default_dump_target_install_conf() is_user_configured_dump_target && return - _save_path=$(grep ^path "/etc/kdump.conf"| cut -d' ' -f2) + _save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH _mntpoint=$(get_mntpoint_from_path $_save_path) @@ -331,7 +331,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf _path=${_save_path##"$_mntpoint"} - sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf + sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf fi } @@ -346,7 +346,7 @@ kdump_install_conf() { config_val=$(strip_comments $config_val) case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) - sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf + sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$config_val"