mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
Merge pull request #28245 from rpigott/dhcp6-relax-assert
relax data assert in dchp6_option_parse_string
This commit is contained in:
commit
d979b39811
@ -529,7 +529,7 @@ int dhcp6_option_parse_string(const uint8_t *data, size_t data_len, char **ret)
|
||||
_cleanup_free_ char *string = NULL;
|
||||
int r;
|
||||
|
||||
assert(data);
|
||||
assert(data || data_len == 0);
|
||||
assert(ret);
|
||||
|
||||
if (data_len <= 0) {
|
||||
|
@ -5202,6 +5202,44 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
|
||||
check(self, False, True)
|
||||
check(self, False, False)
|
||||
|
||||
def test_dhcp_client_reject_captive_portal(self):
|
||||
def check(self, ipv4, ipv6):
|
||||
os.makedirs(os.path.join(network_unit_dir, '25-dhcp-client.network.d'), exist_ok=True)
|
||||
with open(os.path.join(network_unit_dir, '25-dhcp-client.network.d/override.conf'), mode='w', encoding='utf-8') as f:
|
||||
f.write('[DHCPv4]\nUseCaptivePortal=')
|
||||
f.write('yes' if ipv4 else 'no')
|
||||
f.write('\n[DHCPv6]\nUseCaptivePortal=')
|
||||
f.write('yes' if ipv6 else 'no')
|
||||
f.write('\n[IPv6AcceptRA]\nUseCaptivePortal=no')
|
||||
|
||||
networkctl_reload()
|
||||
self.wait_online(['veth99:routable'])
|
||||
|
||||
# link becomes 'routable' when at least one protocol provide an valid address. Hence, we need to explicitly wait for both addresses.
|
||||
self.wait_address('veth99', r'inet 192.168.5.[0-9]*/24 metric 1024 brd 192.168.5.255 scope global dynamic', ipv='-4')
|
||||
self.wait_address('veth99', r'inet6 2600::[0-9a-f]*/128 scope global (dynamic noprefixroute|noprefixroute dynamic)', ipv='-6')
|
||||
|
||||
output = check_output(*networkctl_cmd, 'status', 'veth99', env=env)
|
||||
print(output)
|
||||
self.assertNotIn('Captive Portal: ', output)
|
||||
self.assertNotIn('invalid/url', output)
|
||||
|
||||
# TODO: check json string
|
||||
check_output(*networkctl_cmd, '--json=short', 'status', env=env)
|
||||
|
||||
copy_network_unit('25-veth.netdev', '25-dhcp-server-veth-peer.network', '25-dhcp-client.network', copy_dropins=False)
|
||||
|
||||
start_networkd()
|
||||
self.wait_online(['veth-peer:carrier'])
|
||||
masq = lambda bs: ':'.join(f'{b:02x}' for b in bs)
|
||||
start_dnsmasq('--dhcp-option=114,' + masq(b'http://\x00invalid/url'),
|
||||
'--dhcp-option=option6:103,' + masq(b'http://\x00/invalid/url'))
|
||||
|
||||
check(self, True, True)
|
||||
check(self, True, False)
|
||||
check(self, False, True)
|
||||
check(self, False, False)
|
||||
|
||||
class NetworkdDHCPPDTests(unittest.TestCase, Utilities):
|
||||
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user