- Husk now not only encrypts outgoing emails (if possible) but also adds a signature. - Rework the internal handling of the signing key. - Integrate the signing into the workflow of the daemon. - Add a configuration option for a subject replacement.
73 lines
1.7 KiB
Bash
73 lines
1.7 KiB
Bash
#!/usr/bin/bash
|
|
|
|
# create a unix (shell) user
|
|
create_unix_user() { # name
|
|
adduser --quiet --shell /bin/bash --disabled-password --gecos "" $1 > /dev/null 2>&1
|
|
}
|
|
|
|
# delete a unix user, plus remove $HOME and mails
|
|
delete_unix_user() { # name
|
|
deluser --remove-home $1
|
|
}
|
|
|
|
# send a mail and wait for delivery
|
|
send_test_mail() { # email_address
|
|
USER=$(echo $1 | cut -f 1 -d '@')
|
|
# create an empty mailbox file
|
|
touch /var/mail/$USER
|
|
chown $USER:mail /var/mail/$USER
|
|
chmod 600 /var/mail/$USER
|
|
|
|
echo -e "Subject: testmail\n\ntest mail" | sendmail $1
|
|
inotifywait -qq -t 3 -e close_write /var/mail/$USER
|
|
}
|
|
|
|
# test header
|
|
test_header() { # text
|
|
echo "##############################################"
|
|
echo $1
|
|
echo "Workdir: $WORKDIR"
|
|
echo "##############################################"
|
|
}
|
|
|
|
# Generate a key outside the cert store. The key will not be
|
|
# authenticated.
|
|
gen_key() { # email
|
|
FILE=$(echo $1 | cut -f 1 -d '@')
|
|
FPR=$(sq key generate --home none --shared-key --without-password \
|
|
--email $1 \
|
|
--output $WORKDIR/${FILE}_sk.pgp \
|
|
--rev-cert $WORKDIR/${FILE}.rev |& grep "Fingerprint:" | cut -d ':' -f 2)
|
|
echo $FPR
|
|
}
|
|
|
|
expect_mail() { # unix_user mode
|
|
if [ -f /var/mail/$1 ] ; then
|
|
case $2 in
|
|
encrypted)
|
|
if grep -q "BEGIN PGP MESSAGE" /var/mail/$1 ; then
|
|
R=0
|
|
else
|
|
echo "expected encrypted mail for $1" >&2
|
|
R=1
|
|
fi
|
|
;;
|
|
unencrypted)
|
|
if grep -q "BEGIN PGP MESSAGE" /var/mail/$1 ; then
|
|
echo "expected unencrypted mail for $1" >&2
|
|
R=1
|
|
else
|
|
R=0
|
|
fi
|
|
;;
|
|
delivered)
|
|
R=0
|
|
;;
|
|
esac
|
|
else
|
|
echo "no mail for $1" >&2
|
|
R=1
|
|
fi
|
|
echo $R
|
|
}
|