mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-18 20:37:55 +00:00
Ensure Vendor login works
This commit is contained in:
parent
7ea5aa8aed
commit
5d9f396b14
1
.github/workflows/ci-smoke-linux.yml
vendored
1
.github/workflows/ci-smoke-linux.yml
vendored
@ -114,6 +114,7 @@ jobs:
|
||||
make configure KEY=MYSQL_ROOT_PASSWORD VAL=mysqlpass
|
||||
make configure KEY=PGSQL_ROOT_USER VAL=pgroot
|
||||
make configure KEY=PGSQL_ROOT_PASSWORD VAL=pgsqlpass
|
||||
make configure KEY=DEVILBOX_VENDOR_PHPMYADMIN_AUTOLOGIN VAL=0
|
||||
fi
|
||||
env:
|
||||
PHP: ${{ matrix.php }}
|
||||
|
@ -42,12 +42,16 @@ fi
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
MYSQL_ROOT_PASSWORD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "MYSQL_ROOT_PASSWORD" )"
|
||||
DEVILBOX_VENDOR_PHPMYADMIN_AUTOLOGIN="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "DEVILBOX_VENDOR_PHPMYADMIN_AUTOLOGIN" )"
|
||||
|
||||
|
||||
###
|
||||
### Retrieve URL for current PHP version.
|
||||
### Older PHP versions are presented a link with a different version due to compatibility.
|
||||
###
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT: Version
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# Retrieve URL for current PHP version.
|
||||
# Older PHP versions are presented a link with a different version due to compatibility.
|
||||
printf "[TEST] Retrieve phpMyAdmin URL"
|
||||
if ! URL="$( run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/index.php' \
|
||||
@ -63,207 +67,10 @@ else
|
||||
fi
|
||||
|
||||
|
||||
####
|
||||
#### Ensure given phpMyAdmin version works
|
||||
####
|
||||
#
|
||||
#printf "[TEST] Fetch ${URL}"
|
||||
## 1st Try
|
||||
#if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "welcome to.+phpMyAdmin"; then
|
||||
# # 2nd Try
|
||||
# sleep 1
|
||||
# if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "welcome to.+phpMyAdmin"; then
|
||||
# # 3rd Try
|
||||
# sleep 1
|
||||
# if ! curl -sS localhost${URL} | tac | tac | grep -Eiq "welcome to.+phpMyAdmin"; then
|
||||
# printf "\\r[FAIL] Fetch ${URL}\\n"
|
||||
# curl -sS localhost/${URL} || true
|
||||
# curl -sSI localhost/${URL} || true
|
||||
# exit 1
|
||||
# else
|
||||
# printf "\\r[OK] Fetch ${URL} (3 rounds)\\n"
|
||||
# fi
|
||||
# else
|
||||
# printf "\\r[OK] Fetch ${URL} (2 rounds)\\n"
|
||||
# fi
|
||||
#else
|
||||
# printf "\\r[OK] Fetch ${URL} (1 round)\\n"
|
||||
#fi
|
||||
#
|
||||
#
|
||||
####
|
||||
#### Login
|
||||
####
|
||||
#
|
||||
#TOKEN=
|
||||
#printf "[TEST] Retrieve phpMyAdmin login page"
|
||||
#while true; do
|
||||
# # Try again until it succeeds
|
||||
# if ! CONTENT="$( curl -sS -c cookie.txt localhost${URL} )"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "e"
|
||||
# continue;
|
||||
# fi
|
||||
# # Extract the token
|
||||
# if ! TOKEN="$( echo "${CONTENT}" \
|
||||
# | grep -Eo "name=\"token\" value=\".+\"" \
|
||||
# | head -1 \
|
||||
# | grep -Eo "value=\".+\"" \
|
||||
# | sed -e 's/^value="//g' -e 's/"$//g' )"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "w"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '!'
|
||||
# if echo "${TOKEN}" | grep -q "!"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "!"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '&'
|
||||
# if echo "${TOKEN}" | grep -q "&"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "&"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '?'
|
||||
# if echo "${TOKEN}" | grep -q "?"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "?"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '"'
|
||||
# if echo "${TOKEN}" | grep -q "\""; then
|
||||
# rm -f cookie.txt
|
||||
# printf "\""
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '
|
||||
# if echo "${TOKEN}" | grep -q "'"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "'"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '@'
|
||||
# if echo "${TOKEN}" | grep -q "@"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "@"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '\'
|
||||
# if echo "${TOKEN}" | grep -q "\\\\"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "\\"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '='
|
||||
# if echo "${TOKEN}" | grep -q "="; then
|
||||
# rm -f cookie.txt
|
||||
# printf "="
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '`'
|
||||
# if echo "${TOKEN}" | grep -q "\`"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "\`"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '+'
|
||||
# if echo "${TOKEN}" | grep -q "+"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "+"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain ';'
|
||||
# if echo "${TOKEN}" | grep -q ";"; then
|
||||
# rm -f cookie.txt
|
||||
# printf ";"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '%'
|
||||
# if echo "${TOKEN}" | grep -q "%"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "%%"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain ']'
|
||||
# if echo "${TOKEN}" | grep -q "\]"; then
|
||||
# rm -f cookie.txt
|
||||
# printf "\]"
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '['
|
||||
# if echo "${TOKEN}" | grep -q "\["; then
|
||||
# rm -f cookie.txt
|
||||
# printf "\["
|
||||
# continue;
|
||||
# fi
|
||||
# # Ensure Token does not contain '$'
|
||||
# if echo "${TOKEN}" | grep -q '\$'; then
|
||||
# rm -f cookie.txt
|
||||
# printf '\$'
|
||||
# continue;
|
||||
# fi
|
||||
#
|
||||
# # All set
|
||||
# break
|
||||
#done
|
||||
#printf "\\r[OK] Retrieve phpMyAdmin login page\r\\n"
|
||||
#
|
||||
#
|
||||
#printf "[TEST] Exract phpMyAdmin login token"
|
||||
#if ! TOKEN="$( echo "${CONTENT}" \
|
||||
# | grep -Eo "name=\"token\" value=\".+\"" \
|
||||
# | head -1 \
|
||||
# | grep -Eo "value=\".+\"" \
|
||||
# | sed -e 's/^value="//g' -e 's/"$//g' )"; then
|
||||
# printf "\\r[FAIL] Exract phpMyAdmin login token\\n"
|
||||
# rm -f cookie.txt || true
|
||||
# echo "${CONTENT}"
|
||||
# exit 1
|
||||
#fi
|
||||
#printf "\\r[OK] Exract phpMyAdmin login token: \"%s\"\\n" "${TOKEN}"
|
||||
#
|
||||
#printf "[TEST] Extract phpMyAdmin login session"
|
||||
#if ! SESSION="$( echo "${CONTENT}" \
|
||||
# | grep -Eo "name=\"set_session\" value=\"[A-Fa-f0-9]+\"" \
|
||||
# | grep -Eo "value=\"[A-Fa-f0-9]+\"" \
|
||||
# | sed -e 's/^value="//g' -e 's/"$//g' )"; then
|
||||
# printf "\\r[OK] Extract phpMyAdmin login session (not available)\\n"
|
||||
# SESSION=""
|
||||
#else
|
||||
# printf "\\r[OK] Extract phpMyAdmin login session: \"%s\"\\n" "${SESSION}"
|
||||
#fi
|
||||
#
|
||||
#
|
||||
#printf "[TEST] Submit phpMyAdmin POST login"
|
||||
## 1st Try
|
||||
#if ! curl -sS -c cookie.txt -b cookie.txt -d "pma_username=root&pma_password=&server=1&target=index.php&token=${TOKEN}&set_session=${SESSION}" localhost${URL}; then
|
||||
# # 2nd Try
|
||||
# sleep 1
|
||||
# if ! curl -sS -c cookie.txt -b cookie.txt -d "pma_username=root&pma_password=&server=1&target=index.php&token=${TOKEN}&set_session=${SESSION}" localhost${URL}; then
|
||||
# # 3rd Try
|
||||
# sleep 1
|
||||
# if ! curl -sS -c cookie.txt -b cookie.txt -d "pma_username=root&pma_password=&server=1&target=index.php&token=${TOKEN}&set_session=${SESSION}" localhost${URL}; then
|
||||
# printf "\\r[FAIL] Submit phpMyAdmin POST login\\n"
|
||||
# curl -sS -c cookie.txt -b cookie.txt localhost/${URL} || true
|
||||
# curl -sSI -c cookie.txt -b cookie.txt localhost/${URL} || true
|
||||
# rm -f cookie.txt || true
|
||||
# exit 1
|
||||
# else
|
||||
# printf "\\r[OK] Submit phpMyAdmin POST login (3 rounds)\\n"
|
||||
# fi
|
||||
# else
|
||||
# printf "\\r[OK] Submit phpMyAdmin POST login (2 rounds)\\n"
|
||||
# fi
|
||||
#else
|
||||
# printf "\\r[OK] Submit phpMyAdmin POST login (1 round)\\n"
|
||||
#fi
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT: Configuration file
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
###
|
||||
### Configuration File
|
||||
###
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
DVLBOXPATH="${SCRIPTPATH}/../../"
|
||||
CONFIGPATH="${DVLBOXPATH}/.devilbox/www/htdocs${URL%index\.php}config.inc.php"
|
||||
@ -386,8 +193,188 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT: Login Check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Evaluate if we're logged in
|
||||
### Autologin disabled
|
||||
###
|
||||
if [ "${DEVILBOX_VENDOR_PHPMYADMIN_AUTOLOGIN}" != "1" ]; then
|
||||
|
||||
###
|
||||
### Ensure given phpMyAdmin version works
|
||||
###
|
||||
printf "[TEST] Fetch %s" "${URL}"
|
||||
if ! run "curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}${URL}' | tac | tac | grep -Ei 'welcome to.+phpMyAdmin' >/dev/null" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Fetch %s\\n" "${URL}"
|
||||
run "curl -sS 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
|
||||
run "curl -sSI 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Fetch %s\\n" "${URL}"
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Login
|
||||
###
|
||||
TOKEN=
|
||||
printf "[TEST] Retrieve phpMyAdmin login page"
|
||||
while true; do
|
||||
# Try again until it succeeds
|
||||
if ! CONTENT="$( curl -sS --fail -c cookie.txt "http://localhost:${HOST_PORT_HTTPD}${URL}" )"; then
|
||||
rm -f cookie.txt
|
||||
printf "e"
|
||||
continue;
|
||||
fi
|
||||
# Extract the token
|
||||
if ! TOKEN="$( echo "${CONTENT}" \
|
||||
| grep -Eo "name=\"token\" value=\".+\"" \
|
||||
| head -1 \
|
||||
| grep -Eo "value=\".+\"" \
|
||||
| sed -e 's/^value="//g' -e 's/"$//g' )"; then
|
||||
rm -f cookie.txt
|
||||
printf "w"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '!'
|
||||
if echo "${TOKEN}" | grep -q "!"; then
|
||||
rm -f cookie.txt
|
||||
printf "!"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '&'
|
||||
if echo "${TOKEN}" | grep -q "&"; then
|
||||
rm -f cookie.txt
|
||||
printf "&"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '?'
|
||||
if echo "${TOKEN}" | grep -q "?"; then
|
||||
rm -f cookie.txt
|
||||
printf "?"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '"'
|
||||
if echo "${TOKEN}" | grep -q "\""; then
|
||||
rm -f cookie.txt
|
||||
printf "\""
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '
|
||||
if echo "${TOKEN}" | grep -q "'"; then
|
||||
rm -f cookie.txt
|
||||
printf "'"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '@'
|
||||
if echo "${TOKEN}" | grep -q "@"; then
|
||||
rm -f cookie.txt
|
||||
printf "@"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '\'
|
||||
if echo "${TOKEN}" | grep -q "\\\\"; then
|
||||
rm -f cookie.txt
|
||||
printf "\\"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '='
|
||||
if echo "${TOKEN}" | grep -q "="; then
|
||||
rm -f cookie.txt
|
||||
printf "="
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '`'
|
||||
if echo "${TOKEN}" | grep -q "\`"; then
|
||||
rm -f cookie.txt
|
||||
printf "\`"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '+'
|
||||
if echo "${TOKEN}" | grep -q "+"; then
|
||||
rm -f cookie.txt
|
||||
printf "+"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain ';'
|
||||
if echo "${TOKEN}" | grep -q ";"; then
|
||||
rm -f cookie.txt
|
||||
printf ";"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '%'
|
||||
if echo "${TOKEN}" | grep -q "%"; then
|
||||
rm -f cookie.txt
|
||||
printf "%%"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain ']'
|
||||
if echo "${TOKEN}" | grep -q "\\]"; then
|
||||
rm -f cookie.txt
|
||||
printf "\\]"
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '['
|
||||
if echo "${TOKEN}" | grep -q "\\["; then
|
||||
rm -f cookie.txt
|
||||
printf "\\["
|
||||
continue;
|
||||
fi
|
||||
# Ensure Token does not contain '$'
|
||||
if echo "${TOKEN}" | grep -q '\$'; then
|
||||
rm -f cookie.txt
|
||||
printf '\$'
|
||||
continue;
|
||||
fi
|
||||
|
||||
# All set
|
||||
break
|
||||
done
|
||||
printf "\\r[OK] Retrieve phpMyAdmin login page\\r\\n"
|
||||
|
||||
|
||||
printf "[TEST] Exract phpMyAdmin login token"
|
||||
if ! TOKEN="$( echo "${CONTENT}" \
|
||||
| grep -Eo "name=\"token\" value=\".+\"" \
|
||||
| head -1 \
|
||||
| grep -Eo "value=\".+\"" \
|
||||
| sed -e 's/^value="//g' -e 's/"$//g' )"; then
|
||||
printf "\\r[FAIL] Exract phpMyAdmin login token\\n"
|
||||
rm -f cookie.txt || true
|
||||
echo "${CONTENT}"
|
||||
exit 1
|
||||
fi
|
||||
printf "\\r[OK] Exract phpMyAdmin login token: \"%s\"\\n" "${TOKEN}"
|
||||
|
||||
printf "[TEST] Extract phpMyAdmin login session"
|
||||
if ! SESSION="$( echo "${CONTENT}" \
|
||||
| grep -Eo "name=\"set_session\" value=\"[A-Fa-f0-9]+\"" \
|
||||
| grep -Eo "value=\"[A-Fa-f0-9]+\"" \
|
||||
| sed -e 's/^value="//g' -e 's/"$//g' )"; then
|
||||
printf "\\r[OK] Extract phpMyAdmin login session (not available)\\n"
|
||||
SESSION=""
|
||||
else
|
||||
printf "\\r[OK] Extract phpMyAdmin login session: \"%s\"\\n" "${SESSION}"
|
||||
fi
|
||||
|
||||
|
||||
printf "[TEST] Submit phpMyAdmin POST login"
|
||||
if ! run "curl -sS --fail -c cookie.txt -b cookie.txt -d 'pma_username=root&pma_password=${MYSQL_ROOT_PASSWORD}&server=1&target=index.php&token=${TOKEN}&set_session=${SESSION}' 'http://localhost:${HOST_PORT_HTTPD}${URL}'" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Submit phpMyAdmin POST login\\n"
|
||||
run "curl -sS -c cookie.txt -b cookie.txt 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
|
||||
run "curl -sSI -c cookie.txt -b cookie.txt 'http://localhost:${HOST_PORT_HTTPD}${URL}' || true"
|
||||
rm -f cookie.txt || true
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Submit phpMyAdmin POST login\\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Check if login works
|
||||
###
|
||||
printf "[TEST] Evaluate successful phpMyAdmin login"
|
||||
if [ "$( run "\
|
||||
|
@ -42,12 +42,17 @@ fi
|
||||
### Get required env values
|
||||
###
|
||||
HOST_PORT_HTTPD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "HOST_PORT_HTTPD" )"
|
||||
PGSQL_ROOT_USER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PGSQL_ROOT_USER" )"
|
||||
PGSQL_ROOT_PASSWORD="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PGSQL_ROOT_PASSWORD" )"
|
||||
DEVILBOX_VENDOR_PHPPGADMIN_AUTOLOGIN="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "DEVILBOX_VENDOR_PHPPGADMIN_AUTOLOGIN" )"
|
||||
|
||||
|
||||
###
|
||||
### Retrieve URL for current PHP version.
|
||||
### Older PHP versions are presented a link with a different version due to compatibility.
|
||||
###
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT: Version
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
# Retrieve URL for current PHP version.
|
||||
# Older PHP versions are presented a link with a different version due to compatibility.
|
||||
printf "[TEST] Retrieve phpPgAdmin URL"
|
||||
if ! URL="$( run "\
|
||||
curl -sS --fail 'http://localhost:${HOST_PORT_HTTPD}/index.php' \
|
||||
@ -90,116 +95,10 @@ else
|
||||
fi
|
||||
|
||||
|
||||
####
|
||||
#### Login (get token URL)
|
||||
####
|
||||
## 1st Try
|
||||
#printf "[TEST] Retrieve phpPgAdmin token page"
|
||||
#if ! TOKEN_URL="$( curl -sS -c cookie.txt localhost${URL}servers.php | tac | tac | grep -Eo "\"redirect\.php\?subject=server.+\"" )"; then
|
||||
# # 2nd Try
|
||||
# sleep 1
|
||||
# if ! TOKEN_URL="$( curl -sS -c cookie.txt localhost${URL}servers.php | tac | tac | grep -Eo "\"redirect\.php\?subject=server.+\"" )"; then
|
||||
# # 3rd Try
|
||||
# sleep 1
|
||||
# if ! TOKEN_URL="$( curl -sS -c cookie.txt localhost${URL}servers.php | tac | tac | grep -Eo "\"redirect\.php\?subject=server.+\"" )"; then
|
||||
# printf "\\r[FAIL] Retrieve phpPgAdmin login page\\n"
|
||||
# curl -sS localhost/${URL}servers.php || true
|
||||
# curl -sSI localhost/${URL}servers.php || true
|
||||
# rm -f cookie.txt
|
||||
# exit 1
|
||||
# else
|
||||
# TOKEN_URL="$( echo "${TOKEN_URL}" | sed 's/"//g' )"
|
||||
# TOKEN_URL="$( echo "${TOKEN_URL}" | sed 's/&/\&/g' )"
|
||||
# printf "\\r[OK] Retrieve phpPgAdmin token page (3 rounds): ${TOKEN_URL}\\n"
|
||||
# fi
|
||||
# else
|
||||
# TOKEN_URL="$( echo "${TOKEN_URL}" | sed 's/"//g' )"
|
||||
# TOKEN_URL="$( echo "${TOKEN_URL}" | sed 's/&/\&/g' )"
|
||||
# printf "\\r[OK] Retrieve phpPgAdmin login token (2 rounds): ${TOKEN_URL}\\n"
|
||||
# fi
|
||||
#else
|
||||
# TOKEN_URL="$( echo "${TOKEN_URL}" | sed 's/"//g' )"
|
||||
# TOKEN_URL="$( echo "${TOKEN_URL}" | sed 's/&/\&/g' )"
|
||||
# printf "\\r[OK] Retrieve phpPgAdmin token page (1 round): ${TOKEN_URL}\\n"
|
||||
#fi
|
||||
#
|
||||
#
|
||||
####
|
||||
#### Login (get Login Token)
|
||||
####
|
||||
#TOKEN=
|
||||
#printf "[TEST] Retrieve phpPgAdmin login token"
|
||||
## 1st Try
|
||||
#if ! TOKEN="$( curl -sS -c cookie.txt -b cookie.txt "localhost${URL}${TOKEN_URL}" | tac | tac | grep -Eo "loginPassword_[a-zA-Z0-9]+" )"; then
|
||||
# # 2nd Try
|
||||
# sleep 1
|
||||
# if ! TOKEN="$( curl -sS -c cookie.txt -b cookie.txt "localhost${URL}${TOKEN_URL}" | tac | tac | grep -Eo "loginPassword_[a-zA-Z0-9]+" )"; then
|
||||
# # 3rd Try
|
||||
# sleep 1
|
||||
# if ! TOKEN="$( curl -sS -c cookie.txt -b cookie.txt "localhost${URL}${TOKEN_URL}" | tac | tac | grep -Eo "loginPassword_[a-zA-Z0-9]+" )"; then
|
||||
# printf "\\r[FAIL] Retrieve phpPgAdmin login token\\n"
|
||||
# curl -sS "${TOKEN_URL_URL}" || true
|
||||
# curl -sSI "${TOKEN_URL_URL}" || true
|
||||
# rm -f cookie.txt
|
||||
# exit 1
|
||||
# else
|
||||
# TOKEN="$( echo "${TOKEN}" | head -1 )"
|
||||
# printf "\\r[OK] Retrieve phpPgAdmin login token (3 rounds): ${TOKEN}\\n"
|
||||
# fi
|
||||
# else
|
||||
# TOKEN="$( echo "${TOKEN}" | head -1 )"
|
||||
# printf "\\r[OK] Retrieve phpPgAdmin login token (2 rounds): ${TOKEN}\\n"
|
||||
# fi
|
||||
#else
|
||||
# TOKEN="$( echo "${TOKEN}" | head -1 )"
|
||||
# printf "\\r[OK] Retrieve phpPgAdmin login token (1 round): ${TOKEN}\\n"
|
||||
#fi
|
||||
#
|
||||
#
|
||||
####
|
||||
#### Login
|
||||
####
|
||||
#
|
||||
#printf "[TEST] Submit phpPgAdmin POST login"
|
||||
## 1st Try
|
||||
#if ! curl -sS -c cookie.txt -b cookie.txt \
|
||||
# -d "subject=server&server=pgsql%3A5432%3Aallow&loginServer=pgsql%3A5432%3Aallow&loginUsername=postgres&${TOKEN}=&loginSubmit=Login" \
|
||||
# localhost${URL}redirect.php 2>/dev/null | grep -q "Create database"; then
|
||||
# # 2nd Try
|
||||
# sleep 1
|
||||
# if ! curl -sS -c cookie.txt -b cookie.txt \
|
||||
# -d "subject=server&server=pgsql%3A5432%3Aallow&loginServer=pgsql%3A5432%3Aallow&loginUsername=postgres&${TOKEN}=&loginSubmit=Login" \
|
||||
# localhost${URL}redirect.php 2>/dev/null | grep -q "Create database"; then
|
||||
# # 3rd Try
|
||||
# sleep 1
|
||||
# if ! curl -sS -c cookie.txt -b cookie.txt \
|
||||
# -d "subject=server&server=pgsql%3A5432%3Aallow&loginServer=pgsql%3A5432%3Aallow&loginUsername=postgres&${TOKEN}=&loginSubmit=Login" \
|
||||
# localhost${URL}redirect.php 2>/dev/null | grep -q "Create database"; then
|
||||
# printf "\\r[FAIL] Submit phpPgAdmin POST login\\n"
|
||||
# curl -sS -c cookie.txt -b cookie.txt \
|
||||
# -d "subject=server&server=pgsql%3A5432%3Aallow&loginServer=pgsql%3A5432%3Aallow&loginUsername=postgres&${TOKEN}=&loginSubmit=Login" \
|
||||
# localhost${URL}redirect.php || true
|
||||
# curl -sSI -c cookie.txt -b cookie.txt \
|
||||
# -d "subject=server&server=pgsql%3A5432%3Aallow&loginServer=pgsql%3A5432%3Aallow&loginUsername=postgres&${TOKEN}=&loginSubmit=Login" \
|
||||
# localhost${URL}redirect.php || true
|
||||
# rm -f cookie.txt || true
|
||||
# exit 1
|
||||
# else
|
||||
# printf "\\r[OK] Submit phpPgAdmin POST login (3 rounds)\\n"
|
||||
# fi
|
||||
# else
|
||||
# printf "\\r[OK] Submit phpPgAdmin POST login (2 rounds)\\n"
|
||||
# fi
|
||||
#else
|
||||
# printf "\\r[OK] Submit phpPgAdmin POST login (1 round)\\n"
|
||||
#fi
|
||||
#
|
||||
#rm -f cookie.txt || true
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT: Configuration file
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
###
|
||||
### Configuration File
|
||||
###
|
||||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
DVLBOXPATH="${SCRIPTPATH}/../../"
|
||||
CONFIGPATH="${DVLBOXPATH}/.devilbox/www/htdocs${URL%index\.php}conf/config.inc.php"
|
||||
@ -250,28 +149,103 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
# ENTRYPOINT: Login Check
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
###
|
||||
### Autologin disabled
|
||||
###
|
||||
if [ "${DEVILBOX_VENDOR_PHPPGADMIN_AUTOLOGIN}" != "1" ]; then
|
||||
|
||||
###
|
||||
### Login (get token URL)
|
||||
###
|
||||
printf "[TEST] Retrieve phpPgAdmin token page"
|
||||
if ! TOKEN_URL="$( run "curl -sS --fail -c cookie.txt 'http://localhost:${HOST_PORT_HTTPD}${URL}servers.php' | tac | tac | grep -Eo '\"redirect\\.php\\?subject=server.+\"' " "${RETRIES}" "" "0" )"; then
|
||||
printf "\\r[FAIL] Retrieve phpPgAdmin login page\\n"
|
||||
run "curl -sS 'http://localhost:${HOST_PORT_HTTPD}${URL}servers.php' || true"
|
||||
run "curl -sSI 'http://localhost:${HOST_PORT_HTTPD}${URL}servers.php' || true"
|
||||
rm -f cookie.txt
|
||||
exit 1
|
||||
else
|
||||
TOKEN_URL="${TOKEN_URL//\"/}"
|
||||
TOKEN_URL="${TOKEN_URL//&/&}"
|
||||
printf "\\r[OK] Retrieve phpPgAdmin token page:%s\\n" "${TOKEN_URL}"
|
||||
fi
|
||||
|
||||
###
|
||||
### Login (get Login Token)
|
||||
###
|
||||
printf "[TEST] Retrieve phpPgAdmin login token"
|
||||
# 1st Try
|
||||
if ! TOKEN="$( run "curl -sS --fail -c cookie.txt -b cookie.txt 'http://localhost:${HOST_PORT_HTTPD}${URL}${TOKEN_URL}' | tac | tac | grep -Eo 'loginPassword_[a-zA-Z0-9]+'" "${RETRIES}" "" "0" )"; then
|
||||
printf "\\r[FAIL] Retrieve phpPgAdmin login token\\n"
|
||||
run "curl -sS 'http://localhost:${TOKEN_URL_URL}' || true"
|
||||
run "curl -sSI 'http://localhost:${TOKEN_URL_URL}' || true"
|
||||
rm -f cookie.txt
|
||||
exit 1
|
||||
else
|
||||
TOKEN="$( echo "${TOKEN}" | head -1 )"
|
||||
printf "\\r[OK] Retrieve phpPgAdmin login token: %s\\n" "${TOKEN}"
|
||||
fi
|
||||
|
||||
###
|
||||
### Login
|
||||
###
|
||||
printf "[TEST] Submit phpPgAdmin POST login"
|
||||
# 1st Try
|
||||
if ! run "curl -sS --fail -c cookie.txt -b cookie.txt \
|
||||
--data 'subject=server' \
|
||||
--data 'server=pgsql%3A5432%3Aallow' \
|
||||
--data 'loginServer=pgsql%3A5432%3Aallow' \
|
||||
--data 'loginUsername=${PGSQL_ROOT_USER}' \
|
||||
--data '${TOKEN}=${PGSQL_ROOT_PASSWORD}' \
|
||||
--data 'loginSubmit=Login' \
|
||||
'http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php' 2>/dev/null \
|
||||
| grep -q 'Create database'" "${RETRIES}" "" "0"; then
|
||||
printf "\\r[FAIL] Submit phpPgAdmin POST login\\n"
|
||||
run "curl -sS -c cookie.txt -b cookie.txt \
|
||||
--data 'subject=server' \
|
||||
--data 'server=pgsql%3A5432%3Aallow' \
|
||||
--data 'loginServer=pgsql%3A5432%3Aallow' \
|
||||
--data 'loginUsername=${PGSQL_ROOT_USER}' \
|
||||
--data '${TOKEN}=${PGSQL_ROOT_PASSWORD}' \
|
||||
--data 'loginSubmit=Login' \
|
||||
'http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php 2>/dev/null'"
|
||||
run "curl -sS -I -c cookie.txt -b cookie.txt \
|
||||
--data 'subject=server' \
|
||||
--data 'server=pgsql%3A5432%3Aallow' \
|
||||
--data 'loginServer=pgsql%3A5432%3Aallow' \
|
||||
--data 'loginUsername=${PGSQL_ROOT_USER}' \
|
||||
--data '${TOKEN}=${PGSQL_ROOT_PASSWORD}' \
|
||||
--data 'loginSubmit=Login' \
|
||||
'http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php 2>/dev/null'"
|
||||
rm -f cookie.txt || true
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Submit phpPgAdmin POST login\\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
### Evaluate successful phpPgAdmin login
|
||||
###
|
||||
printf "[TEST] Evaluate successful phpPgAdmin login"
|
||||
# 1st Try
|
||||
if [ "$(curl -sS --fail "http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
# 2nd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS --fail "http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
# 3rd Try
|
||||
sleep 1
|
||||
if [ "$(curl -sS --fail "http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" | tac | tac | grep -Ec 'data">(Database|Owner|Collation|Tablespace)')" != "4" ]; then
|
||||
printf "\\r[FAIL] Evaluate successful phpPgAdmin login\\n"
|
||||
curl -sS "http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" || true
|
||||
curl -sS -I "http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&" || true
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Evaluate successful phpPgAdmin login (3 rounds)\\n"
|
||||
fi
|
||||
else
|
||||
printf "\\r[OK] Evaluate successful phpPgAdmin login (2 rounds)\\n"
|
||||
fi
|
||||
if [ "$( run "curl -sS --fail \
|
||||
-c cookie.txt \
|
||||
-b cookie.txt \
|
||||
'http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&' \
|
||||
| tac \
|
||||
| tac \
|
||||
| grep -Ec 'data\">(Database|Owner|Collation|Tablespace)'" "${RETRIES}" "" "0" )" != "4" ]; then
|
||||
printf "\\r[FAIL] Evaluate successful phpPgAdmin login\\n"
|
||||
run "curl -sS 'http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&' || true"
|
||||
run "curl -sS -I 'http://localhost:${HOST_PORT_HTTPD}${URL}redirect.php?subject=server&server=pgsql%3A5432%3Aallow&' || true"
|
||||
rm -f cookie.txt || true
|
||||
exit 1
|
||||
else
|
||||
printf "\\r[OK] Evaluate successful phpPgAdmin login (1 round)\\n"
|
||||
printf "\\r[OK] Evaluate successful phpPgAdmin login\\n"
|
||||
fi
|
||||
rm -f cookie.txt || true
|
||||
|
Loading…
Reference in New Issue
Block a user