-
-
Notifications
You must be signed in to change notification settings - Fork 393
Adjust SSH heredoc wrapper #998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,8 +170,11 @@ public function exec(string|View $command, string $log = '', ?int $siteId = null | |
|
|
||
| try { | ||
| if ($this->asUser !== null && $this->asUser !== '' && $this->asUser !== '0') { | ||
| $command = base64_encode((string) $command); | ||
| $command = "sudo su - {$this->asUser} -c 'bash -c \"echo {$command} | base64 -d | bash\"'"; | ||
| $command = <<<BASH | ||
| sudo -u {$this->asUser} bash <<'EOF' | ||
| {$command} | ||
| EOF | ||
| BASH; | ||
|
Comment on lines
+173
to
+177
|
||
| } | ||
|
|
||
| $this->connection->setTimeout(0); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heredoc assigned to
$commandis indented inside the method, so the generated string will contain leading spaces beforesudo -u ..., the embedded command, andEOF. In contrast, the new unit test inServerModelTestexpects those lines to start at column 1 with no leading spaces, so this mismatch will cause the assertion to fail and also changes the exact command sent over SSH. Consider left-aligning the heredoc contents (or otherwise normalizing whitespace) so that the produced command matches the expected format.