d8d2b3a338
On NixOS[1] - a Linux distribution which allows to configure a full OS
declaratively - it's possible to configure SSIDs for `wpa_supplicant`
like this:
networking.wireless.networks = {
myssid = {
pskRaw = "<redacted>";
};
};
It's also possible to add networks "imperatively" using `wpa_gui` or
`wpa_cli`. However it's not possible to do both because if the first
option is used, NixOS creates a read-only symlink at
`/etc/wpa_supplicant.conf` and then it's not possible for
`wpa_supplicant` anymore to write to it.
This patch aims to help us changing this: while "declarative" SSID
configuration can be quite useful, it's a bad idea for e.g. sensitive
stuff like a WPA2 enterprise network.
The original idea was to use `-I`[2] for immutable configs (including
"declarative" networks) on NixOS and `-c /etc/wpa_supplicant.conf` for
anything "imperative".
However this doesn't really work out because if a wifi network from a
config file specified with `-I` is changed by e.g. `wpa_gui`, it's
silently overwritten in `/etc/wpa_supplicant.conf` (specified with
`-c`) which is IMHO unintuitive (in our case at least). This patch
basically declares each network defined in a config file passed via `-I`
to `wpa_supplicant` as "read-only" and doesn't write these "read-only"
networks to `/etc/wpa_supplicant.conf`.
A bit more context can be found on GitHub in the PR where I implemented
this[3].
[1] https://nixos.org/
[2] Added in e6304cad47
[3] https://github.com/NixOS/nixpkgs/pull/113716
Signed-off-by: Maximilian Bosch <maximilian@mbosch.me>
57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
/*
|
|
* WPA Supplicant / Configuration backend: empty starting point
|
|
* Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
|
|
*
|
|
* This software may be distributed under the terms of the BSD license.
|
|
* See README for more details.
|
|
*
|
|
* This file implements stub example of a configuration backend. None of the
|
|
* functions are actually implemented so this can be used as a simple
|
|
* compilation test or a starting point for a new configuration backend.
|
|
*/
|
|
|
|
#include "includes.h"
|
|
|
|
#include "common.h"
|
|
#include "config.h"
|
|
#include "base64.h"
|
|
|
|
|
|
struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp,
|
|
bool ro)
|
|
{
|
|
struct wpa_config *config;
|
|
|
|
if (name == NULL)
|
|
return NULL;
|
|
if (cfgp)
|
|
config = cfgp;
|
|
else
|
|
config = wpa_config_alloc_empty(NULL, NULL);
|
|
if (config == NULL)
|
|
return NULL;
|
|
/* TODO: fill in configuration data */
|
|
return config;
|
|
}
|
|
|
|
|
|
int wpa_config_write(const char *name, struct wpa_config *config)
|
|
{
|
|
struct wpa_ssid *ssid;
|
|
struct wpa_config_blob *blob;
|
|
|
|
wpa_printf(MSG_DEBUG, "Writing configuration file '%s'", name);
|
|
|
|
/* TODO: write global config parameters */
|
|
|
|
|
|
for (ssid = config->ssid; ssid; ssid = ssid->next) {
|
|
/* TODO: write networks */
|
|
}
|
|
|
|
for (blob = config->blobs; blob; blob = blob->next) {
|
|
/* TODO: write blobs */
|
|
}
|
|
|
|
return 0;
|
|
}
|