Fix iwd space handling
ref man iwd.network: > Key-value lines contain a setting key, an equal sign and the value of > the setting. Whitespace preceding the key, the equal sign or the value, > is ignored. The key must be a continuous string of alphanumeric and > underscore characters and minus signs only. The value starts at the > first non-whitespace character after the first equal sign on the line > and ends at the end of the line and must be correctly UTF-8-encoded. > […] > String values, including file > paths and hexstrings, are written as is except for five characters that > may be backslash-escaped: space, \t, \r, \n and backslash itself. > The latter three must be escaped. A space character must be escaped if > it is the first character in the value string and is written as \s. I guess this is what is expected then: ``` $ echo -e " \t \r \\ " \ $ echo -e " \t \r \\ " | sed "s=\\\=\\\\\\\=g;s=\t=\\\t=g;s=\r=\\\r=g;s=^ =\\\s=" \s \t \r \\ ```
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ lib, config, ... }:
|
||||
{ lib, config, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.clan.iwd;
|
||||
@@ -12,12 +12,13 @@ let
|
||||
{
|
||||
secret.${secret_name} = { };
|
||||
generator.prompt = "Wifi password for '${value.ssid}'";
|
||||
# ref. man iwd.network
|
||||
generator.script = ''
|
||||
config="
|
||||
[Settings]
|
||||
AutoConnect=${if value.AutoConnect then "true" else "false"}
|
||||
[Security]
|
||||
Passphrase=\"$prompt_value\"
|
||||
Passphrase=$(echo -e "$prompt_value" | ${lib.getExe pkgs.gnused} "s=\\\=\\\\\\\=g;s=\t=\\\t=g;s=\r=\\\r=g;s=^ =\\\s=")
|
||||
"
|
||||
echo "$config" > "$secrets/${secret_name}"
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user