Skip to content

Commit

Permalink
refactor(WithRunable): Simplify sudo password handling
Browse files Browse the repository at this point in the history
- Remove unnecessary echo command from sudo password handling
- Update Process instantiation to streamline the command line
- Maintain sudo password input functionality for better clarity
  • Loading branch information
guanguans committed Jan 16, 2025
1 parent 4af0217 commit 402a63d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Concerns/WithRunable.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ protected function createProcess($withOptions = []): Process
: new Process(array_merge([$this->soarBinary], $this->clone()->mergeOptions($withOptions)->getNormalizedOptions()));

if ($this->shouldApplySudoPassword()) {
// $process = Process::fromShellCommandline(\sprintf(
// 'echo %s | sudo -S %s',
// $this->getEscapedSudoPassword(),
// $process->getCommandLine()
// ));

$process = Process::fromShellCommandline(\sprintf(
'echo %s | sudo -S %s',
$this->getEscapedSudoPassword(),
'sudo -S %s',
$process->getCommandLine()
));

// $process->setInput($this->getSudoPassword());
))->setInput($this->getSudoPassword());
}

if (\is_callable($this->processTapper)) {
Expand Down

0 comments on commit 402a63d

Please sign in to comment.