z3bra.org phlog Proudly powered by smtpd(1) gopher://phlog.z3bra.org/h/atom.xml 2025-10-25T06:08:00+02:00 <![CDATA[BitTorrent specification v2]]> gopher://phlog.z3bra.org/0/bittorrent-specification-v2.txt 2020-09-08T21:22:00+02:00 wgs <![CDATA[Broader protocol support for TWTXT]]> gopher://phlog.z3bra.org/0/broader-protocol-support-for-twtxt.txt 2020-10-21T22:49:00+02:00 wgs <![CDATA[BSD make and built-in rules]]> gopher://phlog.z3bra.org/0/bsd-make-and-builtin-rules.txt 2020-09-09T18:44:00+02:00 wgs <![CDATA[Configuration management]]> gopher://phlog.z3bra.org/0/configuration-management.txt 2020-08-24T11:32:00+02:00 wgs <![CDATA[CREAM header for encrypted streams]]> gopher://phlog.z3bra.org/0/cream-header-for-encrypted-streams.txt 2022-10-24T14:15:00+02:00 wgs <![CDATA[Debugging DNS propagation]]> gopher://phlog.z3bra.org/0/debugging-dns-propagation.txt 2020-09-19T15:20:00+02:00 wgs <![CDATA[Email blogging with scribo(1)]]> gopher://phlog.z3bra.org/0/email-blogging-with-scribo1.txt 2020-09-08T15:44:00+02:00 wgs <![CDATA[Gopher text rendering ideas]]> gopher://phlog.z3bra.org/0/gopher-text-rendering-ideas.txt 2020-09-23T17:22:00+02:00 wgs <![CDATA[Happy time_t party!]]> gopher://phlog.z3bra.org/0/happy-timet-party.txt 2020-09-13T12:26:00+02:00 wgs <![CDATA[IDEA: multipart/mixed support for scribo]]> gopher://phlog.z3bra.org/0/idea-multipartmixed-support-for-scribo.txt 2020-10-06T17:42:00+02:00 wgs <![CDATA[I'm on Lemmy now!]]> gopher://phlog.z3bra.org/0/im-on-lemmy-now.txt 2023-07-05T21:38:00+02:00 wgs <![CDATA[KVM switches for the desktop]]> gopher://phlog.z3bra.org/0/kvm-switches-for-the-desktop.txt 2020-12-16T04:50:00+01:00 wgs <![CDATA[My love-hate relationship with Wayland]]> gopher://phlog.z3bra.org/0/my-love-hate-relationship-with-wayland.txt 2020-11-06T17:28:00+01:00 wgs <![CDATA[My top 10 commands]]> gopher://phlog.z3bra.org/0/my-top-10-commands.txt 2020-10-27T23:36:00+01:00 wgs », immediately followed by « L » to clear the screen, so I can run « LL » again. 3. make Now this is getting interesting ! Do I do this much C programming that I use « make » so often ? Actually no. I use « make » for another purpose: server configuration. I own multiple servers online, and configure them with drist [0], which is similar to ansible. To simplify the configuration deployment, I use a Makefile, so I just need to type « make » to reconfigure a server. Everytime I change a config file, add a DNS name, or username, I run « make » to apply my changes, which is why I run it so often. I also build a lot of C programs too, but configuration management is certainly my main usage these days. 4. cd There is one thing that frustrate me when I look at other people using a terminal : cd /var cd log less messages When people do that, I want to take the keyboard away from them, and beat them up with it !! Ok I'm weird. But seriously, I hate monkeying around in my filesystem. If I want to read the logs, I'll just less /var/log/messages It works, it's elegant, it makes « cd » only appear 4th in you command history rather than first 😉 5. git Well, I didn't know I used git that much. It shouldn't surprise me though, because I constantly search new cool projects to try, and git clone them. Another big use I have for git, is updating my port tree, as I run the crux distro [1], with a lot of git based ports. 6. pwd I get lost quite often in all these gigabytes ! 7. fg (and its friend ^Z) This is certainly the most idiomatic command of my programming workflow. I mostly write shell scripts and C programs, which I test/build manually at the shell prompt. I could use a terminal multiplexer, but I like having a single place to focus my attention on. A typical programming session would look like this: v file.c # see command number 1 ^Z make [...] outpout omitted fg ^Z make ./file git add file.c; git commit -m "WOW it works !" fg man 3 gethostbyname ^Z fg %1 ^Z fg %2 ... I put my editor to the foreground all the time. Even though it has support for splitting windows, I run it multiple times when editing multiple files, and play with job ids to call them back. It might sound slow, but I'm really used to it and feel like I'm pretty efficient. I must admit that sometimes when I'm tired, I might end up with the same file opened 3 times in 3 different jobs... This is usually a good sign that I need some sleep ! 8. ssh What would be life without exploration ? I use it mostly to administer my servers, or connect to my IRC session, which is hosted on one of these servers. Nothing fancy here. 9. doas This is the OpenBSD equivalent to « sudo ». Since I reinstalled all my servers to OpenBSD, I started using « doas » to administer them (I never log in as root). I got so used to it, that I started typng « doas » instead of « sudo » on my own machine. And as crux doesn't come with « sudo » installed by default, I eventually replaced it with « doas ». The same phenomena is happening with « rcctl » vs. « systemctl » on my work laptop. I might add an alias someday ! 10. man To be honest, I'm proud to see it in this list. I love man pages, and prefer them over stackoverflow answers. With OpenBSD, I learnt to use them more, and took the habit to read the manual instead of searching the internet. This helped me a lot when programming in planes or trains, where you must work offline. I'm proud to finally have a proof that I RTFM ! What started as a bored question ended up in a good introspection of my terminal habits. This was a funny exercise, and I would recommend it to everyone that uses a terminal often. Now what are YOUR top 10 commands ? -- ~wgs [0]: gopher://phlog.z3bra.org/0/configuration-management.txt [1]: https://crux.nu 20201027.2336]]> <![CDATA[Official nixers.net gopher space]]> gopher://phlog.z3bra.org/0/official-nixers.net-gopher-space.txt 2020-09-17T15:59:00+02:00 wgs <![CDATA[Old Computer Challenge V3]]> gopher://phlog.z3bra.org/0/old-computer-challenge-v3.txt 2023-07-18T22:07:00+02:00 wgs gopher://occ.deadnet.se/1/users Day 0 ===== I only learn about the challenge on the first day. Hopefully I have the perfect challenger for this task: my trusty Acer Aspire One from 2009. Equipped with an Intel Atom clocking at 1.6GHz, 1Gib of RAM and a 250Gb hard drive, it barely needed any limitation to fit in the challenge. I grab it from the shelf, blow the dust out of it and powers it. Without much surprise, it boots into the 5 years old Void Linux I had setup and forgot about. I plug it in to reflow it with some juice, and ends the day. Day 1 ===== I decide to finally install OpenBSD on this thing, and to make it work. Years ago I had issues with the WiFi card not being usable, but it should be fixed now right? Obviously not. After failing at using urndis(4) to use my phone's connection over USB, I eventually found a working WiFi card in an Asus Eee PC from the same era. It took me quite some time and patience, but I got OpenBSD up and running, with an internet access that's reliable! The rest of the day will be spent setting up my environment, which features many software that must be compiled, either to configure them, or because they're not packaged: - abduco 0.6 - dmenu 5.2 - glazier 1.1 - human 0.3 - lel 0.2 - libwm 1.3 - pm 1.4 - randr 0.0 - sacc 1.06 - webdump 0.0 - wmutils 1.7 - xmenu 0.0 - xrectsel 0.3.2 - xscreenshot 0.0 - xwait 5.7 And that's where I hit my first OCC limit: with a single core at 1GHz, everything is slow when you're compiling stuff in the background! Hopefully these software compile rather fast, so I just had to wait a few seconds before using the computer again. With the environment setup, it was time to actually use the computer. So I decided to brag about it on the web. I knew for a fact that firefox cannot run on this machine, even at its full potential, because I tried it already, and failed miserably. So I installed netsurf right away as my gateway to the world wide web. And here is the second limit: It turns out that netsurf doesn't start with Javascript enabled. 512Mib of RAM just isn't enough for it apparently, so I disabled that. I could browse few website and access online resources I need to fix issues I had with the configuration of OpenBSD, but that's pretty much it. The web of today requires javascript to interact with it. I close the notebook on this unsurprising fact. Day 2 ===== Unfortunately, this would be my last day for the challenge. I would be on holidays the next day, with no plan to do any computing. This would also be a very short day, as my workday turned out to be very busy. I simply spent the night chatting on IRC from this cool little notebook I have, happy that I revived it once again for no valid reason :) Closing word ============ I cannot consider this challenge a success. I came in to late, and could only use the notebook for 2 days, not doing anything meaningful. I'm however happy to finally have been able to slap OpenBSD on it, and I'll definitely keep using this thing when I'm on the go, as the form factor is simply too practical! The battery is also surprisingly good for a cheap computer of the past decade. I'll definitely use it again for next year's challenge ;) Bonus ===== Pictures of "sorlag": gopher://z3bra.org/I/u/sorlag-outside.jpg gopher://z3bra.org/I/u/sorlag-inside.png 20230718.2207]]> <![CDATA[Online messaging]]> gopher://phlog.z3bra.org/0/online-messaging.txt 2020-08-25T08:43:00+02:00 wgs capture.png In case you want to click on the touchscreen remotely, you can use adb shell 'input X Y' Where X and Y are the coordinates of where you want to click. Not very comfortable to use, but that might be handier than stopping the VM and starting it again locally, snapshot it, reupload, … # Rationale https://imgs.xkcd.com/comics/team_chat.png [0]: https://github.com/42wim/matterbridge [1]: https://web.whatsapp.com 20200825.0843]]> <![CDATA[partage: An HTTP based file sharing system]]> gopher://phlog.z3bra.org/0/partage-an-http-based-file-sharing-system.txt 2021-10-21T14:34:00+02:00 wgs <![CDATA[Re: Gopher text rendering ideas]]> gopher://phlog.z3bra.org/0/re-gopher-text-rendering-ideas.txt 2020-09-25T16:40:00+02:00 wgs tags 3.1 Matched ? Wrap paragraph in
 tags
4. Move pointer past the paragraph
5. Start over till EOF

It worked great overall ! I browsed a few holes like this, and all 
ASCII arts / code snippets rendered perfectly. Actual text paragraphs 
were also pleasant to read with proportional fonts.

However,

A few things I didn't think about looked odd, because the 

tag reflow text by default. Things like lists, or quoted text looked bad: 1. First item 2. Second item 3. Third item > This was a quoted text with > hard wraps in it, that should definitely > not be reflowed. Some texts or graphic stuff looked odd as well, like banners like this that are 70 char wide: ||<><><><><><><....>|| As a conclusion, I think that my « naive » approach was a bit too naive, so for now I reverted to full monospace font for the time being, until I find a better way to do it, or give up on it entirely. If someone has an idea, feel free to contact me to discuss it ! -- ~wgs 20200925.1640]]> <![CDATA[Reflowing emails with fmt(1)]]> gopher://phlog.z3bra.org/0/reflowing-emails-with-fmt1.txt 2020-09-09T14:42:00+02:00 wgs <![CDATA[Replacing tinc with wireguard]]> gopher://phlog.z3bra.org/0/replacing-tinc-with-wireguard.txt 2021-09-28T18:04:00+02:00 wgs <![CDATA[RIP M$ basic auth support 💀]]> gopher://phlog.z3bra.org/0/rip-microsoft-basic-auth-support.txt 2022-10-25T18:59:00+02:00 wgs <![CDATA[SSH as a public service]]> gopher://phlog.z3bra.org/0/ssh-as-a-public-service.txt 2022-08-23T17:26:00+02:00 wgs /usr/local/bin/today.sh #!/bin/sh date '+%A !' EOF # chmod +x /usr/local/bin/today.sh # /usr/local/bin/today.sh Tuesday ! You'll probably want something more useful, and we'll get to it later on. For now, this will be enough. 1. Service account ------------------ It all starts with an account, that you'll use to connect to the machine, and run the program. This account must not have a password, and have restricted rights to the system resources. So let's first create a login class for these users, to limit its resource usage on the system: # cat < /etc/login.conf.d/sshervice sshervice:\ :path=/bin /usr/bin /usr/local/bin:\ :umask=022:\ :datasize=1024M:\ :maxproc=32:\ :openfiles=128:\ :stacksize=1M:\ :filesize=512M: EOF # cap_mkdb /etc/login.conf See login.conf(5) for how to tweak these values to your likings. # groupadd _sshervice # adduser -d /var/sshervice \ -L sshervice \ -g _sshervice \ -s /bin/sh \ -p '' \ today At this point, you should be able to get a shell for your service account without specifying a password (try as non-root user): $ su - today $ /usr/bin/whoami today $ pwd /var/sshervice 2. SSH access ------------- You can login as this user, but it shouldn't be accessible from the outside, because of how unsecure it is (at least that's the case on OpenBSD). Thanks to the "Match" keyword, OpenSSH can apply specific configuration bits to a user or a group (see sshd_config(5) for details). So we'll use that: # cat < /etc/ssh/sshd_config_sshervice Match User today ForceCommand /usr/local/bin/today.sh Match Group _sshervice PasswordAuthentication yes PermitEmptyPasswords yes DisableForwarding yes ForceCommand /sbin/nologin MaxSessions 5 EOF # echo 'Include sshd_config_sshervice' >>/etc/ssh/sshd_config # rcctl restart sshd 3. Final result --------------- $ ssh today@cooldomain.tld Tuesday ! 4. Going further ---------------- From there, it's all a matter of providing cool and/or useful services, so you'll have to improve what's running as the "ForceCommand" of your user. Here are a few tips, in no particular order: --- Read login.conf(5) and sshd_config(5). Really, do it. --- Remember that you're giving strangers the ability to run programs on your server. Take extra care to not provide them the ability to get access to a shell. For example: #!/bin/sh date "$1" This looks harmless, but passing it "-f/dev/passwd" would yield its full content. So take extra care with the commands you allow ! --- Worth mentionning is that you can chroot(8) your service over ssh with the following line under the "Match" block of sshd_config(5): ChrootDirectory /var/sshervice This require to setup a proper chroot for your service to run the program correctly. --- Never trust user input. --- use environment variable `$SSH_ORIGINAL_COMMAND` to allow users to specify commands. Given the following script: #!/bin/sh date -- "+${SSH_ORIGINAL_COMMAND:-%A !}" You can now specify the date format on the command line: $ ssh today@cooldomain.tld Tuesday ! $ ssh today@cooldomain.tld %Y-%m-%d 2022-08-23 --- Prefer self-contained programs over scripts. Ideally statically link and chroot them. --- If your program requires a TTY to run (like a pager for example), don't forget to pass `-t` when you specify a command over ssh, because it does not allocate a pseudo tty by default when passing arguments. Imagine an online man page service: #!/bin/sh man "${SSH_ORIGINAL_COMMAND:-man}" Make sure to add -t to force a pseudo TTY allocation for the pager to work: $ ssh -t man@cooldomain.tld sshd_config 20220823.1726]]> <![CDATA[The gophirst approach]]> gopher://phlog.z3bra.org/0/the-gophirst-approach.txt 2020-09-13T16:47:00+02:00 wgs <![CDATA[TLS-sending guarantee @posteo.de]]> gopher://phlog.z3bra.org/0/tls-sending-guarantee-posteo.de.txt 2020-10-20T20:31:00+02:00 wgs <![CDATA[Trip to Reunion Island]]> gopher://phlog.z3bra.org/0/trip-to-reunion-island.txt 2020-10-14T19:34:00+02:00 wgs <![CDATA[Using DNS to bypass hotspot WiFi]]> gopher://phlog.z3bra.org/0/using-dns-to-bypass-hotspot-wifi.txt 2020-09-26T13:42:00+02:00 wgs <![CDATA[Vis: Vim Improved, on Steroids]]> gopher://phlog.z3bra.org/0/vis-vim-improved-on-steroids.txt 2023-07-07T01:15:00+02:00 wgs 7) { foo = do_stuff(foo) } return foo; Now assume we want to change a few things: 0. rename "foo" to "bar" 1. remove the useless "= 0" 2. add the missing ; on line 4 How would we do these with Vim commands ? 0. :%s/foo/bar/g 1. :1s/ = 0// (or "ggt=dt;") 2. :4s/$/;/ (or "4GA;") Do you notice the pattern ? Even though Vim has :change, :delete and :append/:insert commands, we used :substitute for all of them! Think about it the next time you use Vim. The substitute command is used 90% of the time when using commands. Here's how you'd do it with Sam now: 0. x/foo/ c/bar/ 1. 1x/ = 0/ d 2. 4x/$/ a/;/ The x command eXtracts the selected text and runs a command on it, for each selection separately. This is a very powerful concept, as it lets you manipulate the text as a whole, rather than only interacting with it one line at a time. The sam language has even more powerful features which are described in its tutorial: http://doc.cat-v.org/bell_labs/sam_lang_tutorial/sam_tut.pdf Unfortunately for me, and even though Sam has a very powerful command language, navigating the file is done exclusively with the mouse. And I could just not give up on the muscle memory I built over all these years of using Vim. So what were my options ? Going back to Vim, after seing the greener side of the grass ? Give up on Vim, and the power of modal editing ? Vis === There was a third option of course: Vis ! When I first found about it, vis was a small project seeking to provide "90% of the features of Vim, in 10% of the code". This was immediately appealing to me, and I immediately tried it. It had rough edges, and I missed a few features, but it was clean and fast. Then the project became more mature, and a new feature appeared: The Sam language was implemented into it. I was thrilled! Vis combines the strength of both Vim and Sam into what I believe is the ultimate text editor. Selections (or DOT) benefits from Vim "visual" mode, allowing one to edit different portions of the file at the same time, with multiple cursors. And to put the icing on the cake, you can write plugins for it using Lua. Whether you're a plan9 fan looking for a good Sam implementation, or an avid Vim user, I urge you to try it, and embrace the other side of the text editing that you're going to learn. Acme ==== Of course, I could not end this post without talking about Acme[3], which I believe is the next step of editing evolution. I'm however too scared to really commit to it, and buy a 3 buttons mouse for this sole purpose (but I know I will, someday). However, there is a middleground: Edit[4]! This project has not been updated in a long time, but looks like a marvelous concept that I would like to explore in the future. Maybe the next (last?) step is Vim + Sam + Acme ? -- ~wgs [0]: https://github.com/martanne/vis [1]: https://blog.sanctum.geek.nz/category/vim [2]: http://glenda.cat-v.org [3]: http://acme.cat-v.org [4]: https://c9x.me/edit 20230707.0115]]> <![CDATA[Write code on a phone]]> gopher://phlog.z3bra.org/0/write-code-on-a-phone.txt 2020-09-14T16:11:00+02:00 wgs