NetworkConfiguration / dhcpcd

DHCP / IPv4LL / IPv6RA / DHCPv6 client.
https://roy.marples.name/projects/dhcpcd
BSD 2-Clause "Simplified" License
344 stars 111 forks source link

stdin lease is not read, current lease is read instead #391

Open ColinMcInnes opened 1 day ago

ColinMcInnes commented 1 day ago

Cannot use STDIN to load an older copy of the lease to decode it. It only fetches current lease. dhcpcd 10.0.10, linux dhcpcd is currently running in managed mode

PRIVSEP is enabled.

entra-rpd-9059945:/home/tier3support# dhcpcd -4 eth0
dhcpcd-10.0.10 starting
...
eth0: soliciting a DHCP lease
eth0: offered 192.168.228.153 from 192.168.228.21
eth0: probing address 192.168.228.153/24
eth0: leased 192.168.228.153 for 259200 seconds
eth0: adding route to 192.168.228.0/24
eth0: adding default route via 192.168.228.2

# dhcpcd  -4 eth0 -U
reason=BOUND
interface=eth0
protocol=dhcp
ip_address=192.168.228.153
subnet_cidr=24
broadcast_address=192.168.228.255
network_number=192.168.228.0
subnet_mask=255.255.255.0
routers=192.168.228.2
dhcp_lease_time=259200
dhcp_message_type=5
dhcp_server_identifier=192.168.228.21

# cp /var/lib/dhcpcd/eth0.lease /var/lib/dhcpcd/eth0.lease.backup

# dhcpcd -4 eth0 --rebind
sending signal HUP to pid 20300

# dhcpcd -4 eth0 -U
reason=RENEW
interface=eth0
protocol=dhcp
ip_address=192.168.228.153
subnet_cidr=24
broadcast_address=192.168.228.255
network_number=192.168.228.0
subnet_mask=255.255.255.0
routers=192.168.228.2
dhcp_lease_time=259200
dhcp_message_type=5
dhcp_server_identifier=192.168.228.21

# dhcpcd -4 eth0 -U < /var/lib/dhcpcd/eth0.lease
reason=RENEW
interface=eth0
protocol=dhcp
ip_address=192.168.228.153
subnet_cidr=24
broadcast_address=192.168.228.255
network_number=192.168.228.0
subnet_mask=255.255.255.0
routers=192.168.228.2
dhcp_lease_time=259200
dhcp_message_type=5
dhcp_server_identifier=192.168.228.21

# dhcpcd -4 eth0 -U < /var/lib/dhcpcd/eth0.lease.backup 
reason=RENEW
interface=eth0
protocol=dhcp
ip_address=192.168.228.153
subnet_cidr=24
broadcast_address=192.168.228.255
network_number=192.168.228.0
subnet_mask=255.255.255.0
routers=192.168.228.2
dhcp_lease_time=259200
dhcp_message_type=5
dhcp_server_identifier=192.168.228.21
ColinMcInnes commented 16 hours ago

traced to read_lease, we check if the lease file name is populated, as opposed to existing. dhcp_init will always set this up.

recommend changing the behaviour to check if stdin has been redirected to a file, and if so, dumplease can use that as the source.