]> 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, 24 Mar 2022 08:03:28 +0000 (09:03 +0100)
bacula/src/win32/win32_installer/winbacula.nsi
bacula/src/win32/win64_installer/winbacula.nsi

index 32cb41d524c9145f268aa59623b62c6ea4e1d2ce..4750ed4c71a2657b08916de2c4e76c6bedff013b 100644 (file)
@@ -462,38 +462,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 d5e2d120c3e90bde1e6b05f39e7ebbe41bc120e3..6d2abdf93d4f1dd8f99d48984d3d326d04945f18 100644 (file)
@@ -401,38 +401,43 @@ Function .onInit
   SetPluginUnload alwaysoff
 
 ; Generate random File daemon password
-  nsExec::Exec '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$INSTDIR\working\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 '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$INSTDIR\working\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 '"$INSTDIR\working\openssl.exe" rand -base64 -out $INSTDIR\working\pw.txt 33'
-  pop $R0
-  ${If} $R0 = 0
-   FileOpen $R1 "$INSTDIR\working\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