Use awk instead of cut to extract the device field from $IP #523
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This change replaces the use of
cut -d: -f6
withawk -F: '{ print $6 }'
when extracting the device/interface field from the$IP
variable in theget_specified_device()
function.Reason:
The issue with using
cut -d: -f6
is that if the$IP
variable does not contain any:
separator,cut
returns the entire value of$IP
instead of an empty string. This can cause Clevis to incorrectly interpret the whole$IP
value as an interface name and wait for it to appear, which is not the intended behavior.Our Use Case
We need to disable network configuration in the initramfs via
GRUB_CMDLINE_LINUX
(by settingip=none
) because we handle network setup, including VLAN interface creation, in a custominit-premount
script within the initramfs. This approach is required since the standard initramfs network configuration does not support our VLAN setup.However, when we set
GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX ip=none"
, Clevis incorrectly tries to wait for an interface named "none" to appear, which is not the intended behavior. The goal is to prevent initramfs from configuring the network so that our script can do it properly for VLANs, but Clevis should not interpret "none" as an actual interface name.