From: Rod Widdowson Date: Fri, 13 Apr 2012 12:55:01 +0000 (+0000) Subject: Handle the move of openSSL from \opt. Call keygen.bat during install X-Git-Tag: 2.5.0~136 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=101f0caaacf1e3df4e3c98732421e063d53a0583;p=shibboleth%2Fcpp-sp.git Handle the move of openSSL from \opt. Call keygen.bat during install --- diff --git a/configs/keygen.bat-wix b/configs/keygen.bat-wix new file mode 100644 index 0000000..ca8002c --- /dev/null +++ b/configs/keygen.bat-wix @@ -0,0 +1,98 @@ +@echo off +setlocal + +set DAYS= +set YEARS= +set FQDN= +set ENTITYID= +set TEMP_DOMAIN_NAME= +set PARAM= + +set PREFIX=%~dp0 + +:opt_start +set PARAM=%1 +if not defined PARAM goto opt_end +if %1==-h goto opt_fqdn +if %1==-e goto opt_entityid +if %1==-y goto opt_years +if %1==-f goto opt_force +goto usage +:opt_end + +if exist "%PREFIX%sp-key.pem" goto protect +if exist "%PREFIX%sp-cert.pem" goto protect + +if not defined YEARS set YEARS=10 +set /a DAYS=%YEARS%*365 + +if not defined FQDN goto guess_fqdn + +:generate +set PATH=%PREFIX%..\..\lib;%PREFIX%..\..\bin +set CNF="%PREFIX%sp-cert.cnf" +echo # OpenSSL configuration file for creating sp-cert.pem >%CNF% +echo [req] >>%CNF% +echo prompt=no >>%CNF% +echo default_bits=2048 >>%CNF% +echo encrypt_key=no >>%CNF% +echo default_md=sha1 >>%CNF% +echo distinguished_name=dn >>%CNF% +echo # PrintableStrings only >>%CNF% +echo string_mask=MASK:0002 >>%CNF% +echo x509_extensions=ext >>%CNF% +echo [dn] >>%CNF% +echo CN=%FQDN% >>%CNF% +echo [ext] >>%CNF% +if defined ENTITYID (echo subjectAltName=DNS:%FQDN%,URI:%ENTITYID% >>%CNF%) else (echo subjectAltName=DNS:%FQDN% >>%CNF%) +echo subjectKeyIdentifier=hash >>%CNF% +"@-PROGRAMFILES-@Shibboleth\SP\lib\openssl.exe" req -config %PREFIX%sp-cert.cnf -new -x509 -days %DAYS% -keyout %PREFIX%sp-key.pem -out %PREFIX%sp-cert.pem +del %CNF% +exit /b + +:protect +echo The files sp-key.pem and/or sp-cert.pem already exist! +echo Use -f option to force recreation of keypair. +exit /b + +:opt_force +if exist "%PREFIX%sp-key.pem" del "%PREFIX%sp-key.pem" +if exist "%PREFIX%sp-cert.pem" del "%PREFIX%sp-cert.pem" +shift +goto opt_start + +:opt_fqdn +set FQDN=%2 +shift +shift +goto opt_start + +:opt_entityid +set ENTITYID=%2 +shift +shift +goto opt_start + +:opt_years +set YEARS=%2 +shift +shift +goto opt_start + +:usage +echo usage: keygen [-h hostname for cert] [-y years to issue cert] [-e entityID to embed in cert] +exit /b + +:guess_fqdn +for /F "tokens=2 delims=:" %%i in ('"ipconfig /all | findstr /c:"Primary DNS Suffix" /c:"Primary Dns Suffix""') do set TEMP_DOMAIN_NAME=%%i +if defined TEMP_DOMAIN_NAME set FQDN=%TEMP_DOMAIN_NAME: =% +set TEMP_DOMAIN_NAME= +if defined USERDNSDOMAIN set FQDN=%USERDNSDOMAIN% + +for /F %%i in ('hostname') do set HOST=%%i +if defined FQDN (set FQDN=%HOST%.%FQDN%) else (set FQDN=%HOST%) + +echo >%FQDN% +for /F %%i in ('dir /b/l %FQDN%') do set FQDN=%%i +del %FQDN% +goto generate diff --git a/msi/WiX/ShibbolethSP-noarch.wxs b/msi/WiX/ShibbolethSP-noarch.wxs index 33a23c8..edc0df1 100644 --- a/msi/WiX/ShibbolethSP-noarch.wxs +++ b/msi/WiX/ShibbolethSP-noarch.wxs @@ -54,7 +54,7 @@ - + SHIB_OLDVERSION = "none" - + + - + + + NOT Installed NOT Installed + NOT Installed + NOT Installed @@ -53,7 +53,15 @@ + + + + + + @@ -112,6 +120,8 @@ + + diff --git a/msi/scripts/shib_edit_config_files.vbs-wix b/msi/scripts/shib_edit_config_files.vbs-wix new file mode 100644 index 0000000..cbc6bd6 --- /dev/null +++ b/msi/scripts/shib_edit_config_files.vbs-wix @@ -0,0 +1,215 @@ +Function ReadFile( filePath ) + Dim theFile + + 'OpenTextFile args: , 1 = ForReading + 'If you read an empty file, VBScript throws an error for some reason + if (FileSystemObj.FileExists(filePath)) then + Set theFile = FileSystemObj.GetFile(filePath) + if (theFile.size > 0) then + Set theFile = FileSystemObj.OpenTextFile(filePath, 1) + ReadFile = theFile.ReadAll + else + ReadFile = "" + end if + else + ReadFile = "" + end if +End Function + +Sub WriteFile( filePath, contents ) + Dim theFile + + 'OpenTextFile args: , 2 = ForWriting, True = create if not exist + Set theFile = FileSystemObj.OpenTextFile(filePath, 2, True) + theFile.Write contents +End Sub + +Sub ReplaceInFile( filePath, lookForStr, replaceWithStr ) + Dim buffer + + buffer = ReadFile(filePath) + if (buffer <> "") then + buffer = Replace(buffer, lookForStr, replaceWithStr) + WriteFile filePath, buffer + end if +End Sub + + +Dim FileSystemObj, ConvertedDir, ConfigFile, XMLDir, WshShell +Dim customData, msiProperties, InstallDir, ShibdPort + +on error resume next +Set FileSystemObj = CreateObject("Scripting.FileSystemObject") +if (Err = 0) then + + 'Get the INSTALLDIR and SHIBD_PORT values via CustomActionData + customData = Session.Property("CustomActionData") + msiProperties = split(customData,";@;") + InstallDir = msiProperties(0) + ShibdPort = msiProperties(1) + ProgramFiles = msiProperties(2) + + 'Remove all trailing backslashes to normalize + do while (mid(InstallDir,Len(InstallDir),1) = "\") + InstallDir = mid(InstallDir,1,Len(InstallDir)-1) + loop + ConvertedDir = Replace(InstallDir, "\", "/") + ConfigDir = InstallDir & "\etc\shibboleth\" + DistDir = ConfigDir & "dist\" + + 'Set ConvertedDir as the SHIBSP_PREFIX system variable. + Set WshShell = CreateObject("WScript.Shell") + WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\SHIBSP_PREFIX", ConvertedDir, "REG_SZ" + + 'Perform actual Substitutions + 'Afterwards, if the config file doesn't already exist, copy up to etc/shibboleth + 'Also strip *.in for files in dist + + 'Keygen.bat is updated in placehowever + Keygen = ConfigDir & "keygen.bat" + ReplaceInFile Keygen, "@-PROGRAMFILES-@", ProgramFiles + + + ConfigFile = DistDir & "shibd.logger.in" + ReplaceInFile ConfigFile, "@-PKGLOGDIR-@", ConvertedDir & "/var/log/shibboleth" + If (NOT FileSystemObj.FileExists(ConfigDir & "shibd.logger")) then + FileSystemObj.CopyFile ConfigFile, ConfigDir & "shibd.logger", false + End If + If (FileSystemObj.FileExists(DistDir & "shibd.logger")) then + FileSystemObj.DeleteFile DistDir & "shibd.logger", true + End If + FileSystemObj.MoveFile ConfigFile, DistDir & "shibd.logger" + + ConfigFile = DistDir & "native.logger.in" + ReplaceInFile ConfigFile, "@-SHIRELOGDIR-@", ConvertedDir & "/var/log/shibboleth" + If (NOT FileSystemObj.FileExists(ConfigDir & "native.logger")) then + FileSystemObj.CopyFile ConfigFile, ConfigDir & "native.logger", false + End If + If (FileSystemObj.FileExists(DistDir & "native.logger")) then + FileSystemObj.DeleteFile DistDir & "native.logger", true + End If + FileSystemObj.MoveFile ConfigFile, DistDir & "native.logger" + + ConfigFile = DistDir & "apache.config.in" + ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth" + ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth" + If (NOT FileSystemObj.FileExists(ConfigDir & "apache.config")) then + FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache.config", false + End If + If (FileSystemObj.FileExists(DistDir & "apache.config")) then + FileSystemObj.DeleteFile DistDir & "apache.config", true + End If + FileSystemObj.MoveFile ConfigFile, DistDir & "apache.config" + + ConfigFile = DistDir & "apache2.config.in" + ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth" + ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth" + If (NOT FileSystemObj.FileExists(ConfigDir & "apache2.config")) then + FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache2.config", false + End If + If (FileSystemObj.FileExists(DistDir & "apache2.config")) then + FileSystemObj.DeleteFile DistDir & "apache2.config", true + End If + FileSystemObj.MoveFile ConfigFile, DistDir & "apache2.config" + + ConfigFile = DistDir & "apache22.config.in" + ReplaceInFile ConfigFile, "@-PKGLIBDIR-@", ConvertedDir & "/lib/shibboleth" + ReplaceInFile ConfigFile, "@-PKGDOCDIR-@", ConvertedDir & "/share/doc/shibboleth" + If (NOT FileSystemObj.FileExists(ConfigDir & "apache22.config")) then + FileSystemObj.CopyFile ConfigFile, ConfigDir & "apache22.config", false + End If + If (FileSystemObj.FileExists(DistDir & "apache22.config")) then + FileSystemObj.DeleteFile DistDir & "apache22.config", true + End If + FileSystemObj.MoveFile ConfigFile, DistDir & "apache22.config" + + 'Now just copy the other non-edited files over as well (if possible) + + If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth2.xml")) then + FileSystemObj.CopyFile DistDir & "shibboleth2.xml", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "accessError.html")) then + FileSystemObj.CopyFile DistDir & "accessError.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "metadataError.html")) then + FileSystemObj.CopyFile DistDir & "metadataError.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "sessionError.html")) then + FileSystemObj.CopyFile DistDir & "sessionError.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "sslError.html")) then + FileSystemObj.CopyFile DistDir & "sslError.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "bindingTemplate.html")) then + FileSystemObj.CopyFile DistDir & "bindingTemplate.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "discoveryTemplate.html")) then + FileSystemObj.CopyFile DistDir & "discoveryTemplate.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "postTemplate.html")) then + FileSystemObj.CopyFile DistDir & "postTemplate.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "localLogout.html")) then + FileSystemObj.CopyFile DistDir & "localLogout.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "globalLogout.html")) then + FileSystemObj.CopyFile DistDir & "globalLogout.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "partialLogout.html")) then + FileSystemObj.CopyFile DistDir & "partialLogout.html", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "console.logger")) then + FileSystemObj.CopyFile DistDir & "console.logger", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "shibboleth.logger")) then + FileSystemObj.CopyFile DistDir & "shibboleth.logger", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-map.xml")) then + FileSystemObj.CopyFile DistDir & "attribute-map.xml", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "attribute-policy.xml")) then + FileSystemObj.CopyFile DistDir & "attribute-policy.xml", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "security-policy.xml")) then + FileSystemObj.CopyFile DistDir & "security-policy.xml", ConfigDir, false + End If + + If (NOT FileSystemObj.FileExists(ConfigDir & "protocols.xml")) then + FileSystemObj.CopyFile DistDir & "protocols.xml", ConfigDir, false + End If + + 'Finally, fix up schema catalogs. + + XMLDir = InstallDir & "\share\xml\xmltooling\" + ConfigFile = XMLDir & "catalog.xml" + ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir + + XMLDir = InstallDir & "\share\xml\opensaml\" + ConfigFile = XMLDir & "saml20-catalog.xml" + ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir + ConfigFile = XMLDir & "saml11-catalog.xml" + ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir + ConfigFile = XMLDir & "saml10-catalog.xml" + ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir + + XMLDir = InstallDir & "\share\xml\shibboleth\" + ConfigFile = XMLDir & "catalog.xml" + ReplaceInFile ConfigFile, "@-PKGXMLDIR-@/", XMLDir + +'Last End If +End If \ No newline at end of file