[PATCH] mkdumprd: allow spaces after 'path' config phrase when network dump
by Kazuhito Hagio
Without this patch, when there are two or more spaces after 'path'
configuration phrase with ssh or nfs setting, SAVE_PATH is set to
'/var/crash' in mkdumprd, and in most cases kdump service fails to
start.
ssh kdump(a)192.168.122.1
path /kdump
^^
This behavior would be too sensitive and different from the other
configurations. With this patch, mkdumprd allows such spaces.
Signed-off-by: Kazuhito Hagio <k-hagio(a)ab.jp.nec.com>
---
mkdumprd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index a6f7fe8..aa0abfd 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -13,7 +13,7 @@ export IN_KDUMP=1
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
-SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
+SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
# strip the duplicated "/"
SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
--
2.18.0
1 year, 4 months
Re: [dm-crypt] Kdump with full-disk LUKS encryption
by Kairui Song
Hi,
Thanks a lot, these info are very helpful.
Better to keep it for debugging for now, and ask users to use it very carefully.
On Tue, Apr 20, 2021 at 3:54 PM Milan Broz <gmazyland(a)gmail.com> wrote:
>
> Hi,
>
> TL;DR what you are trying to do is to actually reverse many security measures
> we added. It is perhaps acceptable for debugging but hardly for real generic system.
>
> - using memory-hard function increases cost of dictionary and brute-force
> attacks
> You can always decrease amount of memory needed, but you should do it only
> if you know that security margin is ok (like password is randomly generated
> with enough entropy).
>
> - key is in keyring to remove possibility for normal userspace to receive
> the key from kernel. Moreover, there is no need to retain kernel in keyring once
> dm-crypt device is activated. (It is still in kernel memory but only in crypto
> functions context). (Systemd also uses keyring to cache passphrase but that's
> different thing.)
>
> You can still use old way for activation with --disable-keyring activation,
> but then you disable this possibility.
>
> More comments below.
>
> On 19/04/2021 12:00, Kairui Song wrote:
> > Hi all,
> >
> > I'm currently trying to add kdump support for systemd with full-disk
> > LUKS encryption. vmcores contain sensitive data so they should also be
> > protected, and network dumps sometimes are not available. So kdump has
> > to open the LUKS encrypted device in the kdump environment.
> >
> > I'm using systemd/dracut, my work machine is running Fedora 34, and
> > there are several problems I'm trying to solve:
> > 1. Users have to input the password in the kdump kernel environment.
> > But users often don't have shell access to the kdump environment.
> > (headless server, graphic card not working after kexec, both are very
> > common)
> > 2. LUKS2 prefers Argon2 as the key derivation function, designed to
> > use a lot of memory. kdump is expected to use a minimal amount of
> > memory. Users will have to reserve a huge amount of memory for kdump
> > to work (eg. 1G reserve for kdump with 4G total memory which is not
> > reasonable).
>
> When I added Argon2 to LUKS2, I actually expected such issues. Despite
> some people beats me that they cannot use arbitrary amount of memory,
> we have some hard limits that were selected that it should work on most recent
> systems. Maybe kdump can live with it.
>
> - maximum memory cost limit is 4GB, no LUKS2 device can use more for Argon2
> - we never use more than half of available physical memory
> (measured on the host where the device was formatted)
> - required amount of memory is visible in LUKS2 metadata (luksDump)
> for the particular keyslot (Memory: the value is in kB)
> - we use benchmark to calculate memory cost with prefered unlocking
> time 2 seconds (again, on the device where LUKS was formatted)
> Small systems (like RPi2) the uses much smaller acceptable values.
> You can configure all costs (time, memory, threads) during format
> or even set them to predefined values.
>
> I am sorry, but there is really no way around this - and the requeired
> memory must be physical memory (otherwise it slows down extremely).
> This is a feature, not a bug :-)
>
>
> > To fix these problems, I tried to pass the master key to the second
> > kernel directly via initramfs. Kdump will modify the initramfs in
> > ramfs to include the key, kexec_load it, and never write to any actual
> > back storage. This worked with old LUKS configurations.
>
> Well, passing volume key this way is quite insecure, but perhaps
> acceptable for debugging.
>
> >
> > But LUKS2/cryptsetup now stores the key in the kernel keyring by
> > default. The key is accessible from userspace.
>
> If you are talking about volume key (not passsphrase), it is not
> available from userspace. Only reference to it. But you can use
> this reference to construct in-kernel dm-crypt device.
> Please read https://gitlab.com/cryptsetup/cryptsetup/-/blob/master/docs/Keyring.txt
>
> > Users can enter the password to start kdump manually and then it will
> > work, but usually people expect kdump service to start automatically.
> >
> > (WIP patch series:
> > https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.o...)
> >
> > I've several ideas about how to improve it but not sure which one is
> > better, and if this is a good idea after all:
> > 1. Simply introduce a config to let systemd-cryptsetup disable kernel
> > keyring on setup, there is currently no such option.
>
> Well, that option could be useful anyway and we have support for it
> in cryptsetup (--disable-keyring CLI option) and libcryptsetup, so why not.
> Just this should not be a default option.
>
> This is should be patch for systemd-cryptsetup only as libcryptsetup supports it.
>
> ...
>
> > 2. If we can let the key stay in userspace for a little longer, eg.
> > for systems booted with dracut/systemd, when
> > systemd-cryptsetup(a)%s.service opens the crypt device, keep the key in
> > dm-crypt. And later when services like kdump have finished loading,
> > cryptsetup can refresh the device and store the key in the kernel
> > keyring again.
>
> We invalidate volume key in keyring after libceyposetup operation
> is finished (and kernel removes the reference once keyring garbage collection
> is run).
>
> I can imagine to add some option to keep key inside keyring even after
> call is finished, but as said above, this removes some security margin
> we intentionally introduced here.
I agree with your comments, thanks! These two approaches seem not a
good idea now.
>
> ...
>
> Milan
>
How about plan 3 and 4?
> 3. Let kdump use some custom helper/service to load all needed
> resources in the early initrd boot stage, prior to
> systemd-cryptsetup(a)%s.service. It will ask the password / parse the
> keyfile and load kdump, then provide info for systemd-cryptsetup or
> just do the setup. Or maybe let systemd-cryptsetup support some kind
> of "plugins" so other tools can use it.
Some details could be changed/improved, but
systemd-cryptsetup(a)%s.service will prompt for a password or use a
keyfile anyway.
So I think at this point, loading kdump with the volume key should be
safe? At least long as the kdump kernel/environment itself isn't
compromised. Loaded kdump resources can be restricted to be only
accessible from the kernel side.
After panic, kernel kexec jumps to kdump kernel, and that's an
minimized emergency environment that only lives for a very short
period.
> 4. A better and safer solution seems to keep a consistent key ring
> between kexec boots but also more complex and difficult as different
> arch implements kexec differently.
Maybe plan 4 will be a good idea if doable? Since that keeps the key
consistent in the kernel between kexec boots, and cryptsetup can just
reuse it.
--
Best Regards,
Kairui Song
1 year, 11 months
[PATCH v4] selftest: kill VM reliably by recursively kill children processes
by Coiby Xu
qemu is launched in nested subprocess and can't be killed by simply
killing the job ids,
PID Command
2269634 │ ├─ sshd: root [priv]
2269637 │ │ └─ sshd: root@pts/0
2269638 │ │ └─ -bash
2269744 │ │ └─ make test-run V=1
2273117 │ │ └─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh
2273712 │ │ ├─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh
2273714 │ │ │ └─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh
2273737 │ │ │ └─ timeout --foreground 10m /root/kexec-tools-300/tests/scripts/run-qemu -nodefaults -nographic -smp 2 -m 768M -monitor no
2273738 │ │ │ └─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial stdio
2273746 │ │ │ ├─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial std
2273797 │ │ ├─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh
2273798 │ │ │ └─ /bin/bash /root/kexec-tools-300/tests/scripts/run-test.sh
2273831 │ │ │ └─ timeout --foreground 10m /root/kexec-tools-300/tests/scripts/run-qemu -nodefaults -nographic -smp 2 -m 768M -monitor no
2273832 │ │ │ └─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial stdio
2273840 │ │ │ ├─ /usr/bin/qemu-system-x86_64 -enable-kvm -cpu host -nodefaults -nographic -smp 2 -m 768M -monitor none -serial std
This led to the error "qemu-system-x86_64: can't bind ip=0.0.0.0 to
socket: Address already in use".
This patch will kill qemu by killing all the children of the job id.
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
Thanks to Kairui for finding out an error and an issue about previous
version,
- "$_job" should be used instead "$job"
- "Ctrl-c" leads to the failure of parsing pstree result
This version stops parsing pstree and use pgrep to get the children of a
process and kill them recursively instead.
---
tests/scripts/run-test.sh | 37 +++++++++++++++++++++++++++++++++----
tests/scripts/test-lib.sh | 3 +--
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh
index a68504d..7113be8 100755
--- a/tests/scripts/run-test.sh
+++ b/tests/scripts/run-test.sh
@@ -1,9 +1,38 @@
#!/bin/bash
-_kill_all_jobs() {
- local _jobs=$(jobs -r -p)
+_kill_if_valid_pid() {
+ local _pid="$1"
+ if ps -p $_pid > /dev/null
+ then
+ kill $_pid
+ fi
+}
+
+_recursive_kill() {
+ local _pid="$1"
+ local _children _child
+
+ _children=$(pgrep -P $_pid)
+ if [ -n "$_children" ]; then
+ for _child in $_children
+ do
+ _recursive_kill $_child
+ _kill_if_valid_pid $_child
+ done
+ fi
+ _kill_if_valid_pid $_pid
+}
- [ -n "$_jobs" ] && kill $_jobs
+_kill_all_jobs() {
+ local _jobs=$(jobs -r -p)
+ local _job
+
+ if [ -n "$_jobs" ]; then
+ for _job in $_jobs
+ do
+ _recursive_kill $_job
+ done
+ fi
}
trap '
@@ -121,7 +150,7 @@ for test_case in $testcases; do
[ $? -ne 0 ] && ret=$(expr $ret + 1)
results[$test_case]="$res"
-
+ _kill_all_jobs
echo -e "-------- Test finished: $test_case $res --------"
for script in $scripts; do
script="$testdir/$script"
diff --git a/tests/scripts/test-lib.sh b/tests/scripts/test-lib.sh
index f8a2249..8b24b2a 100644
--- a/tests/scripts/test-lib.sh
+++ b/tests/scripts/test-lib.sh
@@ -146,8 +146,7 @@ watch_test_outputs() {
ret=$?
if [ $ret -ne 255 ]; then
- # Test finished, kill VMs
- kill $(jobs -p)
+ # Test finished
break 2
fi
done
--
2.32.0
1 year, 11 months
[PATCH] kdumpctl: fix config checking with override_resettable
by Kairui Song
It's strange that override_resettable is currently marked as an
invalid config option, just fix this.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdumpctl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kdumpctl b/kdumpctl
index 18b546d7..121c5de5 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -236,7 +236,7 @@ check_config()
ext[234] | minix | btrfs | xfs | nfs | ssh)
config_opt=_target
;;
- sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes) ;;
+ sshkey | path | core_collector | kdump_post | kdump_pre | extra_bins | extra_modules | failure_action | default | final_action | force_rebuild | force_no_rebuild | fence_kdump_args | fence_kdump_nodes | override_resettable) ;;
net | options | link_delay | disk_timeout | debug_mem_level | blacklist)
derror "Deprecated kdump config option: $config_opt. Refer to kdump.conf manpage for alternatives."
--
2.31.1
2 years
[PATCH 0/6] Add reboot estimation support
by Kairui Song
This series add an more accurate kdump crashkernel estimation helper.
More details are in PATCH 5/6.
1/6 - 2/6 are required change for the new feature.
3/6 introduce a new file, just to make the code structure more clear.
4/6 fixes a bug I found while composing this patch.
5/6 and 6/6 adds this new command and docs.
Kairui Song (6):
kdumpctl: only acquire the single instance lock when necessary
kdumpctl: allow passing in extra cmdline using env variable
kdump-estiamte.sh: introduce a seperate file
kdump-lib.sh: fix kdump_get_arch_recommend_size
kdump-estimate.sh: add reboot estimation support
Upate crashkernel-howto.txt
.editorconfig | 2 +-
crashkernel-howto.txt | 104 ++++-
dracut-kdump.sh | 15 +
kdump-estimate-cleanup.service | 8 +
kdump-estimate.service | 11 +
kdump-estimate.sh | 778 +++++++++++++++++++++++++++++++++
kdump-lib.sh | 74 +---
kdump.shutdown | 13 +
kdumpctl | 108 +----
kexec-tools.spec | 21 +-
10 files changed, 940 insertions(+), 194 deletions(-)
create mode 100644 kdump-estimate-cleanup.service
create mode 100644 kdump-estimate.service
create mode 100644 kdump-estimate.sh
create mode 100644 kdump.shutdown
--
2.31.1
2 years
[PATCH] kdumpctl: only acquire the single instance lock when necessary
by Kairui Song
Only acquire the single instance lock when following commands are used:
- kdumpctl start
- kdumpctl restart
- kdumpctl rebuild
- kdumpctl reload
- kdumpctl stop
- kdumpctl propagate
For other commands, like showmem, estimate or help, there is no reason
for kdumpctl to be blocked.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
This is based on the series: [PATCH 0/3] Remove harcoded FDs
kdumpctl | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 048404b1..720820f8 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -1346,6 +1346,7 @@ main()
case "$1" in
start)
+ single_instance_lock
if [[ -s /proc/vmcore ]]; then
save_core
reboot
@@ -1354,6 +1355,7 @@ main()
fi
;;
stop)
+ single_instance_lock
stop
;;
status)
@@ -1372,17 +1374,22 @@ main()
exit $EXIT_CODE
;;
reload)
+ single_instance_lock
reload
;;
restart)
+ single_instance_lock
stop
start
;;
rebuild)
+ single_instance_lock
rebuild
;;
- condrestart) ;;
+ condrestart)
+ ;;
propagate)
+ single_instance_lock
propagate_ssh_key
;;
showmem)
@@ -1401,9 +1408,6 @@ main()
esac
}
-# Other kdumpctl instances will block in queue, until this one exits
-single_instance_lock
-
main "$@"
exit $?
--
2.31.1
2 years
[PATCH 0/3] Remove harcoded FDs
by Kairui Song
Use bash's builtin FD allocation or iterate valid POSIX FDs.
Kairui Song (3):
kdumpctl: don't hardcode the lock FD
kdumpctl: don't hardcode the temporary stderr holder FD
kdump-logger.sh: remove hardcoded fd for syslog
kdump-logger.sh | 25 +++++++++++++++++++------
kdumpctl | 26 ++++++++++----------------
2 files changed, 29 insertions(+), 22 deletions(-)
--
2.31.1
2 years
[PATCH] kdump-lib.sh: simplify kdump_get_persistent_dev
by Kairui Song
It has the exact same code as to_dev_name except it calls
get_persistent_dev, so just call to_dev_name here.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdump-lib.sh | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 3da9ac3b..b0b2bc8b 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -227,19 +227,8 @@ get_kdump_mntpoint_from_target()
echo $_mntpoint | tr -s "/"
}
-kdump_get_persistent_dev()
-{
- local dev="${1//\"/}"
-
- case "$dev" in
- UUID=*)
- dev=$(blkid -U "${dev#UUID=}")
- ;;
- LABEL=*)
- dev=$(blkid -L "${dev#LABEL=}")
- ;;
- esac
- echo $(get_persistent_dev "$dev")
+kdump_get_persistent_dev() {
+ get_persistent_dev "$(to_dev_name "$1")"
}
is_atomic()
--
2.31.1
2 years
[PATCH] mkdumprd: automatically create dump path for user specified target
by Kairui Song
When user only provided a "path" value in kdump.conf without explicitly
specify a dump target, covering all cases with "path" config value is
complex.
"path" could be a mount point, a dir insidse a mount point, or nested mount,
bind mount etc. kdump need to detect the real dump target based on the
"path" value, so user have to be carefull with it and in charge
of creating it.
But for user specified dump target (dump target explicitly specified with
nfs/ext4/xfs/...), the "path" config have only one sole meaning: the absolute
dump path on a dump target. In this case it's safe for kdump to create
it automatically.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
mkdumprd | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index cc37ae18..0dc4459e 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -242,7 +242,8 @@ check_user_configured_target()
# For user configured target, use $SAVE_PATH as the dump path within the target
if [[ ! -d "$_mnt/$SAVE_PATH" ]]; then
- perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\""
+ dwarn "Dump path \"$SAVE_PATH\" does not exist on dump target \"$_target\", kdump will create this path automatically."
+ mkdir -p "$_mnt/$SAVE_PATH" || perror_exit "Failed to create dump path \"$SAVE_PATH\" on dump target."
fi
check_size fs "$_target"
--
2.31.1
2 years
[PATCH] kdump-lib-initramfs.sh: add two args parsing helper
by Kairui Song
Add kdump_parse_args and kdump_parse_get_arg, these two helper can parse
shell args properly, handle quotes and escaped characters.
kdump_parse_args accepts a plain string, and a callback function. It
will parse the string as shell command line arguments correctly (except
it doesn't allow newline in the command line, which should be accetable
since newline is not supported in kdump.conf file either), and then it
call the callback using these arguments.
kdump_parse_get_arg will parse the string the same way, then get the
specified args value. It can handle all kind of argument format: arg=val,
--arg val, --arg=val).
For example:
`kdump_parse_args '-e "\nword\n"' echo
Is equivalent to:
echo -e "\nword\n"
`kdump_parse_get_arg '--opt=1 --opt 2 -o "3 4"' -o --opt`
Will print:
1
2
3 4
Because some params can be used multiple times, caller should decide
if the later value should override previous value or not.
All dracut_args related parsing codes are updated to use these two
new helper.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
dracut-module-setup.sh | 1 +
kdump-lib-initramfs.sh | 45 ++++++++++++++++++++++++++++++++++++++++--
kdump-lib.sh | 24 ++++++++--------------
kdumpctl | 4 ++--
mkdumprd | 4 +---
5 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index a5e4b678..a6257bf6 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -1029,6 +1029,7 @@ install() {
inst "/bin/awk" "/bin/awk"
inst "/bin/sed" "/bin/sed"
inst "/bin/stat" "/bin/stat"
+ inst "/bin/xargs" "/bin/xargs"
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
inst "/usr/bin/printf" "/sbin/printf"
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index c1fd75f5..ab4c7010 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -24,6 +24,47 @@ kdump_get_conf_val()
sed -n -e "/^\s*\($1\)\s\+/{s/^\s*\($1\)\s\+//;s/#.*//;s/\s*$//;h};\${x;p}" $KDUMP_CONFIG_FILE
}
+# parse shell arguments properly, call a function use parses args
+# $1: args plain string
+# ${@:2}: callback
+kdump_parse_args()
+{
+ _arg=$1
+ shift
+ _func=$*
+ set --
+ while read -r _arg; do
+ set -- "$@" "$_arg"
+ done << EOF
+$(xargs -n 1 echo '' << ARG
+$_arg
+ARG
+)
+EOF
+ $_func "$@"
+}
+
+# $1: args plain string
+# ${@:2}: list of the arg to get
+kdump_parse_get_arg()
+{
+ _arg=$1
+ shift
+ _func="_func() {
+ while [ \$# -gt 1 ]; do
+ case \$1 in"
+ while [ $# -ge 1 ]; do
+ _func="$_func
+ $1) echo \"\$2\" ;;
+ $1=*) echo \"\${1#$1=}\" ;;"
+ shift
+ done
+ _func="$_func esac; shift; done
+ }"
+ eval "$_func"
+ kdump_parse_args "$_arg" _func
+}
+
is_mounted()
{
findmnt -k -n "$1" > /dev/null 2>&1
@@ -55,13 +96,13 @@ is_fs_type_nfs()
# If $1 contains dracut_args "--mount", return <filesystem type>
get_dracut_args_fstype()
{
- echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f3
+ kdump_parse_get_arg "$1" "--mount" | awk '{print $3}'
}
# If $1 contains dracut_args "--mount", return <device>
get_dracut_args_target()
{
- echo $1 | grep "\-\-mount" | sed "s/.*--mount .\(.*\)/\1/" | cut -d' ' -f1
+ kdump_parse_get_arg "$1" "--mount" | awk '{print $1}'
}
get_save_path()
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 2e2775c9..3da9ac3b 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -411,21 +411,13 @@ get_ifcfg_filename()
echo -n "${ifcfg_file}"
}
-# returns 0 when omission of a module is desired in dracut_args
-# returns 1 otherwise
-is_dracut_mod_omitted()
-{
- local dracut_args dracut_mod=$1
-
- set -- $(kdump_get_conf_val dracut_args)
- while [ $# -gt 0 ]; do
- case $1 in
- -o | --omit)
- [[ " ${2//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0
- ;;
- esac
- shift
- done
+is_dracut_mod_omitted() {
+ local dracut_mod=$1 dracut_args omit_mod
+
+ dracut_args="$(kdump_get_conf_val dracut_args)"
+ omit_mod=$(kdump_parse_get_arg "$dracut_args" -o --omit)
+
+ [[ " ${omit_mod//[^[:alnum:]]/ } " == *" $dracut_mod "* ]] && return 0
return 1
}
@@ -448,7 +440,7 @@ is_wdt_active()
# its correctness).
is_mount_in_dracut_args()
{
- [[ " $(kdump_get_conf_val dracut_args)" =~ .*[[:space:]]--mount[=[:space:]].* ]]
+ [[ $(kdump_parse_get_arg "$(kdump_get_conf_val dracut_args)" --mount) ]]
}
check_crash_mem_reserved()
diff --git a/kdumpctl b/kdumpctl
index 59ec0688..16f6e81a 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -219,7 +219,7 @@ check_config()
case "$config_opt" in
dracut_args)
if [[ $config_val == *--mount* ]]; then
- if [[ $(echo "$config_val" | grep -o "\-\-mount" | wc -l) -ne 1 ]]; then
+ if [[ $(kdump_parse_get_arg "$config_val" "--mount") ]]; then
derror 'Multiple mount targets specified in one "dracut_args".'
return 1
fi
@@ -498,7 +498,7 @@ check_fs_modified()
# point and file system. If any of them mismatches then rebuild
if echo "$_dracut_args" | grep -q "\-\-mount"; then
# shellcheck disable=SC2046
- set -- $(echo "$_dracut_args" | awk -F "--mount '" '{print $2}' | cut -d' ' -f1,2,3)
+ set -- $(kdump_parse_get_arg "$_dracut_args" "--mount")
_old_dev=$1
_old_mntpoint=$2
_old_fstype=$3
diff --git a/mkdumprd b/mkdumprd
index c6cb0018..d02ef8c0 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -420,9 +420,7 @@ while read -r config_opt config_val; do
verify_core_collector "$config_val"
;;
dracut_args)
- while read -r dracut_arg; do
- add_dracut_arg "$dracut_arg"
- done <<< "$(echo "$config_val" | xargs -n 1 echo)"
+ kdump_parse_args "$config_val" add_dracut_arg
;;
*) ;;
--
2.31.1
2 years