Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ WP-CLI version: 0.25.0

You can update WP-CLI with `wp cli update` ([doc](https://wp-cli.org/commands/cli/update/)), or by repeating the installation steps.

If WP-CLI is owned by root or another system user, you'll need to run `sudo wp cli update`.

Want to live life on the edge? Run `wp cli update --nightly` to use the latest nightly build of WP-CLI. The nightly build is more or less stable enough for you to use in your development environment, and always includes the latest and greatest WP-CLI features.

### Tab completions
Expand Down
12 changes: 9 additions & 3 deletions php/WP_CLI/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,18 @@ private function init_config() {
}

private function check_root() {
if ( $this->config['allow-root'] )
if ( $this->config['allow-root'] ) {
return; # they're aware of the risks!
if ( !function_exists( 'posix_geteuid') )
}
if ( count( $this->arguments ) >= 2 && 'cli' === $this->arguments[0] && 'update' === $this->arguments[1] ) {
return; # make it easier to update root-owned copies
}
if ( !function_exists( 'posix_geteuid') ) {
return; # posix functions not available
if ( posix_geteuid() !== 0 )
}
if ( posix_geteuid() !== 0 ) {
return; # not root
}

WP_CLI::error(
"YIKES! It looks like you're running this as root. You probably meant to " .
Expand Down