mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 09:12:45 +01:00
negative case where username doesn't exist now report exception as expected
This commit is contained in:
@@ -34,6 +34,16 @@ MYSQL_PASS=$(lookup_pillar_secret mysql)
|
||||
FLEET_IP=$(lookup_pillar fleet_ip)
|
||||
FLEET_USER=$USER
|
||||
|
||||
# test existence of user
|
||||
MYSQL_OUTPUT=$(docker exec so-mysql mysql -u root --password=$MYSQL_PASS fleet -e \
|
||||
"SELECT count(1) FROM users WHERE username='$FLEET_USER'" 2>/dev/null | tail -1)
|
||||
if [[ $? -ne 0 ]] || [[ $MYSQL_OUTPUT -ne 1 ]] ; then
|
||||
echo "Test for username [${FLEET_USER}] failed"
|
||||
echo " expect 1 hit in users database, return $MYSQL_OUTPUT hit(s)."
|
||||
echo "Unable to update Fleet user password."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Read password for new user from stdin
|
||||
test -t 0
|
||||
if [[ $? == 0 ]]; then
|
||||
@@ -52,6 +62,7 @@ if [[ $? -ne 0 ]]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
MYSQL_OUTPUT=$(docker exec so-mysql mysql -u root --password=$MYSQL_PASS fleet -e \
|
||||
"UPDATE users SET password='$FLEET_HASH', salt='' where username='$FLEET_USER'" 2>&1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user