Skip to content

Commit

Permalink
Try to get admin_password from the ENV by default
Browse files Browse the repository at this point in the history
In a situation where you run wp-cli with `--admin-password`, then plain-text
password is exposed in process list (e.g. `ps aufx`). We might be able to use
`--admin-password=$WP_CLI_CORE_INSTALL_ADMIN_PASSWORD`, but it's not possible also
when running in a nested mode (e.g. unshare() -> chroot() -> execvp() chain).

Thus, this relaxes a bit the installation and tries to get the default password
from the environment itself by default.

It doesn't break a current functionality.

```
% export WP_CLI_CORE_INSTALL_ADMIN_PASSWORD=password123 ; ./vendor/bin/wp core install --admin_user=admin --url=donatas.net --title=wp [email protected]
Success: WordPress installed successfully.

% ./vendor/bin/wp user check-password admin password123 && echo OK
OK
```

Signed-off-by: Donatas Abraitis <[email protected]>
Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed May 31, 2024
1 parent f7580f9 commit cf3ba9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,11 +629,13 @@ function wp_new_blog_notification() {

require_once ABSPATH . 'wp-admin/includes/upgrade.php';

$admin_password = getenv( 'WP_CLI_CORE_INSTALL_ADMIN_PASSWORD' );

$defaults = [
'title' => '',
'admin_user' => '',
'admin_email' => '',
'admin_password' => '',
'admin_password' => false !== $admin_password ? $admin_password : '',
];

if ( Utils\wp_version_compare( '4.0', '<' ) ) {
Expand Down

0 comments on commit cf3ba9c

Please sign in to comment.