Skip to content

Commit

Permalink
Fix SHELL and EDITOR being hardcoded into the application during buil…
Browse files Browse the repository at this point in the history
…d phase, rather than read from environment at runtime.
  • Loading branch information
Jakub Gawron committed Mar 3, 2022
1 parent b299d85 commit 88d4234
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/Commands/AwsAssumeRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function handle()

$this->info("Now opening a session following you ({$sessionUser}) assuming the role {$role} on {$accountName} ({$accountId}) . Type `exit` to leave this shell.");

(new Process([config('app.shell')]))
(new Process([env('SHELL', 'bash')]))
->setEnv(array_merge($envVars, [
'AWS_S3_ENV' => $account['s3env'],
'BASH_SILENCE_DEPRECATION_WARNING' => '1',
Expand Down
2 changes: 1 addition & 1 deletion app/Commands/AwsMfaLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function handle()

$this->info("Now opening a session following your MFA authentication. Type `exit` to leave this shell.");

(new Process([config('app.shell')]))
(new Process([env('SHELL', 'bash')]))
->setEnv(array_merge($envVars, [
'BASH_SILENCE_DEPRECATION_WARNING' => '1',
'PS1' => "\e[32mnscli\e[34m(mfa-authd)$\e[39m ",
Expand Down
8 changes: 6 additions & 2 deletions app/Commands/EditEnvironmentVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class EditEnvironmentVariables extends BaseCommand

private string $fileContents;

private string $editor;

public function configure()
{
$this->setDefinition(array_merge([
Expand All @@ -50,7 +52,9 @@ public function configure()
*/
public function handle()
{
$requiredBinaries = ['aws', config('app.editor')];
$this->editor = env('EDITOR', '/usr/bin/vi');

$requiredBinaries = ['aws', $this->editor];

if ($this->helpers->checks()->checkAndReportMissingBinaries($requiredBinaries)) {
exit(1);
Expand Down Expand Up @@ -143,7 +147,7 @@ private function editFile(): string
case -1:
die('Unable to run editor');
case 0:
pcntl_exec(config('app.editor'), ['/tmp/' . $this->fileName]);
pcntl_exec($this->editor, ['/tmp/' . $this->fileName]);
break;
default:
pcntl_waitpid($pid, $status);
Expand Down
3 changes: 0 additions & 3 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,4 @@
'providers' => [
App\Providers\AppServiceProvider::class,
],

'editor' => env('EDITOR', '/usr/bin/vi'),
'shell' => env('SHELL', 'bash')
];

0 comments on commit 88d4234

Please sign in to comment.