Article URL: https://xn--gckvb8fzb.com/a-gtk4-ssh-askpass-in-zig/ Comments URL: https://news.ycombinator.com/item?id=49124496 Points: 39 # Comments: 12

Every ssh-askpass in the Gentoo tree pulls in X11 or a full KDE stack, so I wrote my own with Zig 0.16 and GTK4, with hand-written bindings that keep X out of the build. I run hardened Gentoo on my laptop, and most of the time I never touch ssh-askpass because I’m using -sk keys for most of the systems. There is one class of situation where I do need it, though, which is when a program wants an SSH key passphrase for a regular ED25519 key, but has no terminal to read it from. The usual case is go get, or the go toolchain in general, fetching a private module over SSH during a build that runs without a TTY. OpenSSH can’t prompt on a pipe, so it runs whatever SSH_ASKPASS points at and puts the passphrase prompt in a window instead. For years I had nothing installed for that and had to work around these scenarios. The main reason for that is what Gentoo’s Portage offers: Each of these has at least one inconvenience I didn’t feel like putting up with. My system runs with the global -X USE flag, so anything that needs X11 is out before I look any further. Of the five, kde-plasma/ksshaskpass is the only one with no X11 dependency whatsoever, which should have made it the obvious pick, but the trouble is everything else that comes with it. As a Sway user, I did not want a full KDE stack on the machine just to type the occasional passphrase, and that is what a ksshaskpass install pulls in: lxqt-base/lxqt-openssh-askpass is next, and it needs X outright. On top of that it pulls in a few KDE framework packages and a Qt built with X support, which collides with the dev-qt/qtbase already on my system that was compiled -X, so Portage stops on a slot conflict: net-misc/ssh-askpass-fullscreen needs X as well, this time by way of GTK2 and a Cairo built with X support: net-misc/x11-ssh-askpass is X11 by name, so no surprise there, and it also needs the old imake build system, namely x11-misc/xorg-cf-files and x11-misc/imake, to compile at all: That left net-misc/gnome-ssh-askpass. At first glance it looked like the one option that needed no X at all, but that turned out to be wrong. It does need X11, and the ebuild appears to be broken about it. The build calls pkg-config --libs gtk+-3.0 x11 and the source includes gdk/gdkx.h, an X-only GDK header, so on a system compiled without X it fails to build: This is where I gave up on the packaged options. Even setting the X11 question aside, every one of these uses GTK2 or GTK3 at most. However, it just so happened that I had wanted to build something with GTK4 for a long time, so instead of patching one of the existing implementations, which are mostly C anyway, I wrote my own with Zig 0.16 and GTK4, and called it ssh-askpass-zigtk.