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.

exim with MySQL password storage

Discussion in 'General Discussion' started by Heritz, Sep 26, 2006.

  1. Heritz

    Heritz Well-Known Member

    Joined:
    Aug 12, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Hello guys,

    Actually, cPanel seems to store the email account passwords into shadow files under home/user/etc/domain/shadow.

    I've been told that I can configure exim to store the passwords into a MySQL database. I really need to do that since my webmail does not change the passwords if they are not stored into a mySQL database.

    Any ideas about this? Thanks in advance!
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
  3. Heritz

    Heritz Well-Known Member

    Joined:
    Aug 12, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Thanks a lot chirpy.
     
  4. Heritz

    Heritz Well-Known Member

    Joined:
    Aug 12, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Ok I better discard this option in the meantime since I don't have enough linux knowledge to do this. Thanks anyway.
     
  5. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    It should be relatively straightfoward to modify the webmail app to change passwords through cPanel instead of it's current method.

    Straightforward, that is, if you know the ins and outs of cPanel ...
     
  6. Heritz

    Heritz Well-Known Member

    Joined:
    Aug 12, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    Hell yeah, I've been trying to set up a CGI script to edit the password for like a week with no success.
     
  7. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Instead of trying to find out how a cPanel-managed mail account's password is correctly reset, a more simple option could be to script a secure wrapper for the cPanel interface. This can be relatively easily managed in PHP with the right amount of curl.

    The end result could be a function that can be integrated into your webmail app, allowing the app to reset passwords the cPanel way.

    I've recently been implementing a fair amount of cPanel integration into third-party PHP apps and can say that what you want to do is quite feasible.
     
  8. Heritz

    Heritz Well-Known Member

    Joined:
    Aug 12, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    You mean create a PHP script to edit the password files? I am a PHP developer and trust me, I tried it, but the thing is that I can't even open the shadow files where exim store the passwords. If I can't open those files I am screwed.

    Those files seems to be under special permissions, and PHP its not able to open them. I never used CURL before, do you think CURL will let me open this files?
     
  9. Heritz

    Heritz Well-Known Member

    Joined:
    Aug 12, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    6
    OMG I did it just like you said with CURL man. I made a wrapper for the cPanel CGI script, I send the new password and the system is changing it successfully. Pretty transparent, fully PHP and completely integrated into my email app. It was pretty easy man, you were right.

    Thanks a lot for that suggestion man! Here is my code:

    PHP:
      $cpaneluser $_SESSION['username'];
      
    $cpanelpass $curpasswd;
      
    $data=explode('@'$_SESSION['username']);
      
    $domain=$data[1];
      
      
    // First do a check if curl_init exists:
      
    if (function_exists("curl_init")) {
        
    $authstr "$cpaneluser:$cpanelpass";

        
    $ch curl_init();
        
    curl_setopt($chCURLOPT_URL$domain.":2095/dowebmailpasswd.cgi?newpass=".$newpasswd);
        
    curl_setopt($chCURLOPT_HEADER0);
        
    curl_setopt($chCURLOPT_USERPWD$authstr);
        
    curl_setopt($chCURLOPT_RETURNTRANSFER,1);
        
    curl_setopt($chCURLOPT_SSL_VERIFYPEER,1);
        
    curl_setopt($chCURLOPT_SSL_VERIFYHOST,1);
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);

        
    $cbsreturn curl_exec($ch);
        
    //echo "Result: " . $cbsreturn; // Returns all the html from cpanel, uncomment to view

        
    if (strpos($cbsreturn"Changed password for")) {
          return 
    true;
        } else {
          return 
    false;
        }

        
    //echo curl_error($ch);
        
    curl_close($ch);
      } 

    This is working as hell!
     
  10. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Good to hear!
     
Loading...

Share This Page