Skip to main content

Module hooks cannot escalate privileges

Comments

3 comments

  • cPanelMichael
    I wrote some perl code to force users php options, and want to run it throught a hook.

    Hello, Could you provide some more details about which specific action you want to hook into, and the steps you have taken thus far? Thank you.
    0
  • macklus
    Hi: Sample code:
    # Package this module. package Cpanel::EscalateTest; # Return errors if Perl experiences problems. use strict; use warnings; # Properly decode JSON. use JSON; # Embed hook attributes alongside the action code. sub describe { my $test1 = { 'category' => 'Cpanel', 'event' => 'Api1::Email::addpop', 'stage' => 'post', 'hook' => 'Cpanel::EscalateTest::test1func', 'exectype' => 'module', 'escalateprivs' => 1, }; return [$test1]; } sub test1func { my ( $context, $data ) = @_; # Get the data that the system passes to the hook. my $result = 0; # This boolean value is set to fail. my $message = 'This is an error message.'; # This string is a reason for $result. # Just touch file on /tmp open( F, ">/tmp/hook_works" ); print F "work\n"; close( F ); # Return the hook's result and message. return $result, $message; } 1;
    this code are located on /usr/local/cpanel/Cpanel/EscalateTest.pm When i try to add:
    root@cp03 [~]# /usr/local/cpanel/bin/manage_hooks add module Cpanel::EscalateTest --privileged Module hooks cannot escalate privileges There was a failure adding a hook, removing all hooks contained with in. Please contact the maintainer of this hook for assistance. root@cp03 [~]#
    By now, it works on script basics, but it is deprecated, so wish to do that on module basic thanks in advance
    0
  • cPanelMichael
    'category' => 'Cpanel', 'event' => 'Api1::Email::addpop',

    Is there a specific reason you are using cPanel API 1 instead of UAPI? Here's the UAPI function for adding an email address: Guide to Standardized Hooks - Privilege Escalation - Software Development Kit - cPanel Documentation Tutorial - Create a Standardized Hook - Software Development Kit - cPanel Documentation Thank you.
    0

Please sign in to leave a comment.