Skip to content

Commit 04df2f5

Browse files
author
Kristan Kenney
authored
Merge pull request hestiacp#373 from hestiacp/bugfix-sftp
Add restart flag to v-add-*-sftp-jail scripts and modify upgrade routine
2 parents ef36c8c + 09975da commit 04df2f5

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

bin/v-add-sys-sftp-jail

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add system sftp jail
3-
# options: NONE
3+
# options: [RESTART]
44
#
55
# The script enables sftp jailed environment
66

@@ -14,6 +14,7 @@ source /etc/profile
1414
source $HESTIA/func/main.sh
1515
source $HESTIA/conf/hestia.conf
1616

17+
restart=$1
1718

1819
#----------------------------------------------------------#
1920
# Verifications #
@@ -45,11 +46,12 @@ if [ -z "$sftp_i" ]; then
4546
echo " X11Forwarding no" >> $config
4647
echo " AllowTCPForwarding no" >> $config
4748
echo " ForceCommand internal-sftp" >> $config
48-
restart='yes'
4949
fi
5050

5151
# Validating opensshd config
52-
if [ "$restart" = 'yes' ]; then
52+
if [ "$restart" = 'no' ]; then
53+
# Skip restarting SSH daemon
54+
else
5355
subj="OpenSSH restart failed"
5456
email=$(grep CONTACT $HESTIA/data/users/admin/user.conf |cut -f 2 -d \')
5557
/usr/sbin/sshd -t >/dev/null 2>&1
@@ -59,7 +61,6 @@ if [ "$restart" = 'yes' ]; then
5961
echo -e "$mail_text" |$SENDMAIL -s "$subj" $email
6062
else
6163
service ssh restart >/dev/null 2>&1
62-
service sshd restart >/dev/null 2>&1
6364
fi
6465
fi
6566

bin/v-add-user-sftp-jail

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add user sftp jail
3-
# options: USER
3+
# options: USER [RESTART]
44
#
55
# The script enables sftp jailed environment
66

@@ -11,6 +11,7 @@
1111

1212
# Argument definition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $HESTIA/func/main.sh
@@ -62,8 +63,11 @@ chown root:root /home/$user
6263
#----------------------------------------------------------#
6364

6465
# Restart ssh service
65-
service ssh restart > /dev/null 2>&1
66-
service sshd restart > /dev/null 2>&1
66+
if [ "$restart" = 'no' ]; then
67+
# Skip restart of SSH daemon
68+
else
69+
service ssh restart > /dev/null 2>&1
70+
fi
6771

6872
# Logging
6973
log_event "$OK" "$ARGUMENTS"

install/upgrade/1.00.0-190618.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,13 @@ if [ ! -z "$WEBALIZER_CHECK" ]; then
322322
fi
323323

324324
# Run sftp jail once
325-
$HESTIA/bin/v-add-sys-sftp-jail
325+
$HESTIA/bin/v-add-sys-sftp-jail no
326326

327327
# Enable SFTP subsystem for SSH
328328
sftp_subsys_enabled=$(grep -iE "^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
329329
if [ ! -z "$sftp_subsys_enabled" ]; then
330330
echo "(*) Updating SFTP subsystem configuration..."
331331
sed -i -E "s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
332-
systemctl restart ssh
333332
fi
334333

335334
# Remove and migrate obsolete object keys
@@ -422,8 +421,9 @@ if [ ! -z $DNS_SYSTEM ]; then
422421
$BIN/v-restart-dns $restart
423422
fi
424423

425-
# restart Hestia services (nginx,php-fpm)
426-
systemctl restart hestia
424+
$BIN/v-restart-service ssh $restart
425+
$BIN/v-restart-service hestia $restart
426+
427427

428428
echo ""
429429
echo " Upgrade complete! Please report any bugs or issues to"

0 commit comments

Comments
 (0)