Skip to content

Commit 5c47d5e

Browse files
authored
Some left overs from the old admin user still remaind (hestiacp#4721)
When using a custom admin user this was causing issues
1 parent c3641be commit 5c47d5e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

bin/v-add-sys-pma-sso

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ fi
6262

6363
# Generate the keys to secure everything
6464
phpmyadminkey=$(generate_password)
65-
apikey=$($BIN/v-add-access-key 'admin' 'phpmyadmin-sso' 'phpMyAdmin' 'plain')
65+
apikey=$($BIN/v-add-access-key "$ROOT_USER" 'phpmyadmin-sso' 'phpMyAdmin' 'plain')
6666

6767
# copy config dir to /usr/share/phpmyadmin/
6868
cp -f $HESTIA_INSTALL_DIR/phpmyadmin/hestia-sso.php $PMA_INSTALL/hestia-sso.php
6969
chmod 640 $PMA_INSTALL/hestia-sso.php
70-
chown root:www-data $PMA_INSTALL/hestia-sso.php
70+
chown root:hestiamail $PMA_INSTALL/hestia-sso.php
7171

7272
sed -i "s/%PHPMYADMIN_KEY%/$phpmyadminkey/g" $PMA_INSTALL/hestia-sso.php
7373
sed -i "s/%API_KEY%/$apikey/g" $PMA_INSTALL/hestia-sso.php
@@ -77,7 +77,7 @@ sed -i "s/%API_HESTIA_PORT%/$BACKEND_PORT/g" $PMA_INSTALL/hestia-sso.php
7777
# Check if config already contains the keys
7878
touch $PMA_CONFIG/hestia-sso.inc.php
7979
chmod 640 $PMA_CONFIG/hestia-sso.inc.php
80-
chown root:www-data $PMA_CONFIG/hestia-sso.inc.php
80+
chown root:hestiamail $PMA_CONFIG/hestia-sso.inc.php
8181

8282
echo "<?php
8383
if(isset(\$_GET['hestia_token']) || isset(\$_COOKIE['SignonSession'])){

web/api/index.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ function api_legacy(array $request_data) {
110110
unset($output);
111111
exec(
112112
HESTIA_CMD .
113-
'v-check-user-password "admin" ' .
113+
"v-check-user-password " .
114+
quoteshellarg($root_user) .
115+
" " .
114116
quoteshellarg($v_password) .
115117
" " .
116118
$v_ip .
@@ -222,7 +224,7 @@ function api_connection(array $request_data) {
222224
exec(HESTIA_CMD . "v-list-sys-config json", $output, $return_var);
223225
$settings = json_decode(implode("", $output), true);
224226
unset($output, $return_var);
225-
227+
$root_user = $settings["config"]["ROOT_USER"];
226228
// Get the status of api
227229
$api_status =
228230
!empty($settings["config"]["API_SYSTEM"]) && is_numeric($settings["config"]["API_SYSTEM"])
@@ -292,13 +294,13 @@ function api_connection(array $request_data) {
292294
: -1;
293295

294296
# Check if API access is enabled for nonadmin users
295-
if ($key_user != "admin" && $api_status < 2) {
297+
if ($key_user != $root_user && $api_status < 2) {
296298
api_error(E_API_DISABLED, "API has been disabled", $hst_return);
297299
}
298300

299301
// Checks if the value entered in the "user" argument matches the user of the key
300302
if (
301-
$key_user != "admin" &&
303+
$key_user != $root_user &&
302304
$user_arg_position > 0 &&
303305
$hst_cmd_args["arg{$user_arg_position}"] != $key_user
304306
) {

0 commit comments

Comments
 (0)