Skip to content

initrd: fix parsing of ip= arguments with empty first token

Beniamino Galvani requested to merge bg/initrd-ip-empty-rh1900260 into master

The parser checks if the first token of an ip= argument is an IP address to determine which of the two possible syntaxes is used:

 ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
 ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<mtu>][:<macaddr>]]

This works as long as the first token is not empty, which - according to the dracut.cmdline man page - seems to be guaranteed.

However, the network-legacy dracut plugin accepts an empty interface or client IP. Also, if a user needs DHCP and wants to specify a hostname, the only possible syntax is:

 ip=::::<hostname>::dhcp

Change the parser to check the second token instead, similarly to what the network-legacy module does.

https://bugzilla.redhat.com/show_bug.cgi?id=1900260

Merge request reports