exim with MySQL password storage

Heritz

Well-Known Member
Aug 12, 2006
45
0
156
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!
 

Heritz

Well-Known Member
Aug 12, 2006
45
0
156
Ok I better discard this option in the meantime since I don't have enough linux knowledge to do this. Thanks anyway.
 

webignition

Well-Known Member
Jan 22, 2005
1,876
2
166
Heritz said:
I really need to do that since my webmail does not change the passwords if they are not stored into a mySQL database.
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 ...
 

Heritz

Well-Known Member
Aug 12, 2006
45
0
156
Hell yeah, I've been trying to set up a CGI script to edit the password for like a week with no success.
 

webignition

Well-Known Member
Jan 22, 2005
1,876
2
166
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.
 

Heritz

Well-Known Member
Aug 12, 2006
45
0
156
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?
 

Heritz

Well-Known Member
Aug 12, 2006
45
0
156
webignition said:
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.
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($ch, CURLOPT_URL, $domain.":2095/dowebmailpasswd.cgi?newpass=".$newpasswd);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_USERPWD, $authstr);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    $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!