فهرست منبع

Merge pull request #2257 from jaapmarcus/fix/sftp-jail-non-hestia-user

[SFTP] Prevent non hestia-user to be added to sftp jail
Raphael Schneeberger 4 سال پیش
والد
کامیت
cef84ee403
1فایلهای تغییر یافته به همراه11 افزوده شده و 1 حذف شده
  1. 11 1
      bin/v-add-sys-sftp-jail

+ 11 - 1
bin/v-add-sys-sftp-jail

@@ -75,9 +75,19 @@ fi
 # Checking users
 # Checking users
 shells="rssh|nologin"
 shells="rssh|nologin"
 for user in $(grep "$HOMEDIR" /etc/passwd |egrep "$shells" |cut -f 1 -d:); do
 for user in $(grep "$HOMEDIR" /etc/passwd |egrep "$shells" |cut -f 1 -d:); do
-    $BIN/v-add-user-sftp-jail "$user" "$restart"
+    if [ -d "$HESTIA/data/users/$user" ]; then
+    $BIN/v-add-user-sftp-jail "$user" "no"
+    fi
 done
 done
 
 
+# Restart ssh service
+if [ "$restart" = 'no' ]; then
+    # Skip restart of SSH daemon
+    echo "" > /dev/null 2>&1
+else
+    service ssh restart > /dev/null 2>&1
+fi
+
 # Add v-add-sys-sftp-jail to startup
 # Add v-add-sys-sftp-jail to startup
 if [ ! -e "/etc/cron.d/hestia-sftp" ]; then
 if [ ! -e "/etc/cron.d/hestia-sftp" ]; then
     echo "@reboot root sleep 60 && /usr/local/hestia/bin/v-add-sys-sftp-jail" > /etc/cron.d/hestia-sftp
     echo "@reboot root sleep 60 && /usr/local/hestia/bin/v-add-sys-sftp-jail" > /etc/cron.d/hestia-sftp