- and store it in a secure location for hostapd
- we could auto-generate this
- hostapd doesn’t seem to have any way to put the secret in a different file
- add options for setting certificate options, e.g. name
- auto-generate certificates
- store them in /var/lib/freeradius ? -> probably not; where are the SSH private keys? -> /etc/ssh
- similar to the script for task server
- also generate pfx file for android:
- openssl pkcs12 -export -in [email protected] -out [email protected] -passin pass:x -passout pass:x
- Can we use the .p12 file? -> yes, but ca file needs .crt extension
-> workaround: force user name to match certificate
- radius group must have access and the user cannot do that before the group exists
- We can copy the file to the statedir - on start and reload.
- We cannot easily add this for reload so let the user do it - that way, she knows about the imperfections.
- In particular: If client certificates are also signed by the CA - what stops them from impersonating the server? Clients can check the common name but the default is to not do that.
- I think the type of the certificate is different - the config file either has [client] or [server].
- From the generated certificate files (02.pem vs. 05.pem):
X509v3 extensions:
X509v3 Extended Key Usage:
- TLS Web Server Authentication
- TLS Web Client Authentication
- I cannot set this while the interface is already active and we have to enable WDS mode if we want to use it.
- http://lists.infradead.org/pipermail/hostap/2016-May/035670.html
- https://wireless.wiki.kernel.org/en/users/documentation/iw#setting_up_a_wds_peer
- Ok, this is complicated and I have no use for it right now.
- I will remove the option, for now.
- https://jamielinux.com/docs/openssl-certificate-authority/certificate-revocation-lists.html
- https://wiki.alpinelinux.org/wiki/FreeRadius_EAP-TLS_configuration
- works as expected: revoked certificate cannot be used anymore
- We can only revoke a certificate if we still have the file; but OpenSSL is keeping them anyway.
- Well, ok, not quite - it doesn’t work for my second test.
- What do we have to do for a revocation to become active?
- https://community.openvpn.net/openvpn/ticket/623?__cf_chl_jschl_tk__=d2ab2ea022d2991016710bf0cc28a6547e099963-1587268160-0-ASGtk8kPjK3AQmHGs7B2azUY6sRsncqiEn39xwJnZ_p9zICeLTpTcgd8MUZluBOIWh1oc9OaPLNo04TGYt8-7ueWqKQ4FKyMBduBHfbx31Yp225pR82-7w_pufFbSyQP7d_OyFPF5FKSJwqtE2L8qJf0MIJihyFmIPW3Y22UE_oprWU3X7CLsQQwYodtNPcJSReYSe823udBoMmr9Nclh8EMdB9ET-i0c6LjNwxe0jA_xgNF7cy9jclfMhaepsYQwPLXgt5rpZyr_Ze0cWZp-6z2KmfYfIUjkvNJGSBi0pZR
- This confirms my suspicion: Revocation is active after a restart but reload doesn’t help.
- It does work if we increment the index in the filename.
- This command is suggested in the example config: find ${logdir}/tlscache -mtime +2 -exec rm -f {} \;
- option 1: copy services.wifi-ap-eap.hostapd to services.hostapd if enabled
- option 2: don’t enable services.hostapd; copy the relevant parts to our .nix files
- Systemd has the very annoying feature that it ignores unknown keys in config files. I get why they do this and this can often be useful for backward compatible unit files. However, it often masks errors in the files. The infamous example is “User = 0day”.
- I just learned that there is a command to check unit files. It can be applied to all of them like that: find -L /etc/systemd/{system,user} -type f ! -name “*.conf” -exec systemd-analyze verify {} \+
- There are some false positives:
- emergency.service tries to start plymouth but errors are masked with “-“.
- Lots of man pages don’t exist. We probably don’t care, i.e. having the reference in the unit file is still useful even if we don’t install that man page.
- Furthermore, we usually want to check a config before applying it and we need to do so in the right context, e.g. don’t complain that “foo” cannot be started if it is present in the new system but not the old one.
- There remaining errors are: systemd-journal-gatewayd.socket: Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, …). Refusing. Unit systemd-journal-gatewayd.socket has a bad unit file setting. -> mostly empty, should probably be missing alltogether [email protected]: Failed to create [email protected]/start: Unit i.mount not found. -> I don’t think this is ever referenced with instance=”i” but systemd mis-interprets the empty instance name and checks “Before=i.mount” instead of “Before=%i.mount”. syslog.socket: Service syslog.service not loaded, syslog.socket cannot be started. -> I think the socket shouldn’t exist if the service is not active. -> The service is gated by services.rsyslogd.enable. The socket is always part of upstreamSystemUnits in systemd.nix.
- find -L result/etc/systemd/{system,user} -type f ! -name ”.conf” ! -name “*@.” -exec systemd-analyze verify {} \+ 2>&1|grep -v man
- Point in case for using a chroot/mount namespace: I had tested my script with three result links. The first one had a correct hostapd.service, the second one had the bug and the third one was an old one without hostapd. The script was correct for the first two but it was reporting the error for the third one - presumably because it was also looking at files of my current system.
- I have looked through lots of .nix files and I still don’t know how to do that…
- Can we at least do this for the wifi? -> I don’t know
- https://wiki.freeradius.org/guide/eduroam
- This says that hostapd should send requests to the default virtual host, which forwards to the eap module, which in turn forwards to inner-tunnel if necessary (e.g. for TTLS).
- I should try that.
- The default site is already enabled so I only have to change the port.
- I think that should also get rid of the error message that was logged for rejected auth.
- https://wireless.wiki.kernel.org/en/users/documentation/hostapd
- https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
- hw_mode only enables b/g/a. We need ieee80211n and probably ht_capab.
- My card doesn’t support much of ht_capab according to `iw list`.
- The example has `wme_enabled=1` which should be “Wireless Multimedia Extensions”. The example hostapd.conf has `wmm_enabled=1` which is probably the same thing. `wme_enabled=1` seems to work - at least it doesn’t cause any error.
- “20/40 MHz operation not permitted on channel pri=7 sec=11 based on overlapping BSSes”
- Fixed by `ht_capab=[HT40-]` because the other SSIDs are on higher channels.
- That makes it much slower: 0-4 Mbit instead of 70/30 Mbit for https://beta.speedtest.net/
- iperf 2, median of 3 measurements, 1-2m distance:
settings laptop -> ap ap -> laptop g, no n 24 25.5 ieee80211n=1 69 Mbit, 84 62 Mbit, 85 ht40- 2, 0.07, 16 10, 0.8, 2 ht20- 91 86 ht20+ 92 87 ht20-, wme=1 91 87 ht20-, wmm=1 91 87 ch=1, ht40+, wmm 10.5 3 ht20-, w/ usb cable 9 10 w/o cable again 52 28
- `nix-shell -p openssl` has all of TEMPDIR, TEMP, TMPDIR, TMP set to /run/user/0.
- A normal shell doesn’t have that. `mktemp` creates files in /tmp.
- That difference means that emacsclient won’t work in nix-shell because it tries to connect to the wrong socket.
- How do we add additional attributes when using certificates? Can we do that in the users file anyway?
- What do we have to do to make VLANs work? Can we do something other than VLANs, e.g. bridge some users to ethernet and others to a private bridge for VMs?
- This is how to apply additional attributes with SQL: https://wiki.freeradius.org/modules/Rlm_sql https://linuskarlsson.se/blog/radius-authentication-and-dynamic-vlan-assignment-for-wpa2-enterprise-using-sqlite-in-freeradius/
- We should be able to do this in /etc/wifi-ap-eap/users, though.
- Test it: Make a service that is only accessible from a certain VLAN/interface.
- socat TCP-LISTEN:1235,fork EXEC:”echo blub”
- #iptables -I INPUT -i wifiap.2 -p tcp –dport 1235 -j ACCEPT –> will not work because packets come from br0
- ebtables -I INPUT –in-if wifiap.2 -j mark –set-mark 2 –mark-target CONTINUE
- iptables -I INPUT -i br0 -p tcp –dport 1235 -m mark –mark 2/2 -j ACCEPT
- nc 192.168.1.23 1235
- I could also try using the sqlite database for that. This might come in handy if I ever make a tool to
interface with the database, e.g. the admin can assign groups and VLANs in a web UI.
- insert into radusergroup(‘username’, ‘groupname’) values (‘test1’, ‘testgroup’);
- insert into radgroupreply(‘groupname’, ‘attribute’, ‘op’, ‘value’) values (‘testgroup’, ‘Tunnel-Type’, ‘:=’, ‘13’), (‘testgroup’, ‘Tunnel-Medium-Type’, ‘:=’, ‘6’), (‘testgroup’, ‘Tunnel-Private-Group-ID’, ‘:=’, ‘“42”’);
- nixos-wifi-ap-eap client test test1.zip
- That is looking good. SQL seems to win over the users file.
- tcpdump -i wifiap.42 icmp
- on the wifi station: ping example.com
- One might want explicit entries for some of the VLANs in the vlan_file: Otherwise, hostapd will remove the interfaces if no client is using it anymore and that may be annoying, e.g. an active tcpdump on that interface will be aborted.
- https://git.c3pb.de/snowball/nixos-config-for-routeromen/-/tree/master/wifi-ap-eap
- bandwidth per day/hour; total and per device/user
- Access control: Listen on Unix socket and use SSH forward?
- XDG_RUNTIME_DIR=/run/user/$UID nix-shell -E ‘let p = import <nixpkgs> {}; in p.stdenv.mkDerivation {name=”a”; buildInputs=[(p.python3.withPackages (p: [p.cherrypy]))];}’
- add lorri config to TPM dir with packages: tpm2-tools python3
- lorri doesn’t seem to support anything akin to `direnv allow` for its shell.nix.
- This cannot be true, can it?
- I don’t see anything in the README nor any issues about this.
- This thread is interesting:
- https://discourse.nixos.org/t/introducing-lorri-your-projects-nix-env/2560
- Potential alternative to lorri: https://github.com/direnv/direnv/wiki/Nix#persistent-cached-shell-direnv–2182
- Use nixpkgs of current system rather than <nixpkgs>: https://discourse.nixos.org/t/introducing-lorri-your-projects-nix-env/2560/7
- There is already `use nix -p …` in normal direnv but I guess this doesn’t do async build in the background and it doesn’t add gcroots.
- Other problems with lorri:
- The user service doesn’t start as root.
- Error: `ERRO Bind error: Io(Os { code: 30, kind: Other, message: “Read-only file system” })`
- This may be due to `ProtectHome=read-only` in the service file but it does work for other users.
- The default `.direnv` file should print a useful message if lorri is not available, e.g. a link to the repository.
- The user service doesn’t start as root.
- legy recommends: Make a default.nix that builds the .envrc and run it like this: `nix build -f . –out-link .envrc`
- Unfortunately, he doesn’t have any code available in a public repo.
- That way, nix-build will add the gcroot and the usual `direnv allow` mechanism will work.
- //However, this also means that we won’t be able to notify the user about updates. –> see below
- I probably want to use mkShell but that won’t work out-of-the-box. The source is here: /nix/var/nix/profiles/per-user/root/channels/nixos/pkgs/build-support/mkshell/default.nix
- I think, I can make a shell.nix that modifies the build phase of mkShell to generate the envrc.
- So, let’s try this:
- Make a shell.nix with pkgs.mkShell but modify the build phase to generate an envrc.
- We can probably generate the envrc by `direnv export` if this does the right thing for PATH.
- Add options for setting additional variables.
- Add some code to the envrc that adds a watch on shell.nix and prints a message if the file is newer than what was used to build that envrc - if we can do that.
- How does lorri track dependencies?
- https://github.com/target/lorri/blob/master/src/builder.rs#L49
- https://github.com/target/lorri/blob/master/src/logged-evaluation.nix#L10
- scopedImport: https://github.com/NixOS/nix/commit/c273c15cb13bb86420dda1e5341a4e19517532b5
- How the paths are reduced: https://github.com/target/lorri, “Evaluator + watch design”
- Simpler: nix-build shell.nix -o test -vv 2>&1|sed -En “s/^(copied source|evaluating file) ‘(.*)’($| -> .*)/\2/p”|grep -v ‘^/nix/store/’
- However, this doesn’t see the reference to the channel at all.
- Lorri does seem to watch the right paths.
- “nix-instantiate” “-vv” “–add-root” ”run/user/1001.tmpfG7VVa/result” “–indirect” “–argstr” “runTimeClosure” ”nix/store/3ly3k012pnba0nh7bpwvk3rdw92yaf6w-runtime-closure.nix” “–argstr” “src” “/home/test/lorritest/x/shell.nix” “–” “/home/test.cache/lorri/cas/3a83fbad2f114b4f4f431db2014c985c”
- The scopedImport is enough to make it work - all the other stuff doesn’t seem to be required.
- direnv seems to use lstat and stat (preferring the one with newer mtime) so we can use it with the channel symlink without recursively watching the directory. This is good. https://github.com/direnv/direnv/blob/219d9f7674fa40699eacaafc21c67d1fc3ba9b70/file_times.go#L120 https://github.com/direnv/direnv/blob/219d9f7674fa40699eacaafc21c67d1fc3ba9b70/file_times.go#L167
- FIXME: My current method of running $stdenv/setup in the .envrc does not work.
- I think, I should probably use lorri’s helper files.
- Also rename “path-only” to “simple” and use `old` value passend to `override` to get additional variables.
- FIXME: Actually do something with the watched files.
- Put them in Nix store or next to the .envrc.
- The .envrc should add them to direnv watch and notify the user if they have changed.
- This seems to be implemented for lots of frameworks. If we have this for all of them, this may be useful as a more complete example.
- Ich hatte die percy und dodrio angeschaut, weil die sahen am besten aus, von denen, über die ich bei Youtube gestolpert war.
- Dieser Vergleich sieht so aus, als wären die vielleicht nicht die beste Wahl: https://awesomeopensource.com/project/flosse/rust-web-framework-comparison#frontend-frameworks
- Zumindest draco und yew sollte ich mir wohl mal ansehen.
- Wenn ich was brauche statt chart.js: https://lib.rs/visualization https://lib.rs/crates/plotters https://lib.rs/crates/plotchart
- https://github.com/ThoughtWorksInc/Binding.scala
- https://github.com/ThoughtWorksInc/todo/blob/master/js/src/main/scala/com/thoughtworks/todo/Main.scala
- https://www.scala-js.org/doc/tutorial/basic/index.html
- espressif/esp-idf#1297
- SHA1, 2048 bit
- probably fixed: https://github.com/espressif/esp-idf/commit/bc97b0f380210b97b7fd98c5f304af7e83c28b7f
- We are using SHA256 and 2048 bit. This should work with the fix for SHA256.
- services.udev.extraRules = ”KERNEL==”eth*”, ATTR{address}==”xx:yy:..”, NAME=”ethX””;
- alternative that didn’t work for queezle: systemd.network.links.eth.{matchConfig,linkConfig}