Strip inline comments from the kdump config file before use

From: Wade Mealing <wmealing@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.

Signed-off-by: Wade Mealing <wmealing@redhat.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Baoquan He 2013-09-26 19:46:48 +08:00
parent ee524473c8
commit 59e28ddf75
4 changed files with 14 additions and 0 deletions

View File

@ -226,6 +226,8 @@ read_kdump_conf()
# first get the necessary variables # first get the necessary variables
while read config_opt config_val; while read config_opt config_val;
do do
# remove inline comments after the end of a directive.
config_val=$(strip_comments $config_val)
case "$config_opt" in case "$config_opt" in
path) path)
KDUMP_PATH="$config_val" KDUMP_PATH="$config_val"
@ -269,6 +271,8 @@ read_kdump_conf()
# rescan for add code for dump target # rescan for add code for dump target
while read config_opt config_val; while read config_opt config_val;
do do
# remove inline comments after the end of a directive.
config_val=$(strip_comments $config_val)
case "$config_opt" in case "$config_opt" in
ext[234]|xfs|btrfs|minix|nfs) ext[234]|xfs|btrfs|minix|nfs)
add_dump_code "dump_fs $config_val" add_dump_code "dump_fs $config_val"

View File

@ -245,6 +245,8 @@ kdump_install_conf() {
while read config_opt config_val; while read config_opt config_val;
do do
# remove inline comments after the end of a directive.
config_val=$(strip_comments $config_val)
case "$config_opt" in case "$config_opt" in
ext[234]|xfs|btrfs|minix|raw) 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_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf

View File

@ -10,6 +10,8 @@ SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
DUMP_TARGET="" DUMP_TARGET=""
. /lib/kdump/kdump-lib.sh
standard_kexec_args="-p" standard_kexec_args="-p"
if [ -f /etc/sysconfig/kdump ]; then if [ -f /etc/sysconfig/kdump ]; then
@ -106,6 +108,8 @@ function check_config()
} }
while read config_opt config_val; do 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 case "$config_opt" in
\#* | "") \#* | "")
;; ;;
@ -263,6 +267,8 @@ function load_kdump()
function check_ssh_config() function check_ssh_config()
{ {
while read config_opt config_val; do 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 case "$config_opt" in
sshkey) sshkey)
if [ -f "$config_val" ]; then if [ -f "$config_val" ]; then

View File

@ -506,6 +506,8 @@ fi
while read config_opt config_val; while read config_opt config_val;
do do
# remove inline comments after the end of a directive.
config_val=$(strip_comments $config_val)
case "$config_opt" in case "$config_opt" in
extra_modules) extra_modules)
extra_modules="$extra_modules $config_val" extra_modules="$extra_modules $config_val"