Procházet zdrojové kódy

Improve port detection filemanager (#2245)

* Improve port detection filemanager

* Adjust spaces

Co-authored-by: Raphael Schneeberger <rs@scit.ch>
Jaap Marcus před 4 roky
rodič
revize
be3a7bd471

+ 4 - 2
install/deb/filemanager/filegator/configuration.php

@@ -27,9 +27,11 @@ $dist_config['services']['Filegator\Services\Storage\Filesystem']['config']['ada
 
     if (!isset($_SESSION['SFTP_PORT'])) {
         exec("sudo /usr/local/hestia/bin/v-list-sys-sshd-port json", $output, $result);
-        if ($output) {
-            $port=json_decode(implode('', $output));
+        $port=json_decode(implode('', $output));
+        if ( is_numeric($port[0]) && $port[0] > 0 ){
             $_SESSION['SFTP_PORT'] = $port[0];
+        } else if ( preg_match('/^\s*Port\s+(\d+)$/im', file_get_contents('/etc/ssh/sshd_config'), $matches) ) {
+            $_SESSION['SFTP_PORT'] = $matches[1] ?? 22;
         } else {
             $_SESSION['SFTP_PORT'] = 22;
         }