Skip to content

Use awk instead of cut to extract the device field from $IP #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

lcharreau
Copy link
Contributor

Description:
This change replaces the use of cut -d: -f6 with awk -F: '{ print $6 }' when extracting the device/interface field from the $IP variable in the get_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 setting ip=none) because we handle network setup, including VLAN interface creation, in a custom init-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.

$> echo none | cut -d: -f6
none

Copy link
Collaborator

@sarroutbi sarroutbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @sergio-correia , can you PTAL when possible?

@sarroutbi sarroutbi merged commit 321fc34 into latchset:master Jul 10, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants