alt.hn

7/31/2026 at 3:40:13 PM

A GTK4 SSH-askpass in Zig

https://xn--gckvb8fzb.com/a-gtk4-ssh-askpass-in-zig/

by surprisetalk

7/31/2026 at 4:53:21 PM

I wrap `pinentry` (which is in the dependency trees of gnupg, pacman, gvfs, udisks2 and other software that you can de-facto depend on on desktops) inside my own simple askpass.

  $ cat ~/scripts/pinentry-askpass
  #!/usr/bin/env bash
  
  pinentry <<INPUT | grep '^D ' | cut -c 3-
  SETPROMPT Password:
  GETPIN
  INPUT

  $ cat ~/.bashrc | grep ASKPASS
  export SUDO_ASKPASS="$HOME/scripts/pinentry-askpass"
  export SSH_ASKPASS="$SUDO_ASKPASS"
It automatically launches the GTK, TTY, or QT version depending on your environment.

It's also useful for agents to use sudo, you can write in instructions to tool-call `sudo -A` and you get a GUI popup to enter the password, and the agent continues from there. And since the "prompt" in pinentry can be customised... you can get the agent to set up a temporary askpass, which replaces "Password:" in the prompt with questions like "Can I delete this old log file in /var?" and you enter your password to authorise.

by porridgeraisin

8/1/2026 at 2:28:05 PM

Any reason you don't use `pinentry-gnome3` from the `pinentry` package? Your wrapper is clever but doesn't work with gpg-agent.

by aorth

8/1/2026 at 3:29:10 PM

No reason, I always thought launching pinentry directly chose the right one out of pinentry, pinentry-curses, pinentry-emacs, pinentry-gnome3, pinentry-gtk, pinentry-qt, pinentry-tty since it always worked for me on xfce+arch+programs I have used.

You can change it I suppose, I don't thing I use gpg-agent often.

by porridgeraisin

7/31/2026 at 6:45:12 PM

Noticed that when I build this it ends up with direct linking against a half-dozen libraries it doesn't actually use, at least on Ubuntu. Fixed it by replacing the linking commands with this:

    exe_mod.linkSystemLibrary("gtk-4", .{ .use_pkg_config = .no });
    exe_mod.linkSystemLibrary("gobject-2.0", .{});
In my case, at least, this doesn't change the full library tree because gtk-4 still links against all of the libraries that are removed from this binary's list, but it does mean that programs which calculate dependencies, like dpkg-shlibdeps, won't report spurious "required" dependencies when analyzing the binary.

When building on Ubuntu 26.04, the binary no longer directly links against lib{pango, cairo, pangocairo, cairo-gobject, harfbuzz, gdk_pixbuf, graphene, gio, vulkan}.

Can't create an account on the site so I figured I'd post this here. If you're going for absolute minimalism this seems like another step in the right direction for anyone building on a more 'gratuitous' GTK build (such as Ubuntu's)

by danudey

7/31/2026 at 5:37:09 PM

Whenever someone writes "with hand-written bindings" I read "will stop working 8 minutes after the next release"

by DannyBee

7/31/2026 at 7:29:50 PM

There are tools to generate bindings. They probably meant it as a marker of quality.

And in languages like zig or odin which are quite similar to C in many ways, writing bindings to C code really isn’t bad. It is so easy that I decided to write my own bindings in Odin to sqlite - bindings exist but it really was so very easy that I didn’t want to bring in a generator or another dependency.

by pseudony

7/31/2026 at 4:22:51 PM

Nice, I just use lxqt-openssh-askpass, but I am on X11. A lighter alternative (for single-text input) would be FLTK. Version 1.4 is really nice, with Wayland support, and they even draw custom window decorations on GNOME. Both Cairo and FLTK should be able to compile with -X; not sure, though, about the status of the Zig bindings.

by gen2brain

7/31/2026 at 6:39:29 PM

fltk is c++ based which makes language bindings significantly harder in general. gtk is c based which worked out really well in that aspect.

by zem

7/31/2026 at 6:50:51 PM

Sure, you need to wrap it in C, but there is also `cfltk` that is maintained and used in Rust bindings. Btw., the difference in memory usage is huge with GTK4. FLTK hello world is ~10M, GTK3 is ~15M, GTK4 is 40M! With Cairo rendering, it's about 30M, but still a lot.

by gen2brain

7/31/2026 at 9:10:01 PM

GTK4 memory usage is ludicrous

by Levitating

7/31/2026 at 8:25:55 PM

ah neat, I wasn't aware that cfltk was already used by rust.

by zem

8/1/2026 at 9:03:59 AM

There is cflt and Freebasic FLTK

by fithisux

7/31/2026 at 4:24:39 PM

Love the tab title shenanigans when switching to and from the tab.

by bflesch

7/31/2026 at 4:27:30 PM

These implementations really need to also include fingerprint sensor support

by hparadiz

7/31/2026 at 4:43:41 PM

PAM really needs to be ravamped and support for (among other things) running multiple stacks in par@llel added. This way you could ask for a password OR a fingerprint

by quotemstr

7/31/2026 at 10:08:51 PM

I'm vaguely considering rewriting PAM in Rust. It's definitely something that would benefit from Rust's extra security and the code quality isn't that great. Nor is the UX. What "among other things" were you thinking of?

by timhh

8/1/2026 at 2:08:18 AM

Implementation language is incidental. Rust is... fine, I guess? But I wouldn't mandate modules use it. What's important is to move PAM out of process and sandbox the process host (using landlock, namespaces like bwrap, whatever) so we can run sensitive code with least-privilege on both ends.

by quotemstr

8/1/2026 at 7:47:18 AM

Yeah I always thought the whole architecture of PAM being a library is weird. A sane person would have made it a Daemon that processes talk to surely?

Really it should probably be part of SystemD, but I know that would anger the anti-SystemD zealots.

by timhh

8/1/2026 at 10:01:54 AM

> A sane person would have made it a Daemon that processes talk to surely?

> Really it should probably be part of SystemD

https://github.com/systemd/systemd/pull/39855

by NekkoDroid

8/1/2026 at 5:21:43 PM

It's confusing how they want a custom protocol that seems to be converging from JSON-RPC, just spelled differently. They should just use JSON-RPC. In any case, it'd essential to retain PAM's customization ability even if the bulk of the work is moved out-of-process.

by quotemstr

8/1/2026 at 5:15:57 PM

Not everything has to be a "daemon". It's a bad trend in current programming zeitgeist to want to make everything into one. (sccache, no, you do NOT need a daemon to behave like ccache.)

For a PAM replacement, you want a separate process. It doesn't have to be a persistent separate process.

by quotemstr

7/31/2026 at 6:33:04 PM

Keypassxc does it perfectly.

by hparadiz

7/31/2026 at 6:45:11 PM

Everyone doing parallel biometric and password authentication on Linux today is either running two PAM stacks in parallel (which is meta-policy that kind of defeats the purpose of PAM) or just bypassing PAM entirely.

by quotemstr

7/31/2026 at 5:44:10 PM

Fingerprint is an authentication mechanism, not an authorization one.

by xnickb

7/31/2026 at 6:30:04 PM

It's both.

by hparadiz

7/31/2026 at 4:14:40 PM

Would love to see more projects using gtk and zig. Always nice to have another language option.

by WD-42

7/31/2026 at 5:25:55 PM

this is realy good and helpfull information thanks.

by hackingboy298