Just for fun: Rewriting e-mails on the fly with LLMs, AWK and OpenSMTPD

Based on a recent interaction with a friend, I jokingly said “Usually I’m negative towards people using AI to write their emails, but in your case it might be relevant to make an exception. Maybe you should have an SMTP filter that wraps your email with ‘could you write this in a kinder way?’, and send it to an LLM”.

Then I thought, hey, that sounds like a perfectly fine weekend project, just for fun!

Cleverio smart fjärrströmbrytare utan koppling till molnet

Jag köpte nyligen en Wi-Fi uppkopplad fjärrströmbrytare från Cleverio, som säljs av Kjell & Co, mer specifikt den här modellen.

Följer man de officiella instruktionerna får man tips om en app att använda för att styra och parkoppla strömbrytaren.

Efter lite nyfikenhet förstod jag att produkterna från Cleverio i själva verket är omprofilerade Tuya-enheter, vilket signifikant ökar möjligheterna för att hitta andra som undersökt produkterna närmare.

Jag har två mål:

  1. Kunna styra strömbrytaren utan appen, genom något form av API (gärna webbaserat och REST)
  2. Blockera strömbrytaren från att ansluta till Internet, men fortfarande fungera på det lokala nätverket.

(1) är framförallt för att jag vill kunna göra vad jag vill rent hemautomatiseringsmässigt, och (2) är framförallt av säkerhetsskäl då internetuppkopplade IoT-enheter sällan har särskilt bra säkerhet.

Cleverio Smart Plug without cloud or app

I recently bought a Wi-fi connected smart plug from Cleverio, sold by the Swedish company Kjell & Co.

If you follow the official instructions, you end up with an app on your phone, that you use to pair and control the plug with.

After some curious investigation, I found that the products from Cleverio are in practise just rebranded Tuya devices. This made me happy, since it significantly increases the number of resources available on the web from others who have investigated the products.

Podman credential helpers

I’ve started using podman on my new laptop. It has worked well so far, even with the rootless configuration.

However, I’ve never got it to save my credentials to Docker Hub, which has been annoying. I’ve had to do a podman login after every reboot. Not very convenient. The man page gave a way to store the credentials in clear text on disk, but that didn’t feel very nice from a security perspective.

WireGuard split tunnel with systemd-networkd

On most laptops I use wg-quick to setup my WireGuard tunnels, but recently I got a bit curious about using systemd-networkd to the the same.

In particular I want the same split-tunnel setup that I’ve used before to work also with systemd-networkd.

Worth noticing is that the setup I describe here will automatically start the tunnel when launching the computer. I haven’t really investigated if it is possible to do it on demand. Edit 2024-04-19: It is possible, thanks for some great feedback from axel

Shebang Shenanigans

You have probably all seen the shebang at top of shell scripts, the first line starting with #!/bin/sh.

The initial characters #! tells the OS that this isn’t a regular binary, but rather something that needs to run through an interpreter, namely the interpreter after #!. Therefore you can see lines like #!/usr/bin/perl, #!/usr/bin/awk, or #!/usr/bin/python.

Executing a file like ./test.sh, having the shebang #!/bin/sh, is similar to calling this command: /bin/sh ./test.sh.

gRPC between Rust and Node.js

I recently wanted to rewrite parts of an existing Node.js application in Rust. A complete rewrite would take a lot of time, so I was browsing through ways to rewrite some parts in Rust.

While it seems possible to call Rust from Node by compiling Rust into a Node js module using FFI, it felt a bit messy.

Instead I opted to look into gRPC, which I’ve been wanting to look into anyway. In this example, I have written a small function in both Node.js and Rust. It can be called using gRPC from either Node.js or Rust.

Yubikey TLS Client Certificate in Firefox on Arch Linux

In this post I’ll use a Yubikey, running the PIV application, to store a keypair and certificate to be used for mutual TLS. The Yubikey will generate the private key on the device, and the private key will never leave the device. Nice for security!

I’ll also configure Firefox to discover the certificate stored on the device, so it can be used when browsing to a site requiring a client certificate.

Split tunnel VPN with Wireguard between OpenBSD and Arch Linux

I’ve traditionally used only SSH to connect to my home network while being away, but recently I got tired of using only SSH tunnels and SOCKS proxies, and decided to actually fix a working Wireguard configuration.

My router is running OpenBSD, and I want Wireguard clients to be able to reach several different internal subnets. However, I don’t want to route all traffic through the VPN tunnel, only traffic to my internal network. In addition, also want all DNS traffic to use my internal DNS server. This is required since I otherwise won’t be able to find the internal hosts by their domain name.

Automatically run script when USB drive is inserted

My goal here is to automatically launch a script when a certain USB stick is connected to the system. When plugging in the stick, the partition should be automatically mounted, a script should be executed, and some notifications should be shown on the screen.

Identifying and automounting the drive

My USB stick is a simple FAT32 drive, so to identify it I set a filesystem label. This allows me to distinguish this drive from other ones. I set the label to DOXIE.