remove doas_askpass subodule update shortcuts

This commit is contained in:
Tibeuleu
2026-01-06 16:33:32 +01:00
parent c7c812b49f
commit 16b46c275a
11 changed files with 144 additions and 14 deletions

View File

@@ -0,0 +1,15 @@
PROG=doas_askpass
PREFIX=/usr/local
BINDIR=${PREFIX}/bin
LICENSEDIR=${PREFIX}/share/licenses/doas_askpass
install:
chmod 755 ${PROG}
cp ${PROG} ${PROG}.bak
mkdir -p ${DESTDIR}${BINDIR}
cp ${PROG}.bak ${DESTDIR}${BINDIR}/${PROG}
rm ${PROG}.bak
uninstall:
rm -rf ${DESTDIR}${LICENSEDIR}
rm -f ${DESTDIR}${BINDIR}/${PROG}

View File

@@ -0,0 +1,81 @@
Doas AskPass
================
## Contents
- [Usage](#usage)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Universal](#universal)
- [Gentoo](#gentoo)
- [Uninstallation](#uninstallation)
- [Universal](#universal-1)
- [Gentoo](#gentoo-1)
- [Configuration](#configuration)
Doas AskPass is a simple expect script that basically creates a
`sudo -A` equivalent for Doas. This allows you to graphically enter your
password.
## Usage
`# user` doas-askpass <command>
## Dependencies
1. Doas
2. Expect
Dmenu is also recommended.
## Installation
### Universal
``` sh
`# user` git clone https://github.com/amarakon/doas_askpass
`# user` cd doas_askpass
`# root` make install
```
### Gentoo
``` sh
`# root` eselect repository add amarlay git https://github.com/amarakon/amarlay
`# root` emerge --sync amarlay
`# root` emerge app-admin/doas_askpass
```
## Uninstallation
### Universal
``` sh
`# user` cd doas_askpass
`# root` make uninstall
```
### Gentoo
``` sh
`# root` emerge -c app-admin/doas_askpass
# Remove my overlay (optional)
`# root` eselect-repository remove -f amarlay
`# root` emerge --sync
```
## Configuration
The graphical program that is expected by the script is set by the
`DOAS_ASKPASS` environment variable. Otherwise, the default is
`dmenu -P -p password`. You need the
[password](https://tools.suckless.org/dmenu/patches/password/) patch in
order for this to work. I recomment using my
[version](https://github.com/amarakon/dotfiles/blob/master/etc/portage/patches/x11-misc/dmenu/dmenu-password-5.0.diff)
which is more secure. You can set the environment variable in
`~/.bashrc` or anywhere else that your shell is going to source. The
following is an example.
``` sh
DOAS_ASKPASS="dmenu -P -p password:"
```

View File

@@ -0,0 +1,34 @@
#!/usr/bin/expect --
# askpass implementation for doas
# example usage: DOAS_ASKPASS="dmenu -P -p password:" doas_askpass echo working
# don't mind the man behind the curtain
log_user 0
# no command, then nothing to do
if { $argc == 0 } { exit 0 }
# treat all arguments as command input
set cmd [lrange $argv 0 end];
# read askpass from env or fallback to dmanu_pass ()
if {[info exists ::env(DOAS_ASKPASS)]} {
set askpass "$::env(DOAS_ASKPASS)"
} else {
set askpass "dmenu -P -p password"
}
# read password from user
set pwd [exec {*}$askpass]
# spawn doas operation
spawn doas {*}$cmd
# send password and execute command
expect "doas*password:" {
send -- "$pwd\r"
expect \r
log_user 1
expect eof
}