From 20e760bbec78e35412b03de2274dec03bdb27c22 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Fri, 20 Dec 2019 13:34:05 +0100 Subject: [PATCH 1/2] Improvements to shell command Currently we only forward `$COLS` and `$ROWS` to `exec`, but we should do the same on `shell`. Also, when you `shell` previosuly we were logging people in as `www-data` which means you can't do things like install new packages. I don't see any issue with using root and giving those caps on `shell` as it's likely you'll be doing stuff like that. --- inc/composer/class-command.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/inc/composer/class-command.php b/inc/composer/class-command.php index 964b5f94..fb7fd812 100644 --- a/inc/composer/class-command.php +++ b/inc/composer/class-command.php @@ -146,7 +146,7 @@ protected function start( InputInterface $input, OutputInterface $output ) { // Check install was successful. if ( $install_failed ) { - $output->writeln( 'WordPress install failed.' ); + $output->writeln( sprintf( 'WordPress install failed. Exited with error code %d', $install_failed ) ); return $install_failed; } @@ -312,11 +312,15 @@ protected function logs( InputInterface $input, OutputInterface $output ) { } protected function shell( InputInterface $input, OutputInterface $output ) { + $columns = exec( 'tput cols' ); + $lines = exec( 'tput lines' ); passthru( sprintf( - 'cd %s; VOLUME=%s COMPOSE_PROJECT_NAME=%s docker-compose exec php /bin/bash', + 'cd %s; VOLUME=%s COMPOSE_PROJECT_NAME=%s docker-compose exec -e COLUMNS=%d -e LINES=%d -u root php /bin/bash', 'vendor/altis/local-server/docker', - getcwd(), - $this->get_project_subdomain() + escapeshellarg( getcwd() ), + $this->get_project_subdomain(), + $columns, + $lines ), $return_val ); return $return_val; From 038302943a9a28385b61e605203cd269e56fb216 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Fri, 10 Jan 2020 09:58:17 +0100 Subject: [PATCH 2/2] Remove root in shell command --- inc/composer/class-command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/composer/class-command.php b/inc/composer/class-command.php index fb5148d9..2834520a 100644 --- a/inc/composer/class-command.php +++ b/inc/composer/class-command.php @@ -321,7 +321,7 @@ protected function shell( InputInterface $input, OutputInterface $output ) { $columns = exec( 'tput cols' ); $lines = exec( 'tput lines' ); passthru( sprintf( - 'cd %s; VOLUME=%s COMPOSE_PROJECT_NAME=%s docker-compose exec -e COLUMNS=%d -e LINES=%d -u root php /bin/bash', + 'cd %s; VOLUME=%s COMPOSE_PROJECT_NAME=%s docker-compose exec -e COLUMNS=%d -e LINES=%d php /bin/bash', 'vendor/altis/local-server/docker', escapeshellarg( getcwd() ), $this->get_project_subdomain(),