Resolves: BZ1484945
https://bugzilla.redhat.com/show_bug.cgi?id=1484945
Currently the kdumpctl script doesn't handle
whitespaces (including TABs) which might be there before
an option name in the kdump.conf
This patch addresses this issue, by ensuring that the
kdumpctl errors out in case it finds any stray space(s)
or tab(s) before a option name.
Reported-by: Kenneth D'souza <kdsouza(a)redhat.com>
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
kdumpctl | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/kdumpctl b/kdumpctl
index 7d06efe292aa..56975a3ba1dc 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -351,6 +351,8 @@ restore_default_initrd()
check_config()
{
local nr
+ TMP_FILE='/tmp/kdump.conf.tmp'
+ touch $TMP_FILE
nr=$(awk 'BEGIN{cnt=0}
/^raw|^ssh[[:blank:]]|^nfs|^ext[234]|^xfs|^btrfs|^minix|^dracut_args .*\-\-mount/{cnt++}
END{print cnt}' $KDUMP_CONFIG_FILE)
[ $nr -gt 1 ] && {
@@ -364,6 +366,20 @@ check_config()
return 1
}
+ # Check if we have any leading spaces (or tabs) before the
+ # variable name in the kdump conf file. While doing so exclude any
+ # comments which appear to have leading spaces (or tabs)
+ awk 'BEGIN{cnt=0} {cnt=match($0, /^[[:blank:]]/); if(cnt!=0) print $0}'
$KDUMP_CONFIG_FILE >> $TMP_FILE
+
+ nr=$(awk 'BEGIN{cnt_hash=0; cnt_blank=0} {cnt_hash=match($0, /#.*$/);
if(cnt_hash!=0) next; else cnt_blank++} END{print cnt_blank}' $TMP_FILE)
+ [ $nr -gt 0 ] && {
+ echo "No whitespaces are allowed before a kdump option name. Please check
$KDUMP_CONFIG_FILE"
+ rm -f $TMP_FILE
+ return 1
+ }
+
+ rm -f $TMP_FILE
+
while read config_opt config_val; do
case "$config_opt" in
\#* | "")
--
2.7.4