From 39f0f4464d8962fba564282f89d9f412a7a18ed0 Mon Sep 17 00:00:00 2001 From: vados-dev <192440777+vados-dev@users.noreply.github.com> Date: Fri, 1 May 2026 09:35:03 +0300 Subject: [PATCH] Autocommit in repo: ros.vados.ru, generated by owner: root, in 09:35:02 01.05.2026. --- html/AM-GlobalFunc.rsc | 47 +++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/html/AM-GlobalFunc.rsc b/html/AM-GlobalFunc.rsc index f6a515828..c3e96225b 100644 --- a/html/AM-GlobalFunc.rsc +++ b/html/AM-GlobalFunc.rsc @@ -17,9 +17,9 @@ :global GlobalFuncReady false; # Git commit id & info, expected configuration version -:global CommitId "main/367/2a8f526e"; +:global CommitId "main/368/b69ddb1c"; :global CommitTAG "unknown"; -:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 09:10:02 01.05.2026."; +:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 09:35:02 01.05.2026."; # The variables are received right here. :global GlobalConfVersion 138; @@ -555,31 +555,28 @@ } # check and download required certificate +# Usage: $CertificateAvailable "Common Name" "intended use for certificate (e.g. "fetch", "tls", "all", "undefined")" :set CertificateAvailable do={ :local CommonName [ :tostr $1 ]; :local UseFor [ :tostr $2 ]; :global CertificateDownload; - :global LogPrint; :global ParseKeyValueStore; :if ([ :len $UseFor ] = 0) do={ - $LogPrint warning $0 ("The intended use is undefined!"); + :log warning ($0 . "The intended use is undefined!"); :set UseFor "undefined"; } - :if ([ /system/resource/get free-hdd-space ] < 8388608 && \ [ /certificate/settings/get crl-download ] = true && \ [ /certificate/settings/get crl-store ] = "system") do={ - $LogPrint warning $0 ("This system has low free flash space but " . \ + :log warning ($0 . "This system has low free flash space but " . \ "is configured to download certificate CRLs to system!"); } - :if ([ :len $CommonName ] = 0) do={ - $LogPrint warning $0 ("No CommonName given!"); + :log warning ($0 . "No CommonName given!"); :return false; } - :local CertSettings [ /certificate/settings/get ]; :if ((($CertSettings->"builtin-trust-anchors") = "trusted" || \ ($CertSettings->"builtin-trust-store") ~ $UseFor || \ @@ -587,24 +584,21 @@ [ :len [ /certificate/builtin/find where common-name=$CommonName ] ] > 0) do={ :return true; } - :if ([ :len [ /certificate/find where common-name=$CommonName ] ] = 0) do={ - $LogPrint info $0 ("Certificate with CommonName '" . $CommonName . "' not available."); + :log info ($0 . "Certificate with CommonName '" . $CommonName . "' not available."); :if ([ $CertificateDownload $CommonName ] = false) do={ :return false; } } - :if ([ :len [ /certificate/find where common-name=$CommonName ] ] > 1) do={ - $LogPrint info $0 ("There are " . $CertCount . " Certificates with CommonName '" . $CommonName . "'. Should be ok."); + :log info ($0 . "There are " . $CertCount . " Certificates with CommonName '" . $CommonName . "'. Should be ok."); :return true; } - :local CertVal [ /certificate/get [ find where common-name=$CommonName ] ]; :while (($CertVal->"akid") != "" && ($CertVal->"akid") != ($CertVal->"skid")) do={ :if ([ :len [ /certificate/find where skid=($CertVal->"akid") ] ] = 0) do={ :local IssuerCN ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN"); - $LogPrint info $0 ("Certificate chain for '" . $CommonName . "' is incomplete, missing '" . $IssuerCN . "'."); + :log info ($0 . "Certificate chain for '" . $CommonName . "' is incomplete, missing '" . $IssuerCN . "'."); :if ([ $CertificateDownload $IssuerCN ] = false) do={ :return false; } @@ -615,20 +609,18 @@ } # download and import certificate +# Usage: $CertificateDownload "Common Name" :set CertificateDownload do={ :local CommonName [ :tostr $1 ]; - :global ScriptUpdatesBaseUrl; :global ScriptUpdatesUrlSuffix; - :global CertificateNameByCN; :global CleanName; :global FetchUserAgentStr; - :global LogPrint; :global RmFile; :global WaitForFile; - $LogPrint info $0 ("Downloading and importing certificate with " . \ + :log info ($0 . "Downloading and importing certificate with " . \ "CommonName '" . $CommonName . "'."); :local FileName ([ $CleanName $CommonName ] . ".pem"); :do { @@ -637,7 +629,7 @@ dst-path=$FileName as-value; $WaitForFile $FileName; } on-error={ - $LogPrint warning $0 ("Failed downloading certificate with CommonName '" . $CommonName . \ + :log warning ($0 . " Failed downloading certificate with CommonName '" . $CommonName . \ "' from repository! Trying fallback to mkcert.org..."); :do { :local CertSettings [ /certificate/settings/get ]; @@ -646,7 +638,7 @@ ($CertSettings->"builtin-trust-store") ~ "fetch" || \ ($CertSettings->"builtin-trust-store") = "all") && \ [ :len [ /certificate/builtin/find where common-name="ISRG Root X1" ] ] > 0)) do={ - $LogPrint error $0 ("Required certificate is not available."); + :log error ($0 . " Required certificate is not available."); :return false; } /tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgentStr $0 ] }) \ @@ -658,21 +650,18 @@ :error false; } } on-error={ - $LogPrint warning $0 ("Failed downloading certificate with CommonName '" . $CommonName . "'!"); + :log warning ($0 . " Failed downloading certificate with CommonName '" . $CommonName . "'!"); :return false; } } - /certificate/import file-name=$FileName passphrase="" as-value; :delay 1s; $RmFile $FileName; - :if ([ :len [ /certificate/find where common-name=$CommonName ] ] = 0) do={ /certificate/remove [ find where name~("^" . $FileName . "_[0-9]+\$") ]; - $LogPrint warning $0 ("Certificate with CommonName '" . $CommonName . "' still unavailable!"); + :log warning ($0 . " Certificate with CommonName '" . $CommonName . "' still unavailable!"); :return false; } - :foreach Cert in=[ /certificate/find where name~("^" . $FileName . "_[0-9]+\$") ] do={ $CertificateNameByCN [ /certificate/get $Cert common-name ]; } @@ -680,15 +669,13 @@ } # name a certificate by its common-name +# Usage: $CertificateNameByCN "Common Name" :set CertificateNameByCN do={ :local Match [ :tostr $1 ]; - :global CleanName; - :global LogPrint; - :local Cert ([ /certificate/find where (common-name=$Match or fingerprint=$Match or name=$Match) ]->0); :if ([ :len $Cert ] = 0) do={ - $LogPrint warning $0 ("No matching certificate found."); + :log warning ($0 ." No matching certificate found."); :return false; } :local CommonName [ /certificate/get $Cert common-name ]; -- 2.52.0