Revert temp file mechanism for sphinx

for some reason to be investigated further using tomb's temp
file mechanism breaks the test suite of sphinx support

This reverts commit a6d252c949.
This commit is contained in:
Jaromil 2019-05-18 09:51:55 +02:00
parent b34584b61c
commit 95f2f68654

11
tomb
View File

@ -527,14 +527,15 @@ sphinx_get_password() {
{ option_is_set --sphx-user && option_is_set --sphx-host } && {
# value error in sphinx doesn't set exit code
# using tempfile as a workaround to notice the error
_tmp_create
errorfile=$TOMBTMP
errorfile=$(mktemp /tmp/tomb_error.XXXXXXXXX)
password=$(echo "$1" | sphinx get $(option_value --sphx-user) $(option_value --sphx-host) 2>$errorfile)
if ! grep -q "ValueError: fail" $errorfile ; then
echo "$password"
rm $errorfile
return 0
else
_warning "sphinx returns error: ::1 error::" $(cat $errorfile)
rm $errorfile
_failure "Failed to retrieve actual password with sphinx."
fi
} || {
@ -551,22 +552,24 @@ sphinx_set_password() {
{ option_is_set --sphx-user && option_is_set --sphx-host } && {
# value error in sphinx doesn't set exit code
# using tempfile as a workaround to notice the error
_tmp_create
errorfile=$TOMBTMP
errorfile=$(mktemp /tmp/tomb_error.XXXXXXXXX)
# check first if this host/user combination exists in store
# if yes, there is no need to make a call to create
password=$(echo "$1" | sphinx get $(option_value --sphx-user) $(option_value --sphx-host) 2>$errorfile)
if ! grep -q "ValueError: fail" $errorfile ; then
echo "$password"
rm $errorfile
return 0
fi
# no such host/user combination in store, create one
password=$(echo "$1" | sphinx create $(option_value --sphx-user) $(option_value --sphx-host) ulsd 0 2>$errorfile)
if ! grep -q "ValueError: fail" $errorfile ; then
echo "$password"
rm $errorfile
return 0
else
_warning "sphinx returns error: ::1 error::" $(cat $errorfile)
rm $errorfile
_failure "Failed to create password with sphinx"
fi
} || {