From: Wade Mealing <wmealing(a)redhat.com>
The RHEL 5 release of mkdumprd allowed for comments in the kdump config
file as shown below:
net 192.168.1.1 # this is the comment part
This patch strips them out during processing, but leaves the configuration
file in original condition.
---
dracut-kdump.sh | 8 ++++++++
dracut-module-setup.sh | 6 ++++++
kdumpctl | 9 +++++++++
mkdumprd | 6 ++++++
4 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 7baa673..fab176a 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -230,6 +230,10 @@ get_host_ip()
return 0
}
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
read_kdump_conf()
{
if [ ! -f "$conf_file" ]; then
@@ -240,6 +244,8 @@ read_kdump_conf()
# first get the necessary variables
while read config_opt config_val;
do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
case "$config_opt" in
path)
KDUMP_PATH="$config_val"
@@ -283,6 +289,8 @@ read_kdump_conf()
# rescan for add code for dump target
while read config_opt config_val;
do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
case "$config_opt" in
ext[234]|xfs|btrfs|minix|nfs)
add_dump_code "dump_fs $config_val"
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 099c03a..cbf2912 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -62,6 +62,10 @@ kdump_is_vlan() {
[ -f /proc/net/vlan/"$1" ]
}
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
# $1: netdev name
kdump_setup_dns() {
_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
@@ -252,6 +256,8 @@ kdump_install_conf() {
while read config_opt config_val;
do
+ # remove inline comments after the end of a directive.
+ 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
diff --git a/kdumpctl b/kdumpctl
index aba1e3c..e2c4960 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -78,6 +78,10 @@ function check_exist()
done
}
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
#$1: the files to be checked with IFS=' '
function check_executable()
{
@@ -100,6 +104,8 @@ function check_config()
}
while read config_opt config_val; do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
case "$config_opt" in
\#* | "")
;;
@@ -257,6 +263,9 @@ function load_kdump()
function check_ssh_config()
{
while read config_opt config_val; do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
+
case "$config_opt" in
sshkey)
if [ -f "$config_val" ]; then
diff --git a/mkdumprd b/mkdumprd
index 26fe5af..57217d1 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -518,8 +518,14 @@ if [ "$(uname -m)" = "s390x" ]; then
add_dracut_module "znet"
fi
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
while read config_opt config_val;
do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
case "$config_opt" in
extra_modules)
extra_modules="$extra_modules $config_val"
--
1.7.1