Jaap Marcus 3 лет назад
Родитель
Сommit
1bebba66d0
2 измененных файлов с 22 добавлено и 1 удалено
  1. 1 0
      CHANGELOG.md
  2. 21 1
      web/api/index.php

+ 1 - 0
CHANGELOG.md

@@ -35,6 +35,7 @@ All notable changes to this project will be documented in this file.
 - Fixed an issue API and DNS cluster over multiple servers where username/password and hash where mixed (#2888)
 - Add option to use custom javascript code (#2747)
 - Add "v-rebuild-dns-domains" to sync-dns-cluster options
+- Fixed an issue with Yescript and api (#2899)
 
 ### Enhancements
 

+ 21 - 1
web/api/index.php

@@ -1,4 +1,14 @@
 <?php
+
+try {
+    require_once '../inc/vendor/autoload.php';
+} catch (Throwable $ex) {
+    $errstr = 'Unable able to load required libraries. Please run v-add-sys-phpmailer in command line. Error: ' . $ex->getMessage();
+    trigger_error($errstr);
+    echo $errstr;
+    exit(1);
+}
+
 //die("Error: Disabled");
 define('HESTIA_DIR_BIN', '/usr/local/hestia/bin/');
 define('HESTIA_CMD', '/usr/bin/sudo /usr/local/hestia/bin/');
@@ -70,7 +80,7 @@ function api_legacy(array $request_data) {
             exit;
         }
         $v_ip = escapeshellarg(get_real_user_ip());
-        $output = '';
+        unset($output);
         exec(HESTIA_CMD."v-get-user-salt admin ".$v_ip." json", $output, $return_var);
         $pam = json_decode(implode('', $output), true);
         $salt = $pam['admin']['SALT'];
@@ -83,6 +93,16 @@ function api_legacy(array $request_data) {
             $hash = crypt($password, '$6$rounds=5000$'.$salt.'$');
             $hash = str_replace('$rounds=5000', '', $hash);
         }
+        if ($method == 'yescrypt') {
+            $v_password = tempnam("/tmp", "vst");
+            $fp = fopen($v_password, "w");
+            fwrite($fp, $password."\n");
+            fclose($fp);
+            unset($output);
+            exec(HESTIA_CMD . 'v-check-user-password "admin" '. $password. ' '.$v_ip.' yes', $output, $return_var);
+            $hash = $output[0];
+            unset($output);
+        }
         if ($method == 'des') {
             $hash = crypt($password, $salt);
         }