]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
win32: Fix #7094 bypass random pwd generation when pwd is provided
authorNorbert Bizet <norbert.bizet@baculasystems.com>
Tue, 1 Dec 2020 13:50:22 +0000 (08:50 -0500)
committerEric Bollengier <eric@baculasystems.com>
Thu, 4 Feb 2021 14:51:58 +0000 (15:51 +0100)
bacula/src/win32/win32_installer/winbacula.nsi
bacula/src/win32/win64_installer/winbacula.nsi

index c30a6f68143197319f5ec98745bbeb7d61ed5436..69d6d536262a2ead97077a0194bf1e260758f5f4 100644 (file)
@@ -461,38 +461,43 @@ Function .onInit
   SetPluginUnload alwaysoff
 
 ; Generate random client password
-  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
-   IfErrors +4
-     FileRead $R1 $R0
-     ${StrTrimNewLines} $ConfigClientPassword $R0
-     FileClose $R1
+  ${If} $ConfigClientPassword == ""
+    nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
+    pop $R0
+    ${If} $R0 = 0
+    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
+    IfErrors +4
+      FileRead $R1 $R0
+      ${StrTrimNewLines} $ConfigClientPassword $R0
+      FileClose $R1
+    ${EndIf}
   ${EndIf}
-
   SetPluginUnload manual
 
 ; Generate random Storage daemon password
-  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
-   IfErrors +4
-     FileRead $R1 $R0
-     ${StrTrimNewLines} $ConfigStoragePassword $R0
-     FileClose $R1
+  ${If} $ConfigStoragePassword == ""
+    nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
+    pop $R0
+    ${If} $R0 = 0
+    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
+    IfErrors +4
+      FileRead $R1 $R0
+      ${StrTrimNewLines} $ConfigStoragePassword $R0
+      FileClose $R1
+    ${EndIf}
   ${EndIf}
 
 ; Generate random monitor password
-  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
-   IfErrors +4
-     FileRead $R1 $R0
-     ${StrTrimNewLines} $ConfigMonitorPassword $R0
-     FileClose $R1
+  ${If} $ConfigMonitorPassword == ""
+    nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
+    pop $R0
+    ${If} $R0 = 0
+    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
+    IfErrors +4
+      FileRead $R1 $R0
+      ${StrTrimNewLines} $ConfigMonitorPassword $R0
+      FileClose $R1
+    ${EndIf}
   ${EndIf}
 
   Pop $R1
index c2a781f39bd021623bdd8467553e38c499c7519c..57d501a6a03d93b2f4cfdef6631edadd6bc2b1a2 100644 (file)
@@ -395,38 +395,43 @@ Function .onInit
   SetPluginUnload alwaysoff
 
 ; Generate random File daemon password
-  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
-   IfErrors +4
-     FileRead $R1 $R0
-     ${StrTrimNewLines} $ConfigClientPassword $R0
-     FileClose $R1
+  ${If} $ConfigClientPassword == ""
+    nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
+    pop $R0
+    ${If} $R0 = 0
+    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
+    IfErrors +4
+      FileRead $R1 $R0
+      ${StrTrimNewLines} $ConfigClientPassword $R0
+      FileClose $R1
+    ${EndIf}
   ${EndIf}
 
 ; Generate random Storage daemon password
-  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
-   IfErrors +4
-     FileRead $R1 $R0
-     ${StrTrimNewLines} $ConfigStoragePassword $R0
-     FileClose $R1
+  ${If} $ConfigStoragePassword == ""
+    nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
+    pop $R0
+    ${If} $R0 = 0
+    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
+    IfErrors +4
+      FileRead $R1 $R0
+      ${StrTrimNewLines} $ConfigStoragePassword $R0
+      FileClose $R1
+    ${EndIf}
   ${EndIf}
-
   SetPluginUnload manual
 
 ; Generate random monitor password
-  nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$PLUGINSDIR\pw.txt" r
-   IfErrors +4
-     FileRead $R1 $R0
-     ${StrTrimNewLines} $ConfigMonitorPassword $R0
-     FileClose $R1
+  ${If} $ConfigMonitorPassword == ""
+    nsExec::Exec '"$PLUGINSDIR\openssl.exe" rand -base64 -out $PLUGINSDIR\pw.txt 33'
+    pop $R0
+    ${If} $R0 = 0
+    FileOpen $R1 "$PLUGINSDIR\pw.txt" r
+    IfErrors +4
+      FileRead $R1 $R0
+      ${StrTrimNewLines} $ConfigMonitorPassword $R0
+      FileClose $R1
+    ${EndIf}
   ${EndIf}
 
   Pop $R1