From: Norbert Bizet Date: Tue, 1 Dec 2020 13:50:22 +0000 (-0500) Subject: win32: Fix #7094 bypass random pwd generation when pwd is provided X-Git-Tag: Release-11.3.2~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=785ce12c51263eacf2f7c327e1ed2cce0167f5ed;p=thirdparty%2Fbacula.git win32: Fix #7094 bypass random pwd generation when pwd is provided --- diff --git a/bacula/src/win32/win32_installer/winbacula.nsi b/bacula/src/win32/win32_installer/winbacula.nsi index 32cb41d52..4750ed4c7 100644 --- a/bacula/src/win32/win32_installer/winbacula.nsi +++ b/bacula/src/win32/win32_installer/winbacula.nsi @@ -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 diff --git a/bacula/src/win32/win64_installer/winbacula.nsi b/bacula/src/win32/win64_installer/winbacula.nsi index d5e2d120c..6d2abdf93 100644 --- a/bacula/src/win32/win64_installer/winbacula.nsi +++ b/bacula/src/win32/win64_installer/winbacula.nsi @@ -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