Skip to content

Commit

Permalink
Revert "Revert "(issue #1) Add a whitelist of commands that a person …
Browse files Browse the repository at this point in the history
…can run""

This reverts commit 0e8bf31.
  • Loading branch information
Hydriz committed Nov 12, 2012
1 parent 0e8bf31 commit 5d0cda7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions SpecialHostStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
*/

class SpecialHostStats extends SpecialPage {
protected $cmdwhitelist;

public function __construct() {
parent::__construct( 'HostStats' );
}

public function execute( $par ) {
global $wgHostStatsCommands;
$this->setHeaders();
<<<<<<< HEAD
$this->whitelistedcmds();
$commands = array();
foreach ( $wgHostStatsCommands as $cmd ) {
Expand All @@ -29,12 +30,9 @@ public function execute( $par ) {
}
}
$this->getOutput()->setPageTitle( wfMessage( 'hoststats-title' )->escaped() );
=======
$this->getOutput->setPageTitle( wfMessage( 'hoststats-title' )->escaped() );
>>>>>>> parent of 6a19864... (issue #1) Add a whitelist of commands that a person can run
$outpage = wfMessage( 'hoststats-intro' )->escaped();
$outpage .= "\n";
foreach ( $wgHostStatsCommands as $cmd ) {
foreach ( $commands as $cmd ) {
$outpage .= '<h3>' . $cmd . '</h3>';
$outpage .= "\n<pre>\n" . $this->query( $cmd ) . "</pre>";
}
Expand All @@ -45,4 +43,12 @@ protected function query( $query ) {
$output = wfShellExec( $query );
return $output;
}

protected function whitelistedcmds() {
$this->cmdwhitelist = array(
'df',
'whoami',
'hostname',
);
}
}

0 comments on commit 5d0cda7

Please sign in to comment.