Skip to content

Commit d7cfe44

Browse files
authored
Replace admin user with "hestiaweb" and new "user" (hestiacp#3855)
* Update debian.sh * Go trough all scripts to remove admin user * Update more scripts * Complete /bin/ * /func folder * Run php under hestiaweb user * Fix check password * Patch few bugs in installer * For got to update hestia-nginx * Update post install scripts * Forgot some usage of "admin" in upgrade.sh * Run via /var/spool/cron/crontabs/hestiaweb * Update Ubuntu installer * Delete hard coded admin user and replace with variable * Update 1 more location Todo: api * Add root_user to v-list-sys-config * Update permissions filemanager Also removed unues install-fm * Update API to use new admin user * Remove "Unsafe warning" * Upgrade script * Fix upgrade script * Fix issue * Check if home dir exstis * Include sudo file + cronjobs * Fix cronjobs * Use correct path * Revert "Remove "Unsafe warning"" This reverts commit c2f2cca. * Add ROLE to sessions And use it in the checks * Add remove admin user for sudoers Keep enabled for now as it would prevent you from going to 1.8.x * set default new user package to "default" Also add upgrade notice... * Replace hardcode admin * Allow W = yes * remove extra line * Source conf after update * Fix bug with ROOT_USER not found on upgrade for the first time
1 parent a9d6bf1 commit d7cfe44

File tree

81 files changed

+428
-410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+428
-410
lines changed

bin/v-add-cron-hestia-autoupdate

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#----------------------------------------------------------#
1111

1212
# Argument definition
13-
user=admin
1413
mode=$1
1514

1615
# Includes
@@ -26,10 +25,8 @@ source_conf "$HESTIA/conf/hestia.conf"
2625
#----------------------------------------------------------#
2726

2827
is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM'
29-
is_package_full 'CRON_JOBS'
30-
get_next_cronjob
31-
check_cron_apt=$(grep 'v-update-sys-hestia-all' $USER_DATA/cron.conf)
32-
check_cron_git=$(grep 'v-update-sys-hestia-git' $USER_DATA/cron.conf)
28+
check_cron_apt=$(grep 'v-update-sys-hestia-all' "/var/spool/cron/crontabs/hestiaweb")
29+
check_cron_git=$(grep 'v-update-sys-hestia-git' "/var/spool/cron/crontabs/hestiaweb")
3330
if [ -n "$check_cron_apt" ] || [ -n "$check_cron_git" ]; then
3431
exit
3532
fi
@@ -53,7 +50,7 @@ if [ -z "$mode" ] || [ "$mode" = "apt" ]; then
5350
day='*'
5451
month='*'
5552
wday='*'
56-
command="sudo $BIN/v-update-sys-hestia-all"
53+
command='v-update-sys-hestia-all'
5754
fi
5855

5956
if [ "$mode" = "git" ]; then
@@ -62,32 +59,14 @@ if [ "$mode" = "git" ]; then
6259
day='*'
6360
month='*'
6461
wday='*'
65-
command="sudo $BIN/v-update-sys-hestia-git"
62+
command='v-update-sys-hestia-git'
6663
fi
6764

68-
# Concatenating cron string
69-
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"
70-
str="$str CMD='$command' SUSPENDED='no' TIME='$time' DATE='$date'"
71-
72-
# Adding to crontab
73-
echo "$str" >> $HESTIA/data/users/$user/cron.conf
74-
75-
# Changing permissions
76-
chmod 660 $HESTIA/data/users/$user/cron.conf
77-
78-
# Sort jobs by id number
79-
sort_cron_jobs
80-
81-
# Sync cronjobs with system cron
82-
sync_cron_jobs
65+
echo "$min $hour * * * sudo /usr/local/hestia/bin/$command" > "/var/spool/cron/crontabs/hestiaweb"
8366

8467
#----------------------------------------------------------#
8568
# Hestia #
8669
#----------------------------------------------------------#
87-
88-
# Increasing cron value
89-
increase_user_value "$user" '$U_CRON_JOBS'
90-
9170
# Restarting cron
9271
$BIN/v-restart-cron
9372
check_result $? "Cron restart failed" > /dev/null

bin/v-add-cron-letsencrypt-job

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ check_hestia_demo_mode
3030
#----------------------------------------------------------#
3131

3232
# Add cron job
33-
cmd="sudo $BIN/v-update-sys-queue letsencrypt"
34-
check_cron=$(grep "$cmd" $HESTIA/data/users/admin/cron.conf 2> /dev/null)
33+
cmd="bin/v-update-sys-queue letsencrypt"
34+
check_cron=$(grep "$cmd" "/var/spool/cron/crontabs/hestiaweb" 2> /dev/null)
3535
if [ -z "$check_cron" ] && [ -n "$CRON_SYSTEM" ]; then
36-
$BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd"
36+
echo "*/5 * * * * sudo /usr/local/hestia/bin/v-update-sys-queue letsencrypt" >> "/var/spool/cron/crontabs/hestiaweb"
3737
fi
3838

3939
#----------------------------------------------------------#

bin/v-add-cron-restart-job

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ check_hestia_demo_mode
3030
#----------------------------------------------------------#
3131

3232
# Add cron job
33-
cmd="sudo $BIN/v-update-sys-queue restart"
34-
check_cron=$(grep "$cmd" $HESTIA/data/users/admin/cron.conf 2> /dev/null)
33+
cmd="v-update-sys-queue restart"
34+
check_cron=$(grep "$cmd" "/var/spool/cron/crontabs/hestiaweb" 2> /dev/null)
3535
if [ -z "$check_cron" ] && [ -n "$CRON_SYSTEM" ]; then
36-
$BIN/v-add-cron-job admin '*' '*' '*' '*' '*' "$cmd"
36+
echo "*/2 * * * * sudo /usr/local/hestia/bin/v-update-sys-queue restart" >> "/var/spool/cron/crontabs/hestiaweb"
3737
fi
3838

3939
#----------------------------------------------------------#

bin/v-add-letsencrypt-domain

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,10 @@ if [ "$?" -ne '0' ]; then
569569
fi
570570

571571
# Adding LE autorenew cronjob
572-
if [ -z "$(grep v-update-lets $HESTIA/data/users/admin/cron.conf)" ]; then
572+
if [ -z "$(grep v-update-letsen "$HESTIA/data/users/$ROOT_USER/cron.conf")" ]; then
573573
min=$(generate_password '012345' '2')
574574
hour=$(generate_password '1234567' '1')
575-
cmd="sudo $BIN/v-update-letsencrypt-ssl"
576-
$BIN/v-add-cron-job admin "$min" "$hour" '*' '*' '*' "$cmd" > /dev/null
575+
echo "$min $hour * * * sudo /usr/local/hestia/bin/v-update-letsencrypt-ssl" > /etc/cron.d/hestiaweb
577576
fi
578577

579578
# Updating letsencrypt key

bin/v-add-sys-dependencies

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ source_conf "$HESTIA/conf/hestia.conf"
1919
source "$HESTIA/install/upgrade/upgrade.conf"
2020

2121
MODE=$1
22-
user="admin"
22+
user="$ROOT_USER"
2323

2424
PM_INSTALL_DIR="$HESTIA/web/inc"
2525
QUICK_INSTALL_DIR="$HESTIA/web/src"
@@ -49,7 +49,7 @@ fi
4949
if [ ! -f "$COMPOSER_BIN" ]; then
5050
$BIN/v-add-user-composer "$user"
5151
if [ $? -ne 0 ]; then
52-
$BIN/v-add-user-notification admin 'Composer installation failed!' '<p class="u-text-bold">Hestia will not work without Composer.</p><p>Please try running the installer manually from a shell session:<br><code>v-add-sys-dependencies</code></p><p>If this continues, <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a>.</p>'
52+
$BIN/v-add-user-notification "$ROOT_USER" 'Composer installation failed!' '<p class="u-text-bold">Hestia will not work without Composer.</p><p>Please try running the installer manually from a shell session:<br><code>v-add-sys-dependencies</code></p><p>If this continues, <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a>.</p>'
5353
exit 1
5454
fi
5555
fi
@@ -78,7 +78,7 @@ if [ $? -ne 0 ]; then
7878
echo "ERROR: PHPMailer installation failed!"
7979
echo "Please report this to our development team:"
8080
echo "https://github.com/hestiacp/hestiacp/issues"
81-
$BIN/v-add-user-notification admin 'Hestia PHP dependencies installation failed!' '<p>Please <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a> to report this to our development team.</p>'
81+
$BIN/v-add-user-notification "$ROOT_USER" 'Hestia PHP dependencies installation failed!' '<p>Please <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a> to report this to our development team.</p>'
8282
# Installation failed, clean up files
8383
rm --recursive --force ${PM_INSTALL_DIR}/vendor
8484
$BIN/v-change-sys-config-value 'USE_SERVER_SMTP' 'n'

bin/v-add-sys-filemanager

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ source_conf "$HESTIA/conf/hestia.conf"
2020
source_conf "$HESTIA/install/upgrade/upgrade.conf"
2121

2222
MODE=$1
23-
user="admin"
23+
user="$ROOT_USER"
2424

2525
FM_INSTALL_DIR="$HESTIA/web/fm"
2626
FM_FILE="filegator_latest"
@@ -51,7 +51,7 @@ fi
5151
if [ ! -f "$COMPOSER_BIN" ]; then
5252
$BIN/v-add-user-composer "$user"
5353
if [ $? -ne 0 ]; then
54-
$BIN/v-add-user-notification admin 'Composer installation failed!' '<p class="u-text-bold">The File Manager will not work without Composer.</p><p>Please try running the installer manually from a shell session:<br><code>v-add-sys-filemanager</code></p><p>If this continues, <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a>.</p>'
54+
$BIN/v-add-user-notification "$ROOT_USER" 'Composer installation failed!' '<p class="u-text-bold">The File Manager will not work without Composer.</p><p>Please try running the installer manually from a shell session:<br><code>v-add-sys-filemanager</code></p><p>If this continues, <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a>.</p>'
5555
exit 1
5656
fi
5757
fi
@@ -91,7 +91,7 @@ if [ $? -ne 0 ]; then
9191
echo "ERROR: File Manager installation failed!"
9292
echo "Please report this to our development team:"
9393
echo "https://github.com/hestiacp/hestiacp/issues"
94-
$BIN/v-add-user-notification admin 'File Manager installation failed!' '<p>Please <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a> to report this to our development team.</p>'
94+
$BIN/v-add-user-notification "$ROOT_USER" 'File Manager installation failed!' '<p>Please <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a> to report this to our development team.</p>'
9595
# Installation failed, clean up files
9696
rm --recursive --force ${FM_INSTALL_DIR}
9797
$BIN/v-change-sys-config-value 'FILE_MANAGER' 'false'
@@ -105,9 +105,9 @@ cp -f $HESTIA_INSTALL_DIR/filemanager/filegator/configuration.php $HESTIA/web/fm
105105
echo "$fm_v" > "${FM_INSTALL_DIR}/version"
106106
# Set permissions
107107
chown root: -R "${FM_INSTALL_DIR}"
108-
chown $user: "${FM_INSTALL_DIR}/private"
109-
chown $user: "${FM_INSTALL_DIR}/private/logs"
110-
chown $user: "${FM_INSTALL_DIR}/repository"
108+
chown hestiaweb: "${FM_INSTALL_DIR}/private"
109+
chown hestiaweb: "${FM_INSTALL_DIR}/private/logs"
110+
chown hestiaweb: "${FM_INSTALL_DIR}/repository"
111111

112112
$BIN/v-change-sys-config-value 'FILE_MANAGER' 'true'
113113

bin/v-add-sys-ip

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if [ -z "$iface" ]; then
2828
fi
2929

3030
iface="${3-$iface}"
31-
user="${4-admin}"
31+
user="$4"
3232
ip_status="${5-shared}"
3333
ip_name="$6"
3434
nat_ip="$7"
@@ -47,6 +47,10 @@ source "$HESTIA/func/syshealth.sh"
4747
# load config file
4848
source_conf "$HESTIA/conf/hestia.conf"
4949

50+
if [ -z "$4" ]; then
51+
user="$ROOT_USER"
52+
fi
53+
5054
#----------------------------------------------------------#
5155
# Verifications #
5256
#----------------------------------------------------------#
@@ -62,7 +66,7 @@ fi
6266
if [ -n "$nat_ip" ]; then
6367
is_format_valid 'nat_ip'
6468
fi
65-
if [ "$user" != "admin" ]; then
69+
if [ "$user" != "$ROOT_USER" ]; then
6670
ip_status="dedicated"
6771
fi
6872

@@ -204,17 +208,17 @@ syshealth_adapt_hestia_nginx_listen_ports
204208

205209
# Updating user counters
206210
increase_user_value "$user" '$IP_OWNED'
207-
if [ "$user" = 'admin' ]; then
211+
if [ "$user" = $ROOT_USER ]; then
208212
if [ "$ip_status" = 'shared' ]; then
209213
for hestia_user in $($BIN/v-list-sys-users plain); do
210214
increase_user_value "$hestia_user" '$IP_AVAIL'
211215
done
212216
else
213-
increase_user_value 'admin' '$IP_AVAIL'
217+
increase_user_value $ROOT_USER '$IP_AVAIL'
214218
fi
215219
else
216220
increase_user_value "$user" '$IP_AVAIL'
217-
increase_user_value 'admin' '$IP_AVAIL'
221+
increase_user_value $ROOT_USER '$IP_AVAIL'
218222
fi
219223

220224
# Restarting web server

bin/v-add-sys-sftp-jail

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fi
5858
# Validating opensshd config
5959
if [ "$restart" = 'yes' ]; then
6060
subj="OpenSSH restart failed"
61-
email=$(grep CONTACT $HESTIA/data/users/admin/user.conf | cut -f 2 -d \')
61+
email=$(grep CONTACT "$HESTIA/data/users/$ROOT_USER/user.conf" | cut -f 2 -d \')
6262
/usr/sbin/sshd -t > /dev/null 2>&1
6363
if [ "$?" -ne 0 ]; then
6464
mail_text="OpenSSH can not be restarted. Please check config:
@@ -72,8 +72,10 @@ fi
7272
# Checking users
7373
shells="rssh|nologin"
7474
for user in $(grep "$HOMEDIR" /etc/passwd | egrep "$shells" | cut -f 1 -d:); do
75-
# Include all users v-add-user-sftp-jail will handle it
76-
$BIN/v-add-user-sftp-jail "$user" "no"
75+
if [ -d "/home/$user" ]; then
76+
# Include all users v-add-user-sftp-jail will handle it
77+
$BIN/v-add-user-sftp-jail "$user" "no"
78+
fi
7779
done
7880

7981
# Restart ssh service

bin/v-add-user

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# info: add system user
33
# options: USER PASSWORD EMAIL [PACKAGE] [NAME] [LASTNAME]
44
#
5-
# example: v-add-user admin2 P4$$w@rD bgates@aol.com
5+
# example: v-add-user user P4$$w@rD bgates@aol.com
66
#
77
# This function creates new user account.
88

@@ -92,8 +92,8 @@ if [ -z "$(grep ^hestia-users: /etc/group)" ]; then
9292
fi
9393

9494
# Add membership to hestia-users group to non-admin users
95-
if [ "$user" = "admin" ]; then
96-
setfacl -m "g:admin:r-x" "$HOMEDIR/$user"
95+
if [ "$user" = "$ROOT_USER" ]; then
96+
setfacl -m "g:$ROOT_USER:r-x" "$HOMEDIR/$user"
9797
else
9898
usermod -a -G "hestia-users" "$user"
9999
setfacl -m "u:$user:r-x" "$HOMEDIR/$user"
@@ -198,8 +198,8 @@ time=$(echo "$time_n_date" | cut -f 1 -d \ )
198198
date=$(echo "$time_n_date" | cut -f 2 -d \ )
199199

200200
# Filling user config
201-
if [ "$user" != 'admin' ]; then
202-
ip_avail=$($BIN/v-list-user-ips admin plain | grep -w shared | wc -l)
201+
if [ "$user" != "$ROOT_USER" ]; then
202+
ip_avail=$($BIN/v-list-user-ips "$ROOT_USER" plain | grep -w shared | wc -l)
203203
u_users=0
204204
else
205205
ip_avail=0
@@ -262,8 +262,8 @@ if [ "$DISK_QUOTA" = 'yes' ]; then
262262
fi
263263

264264
# Updating admin counter
265-
if [ "$user" != 'admin' ]; then
266-
increase_user_value 'admin' '$U_USERS'
265+
if [ "$user" != "$ROOT_USER" ]; then
266+
increase_user_value "$ROOT_USER" '$U_USERS'
267267
fi
268268

269269
# Run template trigger

bin/v-backup-user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ start_time=$(date '+%s')
174174

175175
# Set notification email and subject
176176
subj="$user → backup failed"
177-
email=$(grep CONTACT "$HESTIA/data/users/admin/user.conf" | cut -f 2 -d \')
177+
email=$(grep CONTACT "$HESTIA/data/users/$ROOT_USER/user.conf" | cut -f 2 -d \')
178178

179179
# Validate available disk space (take usage * 2, due to the backup handling)
180180
let u_disk=$(($(get_user_disk_usage) * 2))

0 commit comments

Comments
 (0)