All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj at gmail.com>
To: iwd at lists.01.org
Subject: [PATCH] network: fix handling of AlwaysRandomizeAddress/AddressOverride
Date: Fri, 03 Jun 2022 13:54:27 -0700	[thread overview]
Message-ID: <20220603205427.216954-1-prestwoj@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1864 bytes --]

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(+)

diff --git a/src/network.c b/src/network.c
index 7bc97121..70cb925c 100644
--- a/src/network.c
+++ b/src/network.c
@@ -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)
-- 
2.34.1

             reply	other threads:[~2022-06-03 20:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 20:54 James Prestwood [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-06-03 20:53 [PATCH] network: fix handling of AlwaysRandomizeAddress/AddressOverride Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220603205427.216954-1-prestwoj@gmail.com \
    --to=unknown@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.