abuild-keygen: use doas instead of sudo
fallback to sudo if doas was not found
This commit is contained in:
parent
36e1d04f06
commit
4dbf8e3756
|
@ -8,7 +8,7 @@
|
|||
|
||||
program_version=@VERSION@
|
||||
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
|
||||
SUDO="${SUDO-sudo}"
|
||||
SUDO="${SUDO-$(command -v doas || command -v sudo || echo doas)}"
|
||||
|
||||
if ! [ -f "$sharedir/functions.sh" ]; then
|
||||
echo "$sharedir/functions.sh: not found" >&2
|
||||
|
@ -98,14 +98,15 @@ usage() {
|
|||
-a, --append Set PACKAGER_PRIVKEY=<generated key> in
|
||||
$ABUILD_USERCONF
|
||||
|
||||
-i, --install Install public key into /etc/apk/keys using sudo
|
||||
-i, --install Install public key into /etc/apk/keys using doas
|
||||
-n Non-interactive. Use defaults
|
||||
-b, --numbits [BITS] The size of the private key to generate in bits.
|
||||
-q, --quiet
|
||||
-h, --help Show this help
|
||||
|
||||
The SUDO variable can be set to pick which tool can be used to
|
||||
elevate privileges, if it is not set it defaults to sudo.
|
||||
elevate privileges, if it is not set it defaults to doas or sudo if doas
|
||||
is not found.
|
||||
|
||||
__EOF__
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ init_tests \
|
|||
abuild_keygen_append \
|
||||
abuild_keygen_install_without_sudo \
|
||||
abuild_keygen_install_interactive \
|
||||
abuild_keygen_install_non_interactive
|
||||
abuild_keygen_install_non_interactive \
|
||||
abuild_keygen_install_doas
|
||||
|
||||
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
|
||||
export GIT=false
|
||||
|
@ -79,3 +80,21 @@ abuild_keygen_install_non_interactive_body() {
|
|||
-e match:"Generating RSA" \
|
||||
abuild-keygen --install -n
|
||||
}
|
||||
|
||||
abuild_keygen_install_doas_body() {
|
||||
mkdir bin
|
||||
cat >bin/doas<<-EOF
|
||||
#!/bin/sh
|
||||
echo "fake doas"
|
||||
"\$@"
|
||||
EOF
|
||||
chmod +x bin/doas
|
||||
|
||||
PATH="$PWD/bin:$PATH" abuild_keygen_install_root="$PWD" \
|
||||
atf_check -s exit:0 \
|
||||
\
|
||||
-o match:"fake doas" \
|
||||
-e match:"Generating RSA" \
|
||||
abuild-keygen --install -n
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue