list( $this->config, $this->extra_config ) = $configurator->to_array();
}
+ private function check_root() {
+ if ( $this->config['allow_root'] )
+ return; # they're aware of the risks!
+ if ( !function_exists( 'posix_geteuid') )
+ return; # posix functions not available
+ if ( posix_geteuid() !== 0 )
+ return; # not root
+
+ WP_CLI::error(
+ "YIKES! It looks like you're running this as root. You probably meant to" .
+ "run this as the user that your WordPress install exists under.\n" .
+ "\n" .
+ "If you REALLY mean to run this as root, we won't stop you, but just " .
+ "bear in mind that any code on this site will then have full control of " .
+ "your server, making it quite DANGEROUS.\n" .
+ "\n" .
+ "If you'd like to continue as root, please run this again, adding this " .
+ "flag: --allow_root\n" .
+ "\n" .
+ "If you'd like to run it as the user that this site is under, you can " .
+ "run the following to become the respective user:\n" .
+ "\n" .
+ " su USER -c -- wp ...\n" .
+ "\n"
+ );
+ }
+
public function before_wp_load() {
$this->init_config();
$this->init_colorization();
$this->init_logger();
+ $this->check_root();
+
if ( empty( $this->arguments ) )
$this->arguments[] = 'help';