Skip to contentSkip to conversation

network: fix handling of AlwaysRandomizeAddress/AddressOverride

PATCH Applied James Prestwood 2 participants 2 messages Jun 3, 2022

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH 1/1 network: fix handling of AlwaysRandomizeAddress/AddressOverride

For network configuration files the man pages (iwd.network) state that [General].{AlwaysRandomizeAddress,AddressOverride} are only used if main.conf has [General].AddressRandomization=network.

This actually was not being enforced and both iwd.network settings were still taken into account regardless of what AddressRandomization was set to (even disabled).

The handshake setup code now checks the AddressRandomization value and if anything other than 'network' skips the randomization.

---
 src/network.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
src/network.c +11 -0
index 7bc97121..70cb925c 100644
@@ -485,10 +485,12 @@ int network_handshake_setup(struct network *network, struct scan_bss *bss,
 	struct station *station = network->station;
 	struct wiphy *wiphy = station_get_wiphy(station);
 	struct l_settings *settings = network->settings;
+	const struct l_settings *config = iwd_get_config();
 	struct network_info *info = network->info;
 	uint32_t eapol_proto_version;
 	uint8_t new_addr[ETH_ALEN];
 	int r;
+	const char *str;
 
 	switch (network->security) {
 	case SECURITY_PSK:
@@ -523,6 +525,15 @@ int network_handshake_setup(struct network *network, struct scan_bss *bss,
 		handshake_state_set_protocol_version(hs, eapol_proto_version);
 	}
 
+	/*
+	 * The randomization options in the provisioning file are dependent on
+	 * main.conf: [General].AddressRandomization=network. Any other value
+	 * should disqualify the three network-specific settings below.
+	 */
+	str = l_settings_get_value(config, "General", "AddressRandomization");
+	if (!(str && !strcmp(str, "network")))
+		return 0;
+
 	/*
 	 * We have three possible options here:
 	 * 1. per-network MAC generation (default, no option in network config)
Signature · 1 line
2.34.1
Applied
#1 lore raw

Hi James,

Quoted 8 lines · James Prestwood

For network configuration files the man pages (iwd.network) state that [General].{AlwaysRandomizeAddress,AddressOverride} are only used if main.conf has [General].AddressRandomization=network.

This actually was not being enforced and both iwd.network settings were still taken into account regardless of what AddressRandomization was set to (even disabled).

Quoted 6 lines

The handshake setup code now checks the AddressRandomization value and if anything other than 'network' skips the randomization.

---
  src/network.c | 11 +++++++++++
  1 file changed, 11 insertions(+)

Applied, thanks.

Regards,
-Denis