#!/usr/bin/expect --
# no command, then nothing to do
if { $argc == 0 } { exit 0 }
# treat all arguments as command input
set cmd [lrange $argv 0 end];
#sets askpass
set askpass "imenu -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
}
doas emerge --ask dev-tcltk/expect
src::
https://noxz.tech/articles/askpass_implementation_for_doas/
for env var
# example usage: DOAS_ASKPASS="dmenu -P -p password:" doas_askpass echo working
if {[info exists ::env(DOAS_ASKPASS)]} {
set askpass "$::env(DOAS_ASKPASS)"
} else {
set askpass "dmenu_pass password:"
}
Comments
Post a Comment