The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using the Universal Password Trap

Discussion in 'cPanel Developers' started by fusephase, Aug 18, 2011.

  1. fusephase

    fusephase Member

    Joined:
    Aug 18, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I'm trying to use the Universal Password Trap, but it is not working.

    I've created the module with this code:
    Code:
    #!/usr/bin/perl
    
    package Cpanel::ChangePasswd::WrapperModule;
    use strict;
    
    sub process {
        my %OPTS    = @_;
        my $user    = $OPTS{'user'};
        my $newpass = $OPTS{'newpass'};
        my $message = $OPTS{'message'};    #only when changing password as root
        my $rawout  = $OPTS{'rawout'};     #only when changing password as root
        my $applist = $OPTS{'applist'};    #only when changing password as root
    
        $rawout  =~ s/[\n\r]/ /g;
        $message =~ s/[\n\r]/ /g;
    
        foreach my $app ( @{$applist} ) {
            if ( $app->{'app'} =~ m/mysql/i ) {
    
                system( 'php', '-f', "/home/clientes/fphase/public_html/ChangePasswordAAcliente.php", $user, $newpass );
            }
    
        }
    }
    1;
    And i have the ChangePasswordAAcliente.php with this code:
    PHP:
    <?php


       $to      
    'myemail@fusephase.com';
       
    $subject 'Alterar a Password';
       
    $message 'password alterada';
       
    $headers 'From: myemail@fusephase.com' "\r\n" .
       
    'Reply-To: myemail@fusephase.com' "\r\n" .
       
    'X-Mailer: PHP/' phpversion();

       
    mail($to$subject$message$headers);


    ?>

    But i never receive that email when the password is changed.
    The paths are correct.

    Thanks!
     
  2. syslint

    syslint Well-Known Member

    Joined:
    Oct 9, 2006
    Messages:
    249
    Likes Received:
    6
    Trophy Points:
    18
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Twitter:
    So you saying the password is changed and not received email ?

    If so please check the email server logs and check your junk folder or spam folder
     
  3. fusephase

    fusephase Member

    Joined:
    Aug 18, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    When i change the password, the PHP script is not runned, so must be a problem with the module code, since if i run the PHP script from the browser i receive the email.
     
    #3 fusephase, Aug 19, 2011
    Last edited: Aug 19, 2011
  4. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Is there anything in /usr/local/cpanel/logs/error_log from when this is run?
     
  5. fusephase

    fusephase Member

    Joined:
    Aug 18, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    I only have this on the log file

    Code:
    Undefined subroutine &Cpanel::ChangePasswd::ChangePasswordAAcliente::process called at (eval 2) line 1.
    /usr/local/cpanel/bin/ftpadmin : Syncing Ftp Databases....
    Undefined subroutine &Cpanel::ChangePasswd::ChangePasswordAAcliente::process called at (eval 2) line 1.
     
  6. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    There's the problem. Remove the shebang from your script, the first line should be "package ...". only perl scripts need a shebang, modules do not as they are loaded by scripts.
     
  7. fusephase

    fusephase Member

    Joined:
    Aug 18, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hi Matt,

    Still getting the same error
    Code:
    /usr/local/cpanel/bin/ftpadmin : Syncing Ftp Databases....
    Undefined subroutine &Cpanel::ChangePasswd::ChangePasswordAAcliente::process called at (eval 2) line 1.
    
    I removed the first line, but still not working, maybe im doing something wrong...

    This is the module:
    Code:
    package Cpanel::ChangePasswd::WrapperModule;
    use strict;
    
    sub process {
        my %OPTS    = @_;
        my $user    = $OPTS{'user'};
        my $newpass = $OPTS{'newpass'};
        my $message = $OPTS{'message'};    #only when changing password as root
        my $rawout  = $OPTS{'rawout'};     #only when changing password as root
        my $applist = $OPTS{'applist'};    #only when changing password as root
    
        $rawout  =~ s/[\n\r]/ /g;
        $message =~ s/[\n\r]/ /g;
    
        foreach my $app ( @{$applist} ) {
            if ( $app->{'app'} =~ m/mysql/i ) {
    
                system( 'php', '-f', "/home/clientes/fphase/public_html/ChangePasswordAAcliente.php", $user, $newpass );
            }
    
        }
    }
    
    1;
     
  8. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Could I see an ls of /usr/local/cpanel/Cpanel/ChangePasswd?
     
  9. fusephase

    fusephase Member

    Joined:
    Aug 18, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Sure.

    Code:
    root@core [/usr/local/cpanel/Cpanel/ChangePasswd]# ls
    ./   ChangePasswordAAcliente.pm  SendPasswordAClientes.pm.save
    ../  SampleModule.pmtxt
    root@core [/usr/local/cpanel/Cpanel/ChangePasswd]#
    
    I didn't create this SendPasswordAClientes.pm.save file
     
  10. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Is the package line:

    Code:
    package Cpanel::ChangePasswd::WrapperModule;
    or

    Code:
    package Cpanel::ChangePasswd::ChangePasswordAAcliente;

    it should be the later. If that's not the problem, file a ticket and put "ATTN: Matt Dees Universal Password Trap" as the topic and I'll take a look at it.
     
  11. fusephase

    fusephase Member

    Joined:
    Aug 18, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hi Matt, yes is the latest one, ok i will create a ticket regarding the issue.

    Thanks!
     
Loading...

Share This Page