Kristan Kenney 6 лет назад
Родитель
Сommit
5e1064267a
3 измененных файлов с 67 добавлено и 1 удалено
  1. 8 0
      bin/v-list-sys-services
  2. 1 1
      bin/v-open-fs-config
  3. 58 0
      web/edit/server/ssh/index.php

+ 8 - 0
bin/v-list-sys-services

@@ -263,6 +263,13 @@ if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'remote' ]; then
     data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
 fi
 
+# Checking SSH daemon
+if [ -e "/etc/ssh/sshd_config" ]; then
+    get_srv_state ssh
+    data="$data\nNAME='ssh' SYSTEM='SSH Access' STATE='$state'"
+    data="$data CPU='$cpu' MEM='$mem' RTIME='$rtime'"
+fi
+
 # Checking FIREWALL system
 if [ ! -z "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != 'remote' ]; then
     state="stopped"
@@ -274,6 +281,7 @@ if [ ! -z "$FIREWALL_SYSTEM" ] && [ "$FIREWALL_SYSTEM" != 'remote' ]; then
     data="$data STATE='$state' CPU='0' MEM='0' RTIME='$rtime'"
 fi
 
+
 # Checking FIREWALL Fail2ban extention
 if [ ! -z "$FIREWALL_EXTENSION" ]; then
     get_srv_state $FIREWALL_EXTENSION fail2ban-server script

+ 1 - 1
bin/v-open-fs-config

@@ -28,7 +28,7 @@ fi
 if [ ! -z "$src_file" ]; then
     rpath=$(readlink -f "$src_file")
     services="nginx|apache|httpd|php|ftp|bind|named|exim|dovecot|spamassassin"
-    services="$services|clam|mysql|postgresql|pgsql|cron|fail2ban|iptables"
+    services="$services|clam|mysql|postgresql|pgsql|cron|ssh|fail2ban|iptables"
     services="$services|my.cnf"
     spath=$(echo "$rpath" |egrep "$services")
     if [ -z "$spath" ]; then

+ 58 - 0
web/edit/server/ssh/index.php

@@ -0,0 +1,58 @@
+<?php
+error_reporting(NULL);
+$TAB = 'SERVER';
+
+// Main include
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Check user
+if ($_SESSION['user'] != 'admin') {
+    header("Location: /list/user");
+    exit;
+}
+
+// Check POST request
+if (!empty($_POST['save'])) {
+
+    // Check token
+    if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
+        header('location: /login/');
+        exit();
+    }
+
+    // Set restart flag
+    $v_restart = 'yes';
+    if (empty($_POST['v_restart'])) $v_restart = 'no';
+
+    // Update config
+    if (!empty($_POST['v_config'])) {
+        exec ('mktemp', $mktemp_output, $return_var);
+        $new_conf = $mktemp_output[0];
+        $fp = fopen($new_conf, 'w');
+        fwrite($fp, str_replace("\r\n", "\n",  $_POST['v_config']));
+        fclose($fp);
+        exec (HESTIA_CMD."v-change-sys-service-config ".$new_conf." ssh ".$v_restart, $output, $return_var);
+        check_return_code($return_var,$output);
+        unset($output);
+        unlink($new_conf);
+    }
+
+    // Set success message
+    if (empty($_SESSION['error_msg'])) {
+        $_SESSION['ok_msg'] = __('Changes has been saved.');
+    }
+
+}
+
+$v_config_path = '/etc/ssh/sshd_config';
+$v_service_name = strtoupper('ssh');
+
+// Read config
+$v_config = shell_exec(HESTIA_CMD."v-open-fs-config ".$v_config_path);
+
+// Render page
+render_page($user, $TAB, 'edit_server_service');
+
+// Flush session messages
+unset($_SESSION['error_msg']);
+unset($_SESSION['ok_msg']);