Skip to content
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

added becomeSetHome method to add -H flag when using sudo #1556

Merged
merged 8 commits into from
Apr 18, 2018
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Added debug:task command to display the order of task execution [#1488]
- Added a description to the autocomplete command [#1472]
- Added logging of unhandled exceptions into logfile [#1481]
- Added default -H flag when using become [#1556]
- Added Symfony 4 recipe [#1437]

### Fixed
Expand Down Expand Up @@ -360,6 +361,7 @@

[#1559]: https://github.com/deployphp/deployer/pull/1559
[#1557]: https://github.com/deployphp/deployer/pull/1557
[#1556]: https://github.com/deployphp/deployer/pull/1556
[#1554]: https://github.com/deployphp/deployer/pull/1554
[#1521]: https://github.com/deployphp/deployer/pull/1521
[#1513]: https://github.com/deployphp/deployer/pull/1513
Expand Down
8 changes: 4 additions & 4 deletions src/Host/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,25 @@ public function getSshArguments()
return $this->sshArguments;
}

public function sshOptions(array $options) : Host
public function sshOptions(array $options): Host
{
$this->sshArguments = $this->sshArguments->withOptions($options);
return $this;
}

public function sshFlags(array $flags) : Host
public function sshFlags(array $flags): Host
{
$this->sshArguments = $this->sshArguments->withFlags($flags);
return $this;
}

public function addSshOption(string $option, $value) : Host
public function addSshOption(string $option, $value): Host
{
$this->sshArguments = $this->sshArguments->withOption($option, $value);
return $this;
}

public function addSshFlag(string $flag, string $value = null) : Host
public function addSshFlag(string $flag, string $value = null): Host
{
$this->sshArguments = $this->sshArguments->withFlag($flag, $value);
return $this;
Expand Down
3 changes: 2 additions & 1 deletion src/Ssh/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function run(Host $host, string $command, array $config = [])
$this->pop->command($hostname, $command);

$sshArguments = $host->getSshArguments();
$become = $host->has('become') ? 'sudo -u ' . $host->get('become') : '';

$become = $host->has('become') ? 'sudo -H -u ' . $host->get('become') : '';

// When tty need to be allocated, don't use multiplexing,
// and pass command without bash allocation on remote host.
Expand Down