diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-10-20 20:45:53 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2023-01-26 22:59:40 -0500 |
| commit | c436b67918be2cb63c74de98b617329f13f62ed3 (patch) | |
| tree | 418d5c17802dee444c7bd278a7ca480efc3501e3 | |
| parent | ba1a347dcaba055f824161007dfee60db3ea785b (diff) | |
| download | dmenu-c436b67918be2cb63c74de98b617329f13f62ed3.tar.gz dmenu-c436b67918be2cb63c74de98b617329f13f62ed3.tar.xz | |
SSH askpass suppport
dmenu_askpass has been added and can be used to read in SSH key
passwords, useful for if your agent is forwarded. Full support for
prompting from security keys, often requiring you to tap the
authenticator. This unlike some other askpass variants does not stick
around after you tap the button.
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | dmenu.c | 13 | ||||
| -rwxr-xr-x | dmenu_askpass | 3 |
3 files changed, 16 insertions, 3 deletions
@@ -42,10 +42,11 @@ dist: clean install: all mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin + cp -f dmenu dmenu_path dmenu_run dmenu_askpass stest $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run + chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_askpass chmod 755 $(DESTDIR)$(PREFIX)/bin/stest mkdir -p $(DESTDIR)$(MANPREFIX)/man1 sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 @@ -35,6 +35,7 @@ struct item { }; static char text[BUFSIZ] = ""; +static int echo = 1; static char *embed; static int bh, mw, mh; static int inputw = 0, promptw; @@ -160,7 +161,11 @@ drawmenu(void) /* draw input field */ w = (lines > 0 || !matches) ? mw - x : inputw; drw_setscheme(drw, scheme[SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + + if (echo) + drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0); + else + drw_text(drw, x, 0, w, bh, lrpad / 2, "(no echo)", 0); curpos = TEXTW(text) - TEXTW(&text[cursor]); if ((curpos += lrpad / 2 - 1) < w) { @@ -279,6 +284,7 @@ match(void) } curr = sel = matches; calcoffsets(); + memset(buf, '\0', sizeof(text)); } static void @@ -491,6 +497,7 @@ insert: case XK_Return: case XK_KP_Enter: puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); + memset(text, '\0', sizeof text); if (!(ev->state & ControlMask)) { cleanup(); exit(0); @@ -714,7 +721,7 @@ setup(void) static void usage(void) { - die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + die("usage: dmenu [-bfivE] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]"); } @@ -733,6 +740,8 @@ main(int argc, char *argv[]) topbar = 0; else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = 1; + else if (!strcmp(argv[i], "-E")) /* no Echo, for use with passphrases */ + echo = 0; else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; diff --git a/dmenu_askpass b/dmenu_askpass new file mode 100755 index 0000000..9f61844 --- /dev/null +++ b/dmenu_askpass @@ -0,0 +1,3 @@ +#!/bin/sh +exec <&- +exec dmenu -E -p "${1:-OpenSSH Passphrase: }" |
