Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14362687
D10378.id24977.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D10378.id24977.diff
View Options
diff --git a/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockPreallocatedHostBlueprintImplementation.php
@@ -76,18 +76,7 @@
$cmd = $lease->getInterface('command');
- if ($v_platform !== 'windows') {
- $cmd->execx('mkdir %s', $full_path);
- } else {
- // Windows is terrible. The mkdir command doesn't even support putting
- // the path in quotes. IN QUOTES. ARGUHRGHUGHHGG!! Do some terribly
- // inaccurate sanity checking since we can't safely escape the path.
- if (preg_match('/^[A-Z]\\:\\\\[a-zA-Z0-9\\\\\\ ]/', $full_path) === 0) {
- throw new Exception(
- 'Unsafe path detected for Windows platform: "'.$full_path.'".');
- }
- $cmd->execx('mkdir %C', $full_path);
- }
+ list($stdout, $stderr) = $cmd->execx('mkdir %s', $full_path);
$lease->setAttribute('path', $full_path);
}
diff --git a/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php b/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php
--- a/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php
+++ b/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php
@@ -47,10 +47,24 @@
}
$script = <<<EOF
-$change_directory
-$command
-if (\$LastExitCode -ne 0) {
- exit \$LastExitCode
+\$ErrorActionPreference = 'Continue'
+
+\$s = New-PSSession localhost
+Invoke-Command -Session \$s -ErrorAction Continue -ScriptBlock {
+ $change_directory
+}
+Invoke-Command -Session \$s -ErrorAction Continue -ScriptBlock {
+ $command
+}
+\$exit = Invoke-Command -Session \$s -ErrorAction Continue -ScriptBlock {
+ return \$LastExitCode
+}
+
+Remove-PSSession \$s
+
+if (\$exit -ne 0 -and \$exit -ne \$null) {
+ throw "Command exited with a non-zero exit code; refer to the " + `
+ "above output and the 'remote - stdout' log for more information."
}
EOF;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 1:16 PM (6 h, 1 s)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6914101
Default Alt Text
D10378.id24977.diff (2 KB)
Attached To
Mode
D10378: Spawn a new Powershell session when running commands on Windows
Attached
Detach File
Event Timeline
Log In to Comment