Skip to content

Commit

Permalink
critical fix priv_ actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveorevo committed Jun 10, 2023
1 parent 06c3026 commit 031d0e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hooks/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $hcpp->patch_file(
$hcpp->patch_file(
'/usr/local/hestia/func/main.sh',
'# Internal variables',
'# Internal variables' . "\nPARENT=\$(tr '\\0' '\\n' < \"/proc/\$PPID/cmdline\")\nif [[ \$PARENT == *sudo* ]]; then\n eval \"\$(/etc/hestiacp/hooks/priv_actions \$PARENT)\"\nfi\n"
"# Internal variables\nPARENT=\$(tr '\\0' '\n' < \"/proc/\$PPID/cmdline\" | sed 's/.*/\"&\"/');\nPARENT=\${PARENT//\$'\\n'/ };\nif [[ \$PARENT == *sudo* ]]; then\n PARENT=\"/etc/hestiacp/hooks/priv_actions \$PARENT\";\n eval_out=\$(eval \"\$PARENT\");\n eval \"\$eval_out\";\nfi"
);

// inc/main.php - check for Hestia 1.7.X
Expand Down
9 changes: 4 additions & 5 deletions hooks/priv_actions
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@
/**
* Intercept privilege (sudo) calls to Hestia's bin/ directory and invoke plugin actions/filters
* before executing the original command.
*
*
* @version 1.0.0
* @license GPL-3.0
* @link https://github.com/steveorevo/hestiacp-pluginable
*
*
*/

// Check if we've already filtered the arguments
if ( getenv('HCPPFILTERED') == '1' ) return;

// Remove the first argument, which is the path to the script
array_shift( $argv );

// Obtain the API command and parameters
$cmd = '';
$params = [];
foreach( $argv as $a ) {

// Isolate the API command name
if ( strpos( $a, '/usr/local/hestia/bin/' ) !== false ) {
$cmd = str_replace( '/usr/local/hestia/bin/', '', $a );
Expand All @@ -34,7 +33,7 @@ foreach( $argv as $a ) {
}
}

// Throw our priv action filter, strip v- prefix, and replace dashes with underscores
// Throw our priv action filter, strip v- prefix, and replace dashes with underscores
require_once( '/usr/local/hestia/web/pluginable.php' );
global $hcpp;
$event = $hcpp->delLeftMost( $cmd, 'v-' );
Expand Down

0 comments on commit 031d0e3

Please sign in to comment.