From 2071c5945c4ceed11bb5c2fe7a1c0fe0ade457b2 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 20 May 2013 21:21:43 +0000 Subject: [PATCH] Try to make powershell module more tolerant of pathing situations git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@16369 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../share/xcat/netboot/windows/xCAT.psm1 | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 index 55e532beb..288bb706a 100644 --- a/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 +++ b/xCAT-server/share/xcat/netboot/windows/xCAT.psm1 @@ -2,9 +2,12 @@ # This function specifically validates that the peer we are talking to is signed by the xCAT blessed CA and no other CA Function Import-xCATConfig ($credentialPackage) { $shell = New-Object -com shell.application - (Get-Location).Path+"\$credentialPackage" - $credpkg = $shell.namespace((Get-Location).Path+"\$credentialPackage") - $credpkg + $credentialPackage = $credentialPackage -replace '^\.\\','' + if (-not $credentialPackage -match '\\') { + $mypath = Get-Location + $credentialPackage = $mypath.Path + $credentialPackage + } + $credpkg = $shell.namespace($credentialPackage) $randname = [System.IO.Path]::GetRandomFileName() Push-Location mkdir $env:temp+"\"+$randname @@ -54,6 +57,11 @@ Function VerifyxCATCert ($sender, $cert, $chain, $polerrs) { #this isn't quite as innocuous as the openssl mechanisms to do this sort of thing, but it's as close as I could figure to get Function ImportxCATCA ( $certpath ) { $xcatstore = New-Object System.Security.Cryptography.X509Certificates.X509Store("xCAT","CurrentUser") + $certpath -replace '^\.\\','' + if (-not $certpath -match '\\') { + $mypath=Get-Location + $certpath = $mypath.Path + $certpath + } $cacert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certpath) $xcatstore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]'Readwrite') $xcatstore.Add($xcatcacert) @@ -70,6 +78,12 @@ Function RemovexCATCA { #specify a client certificate to use in pfx format Function SetxCATClientCertificate ( $pfxPath ) { + $pfxPath = $pfxPath -replace '^\.\\','' + if (-not $pxfPath -match '\\') { + $mypath=Get-Location + $pfxPath = $mypath.Path + $pfxPath + } + $xcatstore = New-Object System.Security.Cryptography.X509Certificates.X509Store("xCAT","CurrentUser") $xcatclientcert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($pfxpath) $xcatstore.Add($xcatclientcert)