Password creation fix (#908, #914)

* fix password with spaces is stripped to first word
This commit is contained in:
17Halbe 2018-04-02 16:55:54 +02:00 committed by Johan Smits
parent f28e9843ce
commit 2e06228b10
3 changed files with 20 additions and 5 deletions

View file

@ -28,5 +28,5 @@ if [ -z "$PASSWD" ]; then
echo
[ -z "$PASSWD" ] && errex "Password must not be empty"
fi
echo "$USER|$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$PASSWD")" >>$DATABASE
HASH="$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$PASSWD")"
echo "$USER|$HASH" >> $DATABASE

View file

@ -3,7 +3,7 @@
DATABASE=${DATABASE:-/tmp/docker-mailserver/postfix-accounts.cf}
USER="$1"
PASSWD=$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$2")
PASSWD="$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$2")"
usage() {
echo "Usage: updatemailuser <user@domain.tld> [password]"
@ -23,4 +23,3 @@ escape() {
grep -qi "^$(escape "$USER")|" $DATABASE 2>/dev/null ||
errex "User \"$USER\" does not exist"
sed -i "s ^"$USER"|.* "$USER"|"$PASSWD" " $DATABASE
#sed -i "s/^"$(escape "$USER")"|*/"$USER"|"$(doveadm pw -s SHA512-CRYPT -u "$USER" -p "$PASSWD")"/" $DATABASE

View file

@ -1188,17 +1188,34 @@ load 'test_helper/bats-assert/load'
assert_success
value=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $1}')
[ "$value" = "lorem@impsum.org" ]
# don't know why, but the test suite needs to delete the (non existant) user prior succeeding in adding him again.
# when executed directly against the container this workaround is not neccessary.
run docker exec mail delmailuser -y pass@localhorst.localdomain
assert_success
docker exec mail addmailuser pass@localhost.localdomain 'may be \a `p^a.*ssword'
sleep 30
docker exec mail doveadm auth test -x service=smtp pass@localhost.localdomain 'may be \a `p^a.*ssword' | grep 'auth succeeded'
assert_success
}
@test "checking setup.sh: setup.sh email list" {
run ./setup.sh -c mail email list
assert_success
}
@test "checking setup.sh: setup.sh email update" {
initialpass=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $2}')
run ./setup.sh -c mail email update lorem@impsum.org consectetur
updatepass=$(cat ./config/postfix-accounts.cf | grep lorem@impsum.org | awk -F '|' '{print $2}')
[ "$initialpass" != "$changepass" ]
docker exec mail /bin/sh -c "updatemailuser pass@localhost.localdomain 'my other password'"
sleep 30
docker exec mail /bin/sh -c "doveadm auth test -x service=smtp pass@localhost.localdomain 'my other password' | grep 'auth succeeded'"
assert_success
}
@test "checking setup.sh: setup.sh email del" {
run ./setup.sh -c mail email del -y lorem@impsum.org
assert_success
@ -1243,7 +1260,6 @@ load 'test_helper/bats-assert/load'
run /bin/sh -c 'cat ./config/postfix-virtual.cf | grep "test1@example.org test1@forward.com,test2@forward.com" | wc -l | grep 1'
assert_success
}
@test "checking setup.sh: setup.sh alias del" {
echo -e 'test1@example.org test1@forward.com,test2@forward.com\ntest2@example.org test1@forward.com' > ./config/postfix-virtual.cf