Author Topic: Change password postfix+courier+mysql  (Read 47971 times)

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #15 on: March 16, 2008, 03:38:34 PM »
Ouch, try this one, which is .txt but the other one works fine for me :| (WinZip) Please note that you may need to change the query to suit your database, in save_prefs.inc.

I also wrote a short tutorial to help adding this mod to your roundcube installation which can be found here.

Offline speedyboy

  • Newbie
  • *
  • Posts: 5
Re: Change password postfix+courier+mysql
« Reply #16 on: March 24, 2008, 02:28:43 PM »
I have a problem with the password, unfortunately for me ENCRYPT not works.

And md5 is not works.

In my database the password is ENCRYPT Function, unfortunately when I modify it the roundcube , that password is not going though already.

Thank You

And sorry about my bad english

Offline speedyboy

  • Newbie
  • *
  • Posts: 5
Re: Change password postfix+courier+mysql
« Reply #17 on: March 24, 2008, 02:35:34 PM »
error log

[24-Mar-2008 20:02:01] PHP Fatal error: Call to undefined function ENCRYPT()

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #18 on: March 24, 2008, 03:30:04 PM »
It looks like you have no ENCRYPT function in your sources. Are you sure there's such a function in your code? What are you using to store passwords?

Offline speedyboy

  • Newbie
  • *
  • Posts: 5
Re: Change password postfix+courier+mysql
« Reply #19 on: March 25, 2008, 07:21:13 AM »
program\steps\settings\save_prefs.inc
// Password MOD
password' => isset($_POST['_password']) ? TRUE : FALSE,
// End Password MOD


 // Password MOD
if (isset($_POST['_password']))
{
$tmpEncPass = ENCRYPT($_POST['_password'], "");
 
 mysql_query("UPDATE CCC.TableWithPasswordHERE SET password = '".$tmpEncPass."' WHERE username = '".$_SESSION['username']."'")
or die(mysql_error());
 
$_SESSION['password'] = encrypt_passwd($_POST['_password']);
}
 // End Password MOD


program\steps\settings\func.inc

 // Password MOD
$field_id = 'rcmfd_password';
$input_password = new textfield(array('name' => '_password', 'id' => $field_id, 'size' => 20));
$out .= sprintf("%s (empty = unchanged)\n",
$field_id,
rep_specialchars_output(rcube_label('password')),
$input_password->show();
// End Password MOD

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #20 on: March 25, 2008, 07:26:56 AM »
You have to change this line:

Code: [Select]
$tmpEncPass = ENCRYPT($_POST['_password'], "");
In order to match the encryption you use to store your passwords in your database. If your passwords are stored as md5 hashes, you could use php native md5 function referenced here in PHP manual.

Don't forget the query as well to suit your database structure.

Offline speedyboy

  • Newbie
  • *
  • Posts: 5
Re: Change password postfix+courier+mysql
« Reply #21 on: March 25, 2008, 10:14:15 AM »
Thanks for the idea, Dexterp37 O0

Offline LaPanthere

  • Newbie
  • *
  • Posts: 1
Re: Change password postfix+courier+mysql
« Reply #22 on: March 28, 2008, 09:12:11 AM »
for native DES crypt you need to change the crypt like :
 
$tmpEncPass = crypt($_POST['_password'],'xx');

regards

Offline Martin2008

  • Newbie
  • *
  • Posts: 2
Re: Change password postfix+courier+mysql
« Reply #23 on: April 05, 2008, 05:25:08 AM »
Quote from: Dexterp37
I just applied this mod to 0.1stable, and it works flawlessly. I've attached the patch to this post. Let me know if it works, that's my first patch!




Hello,

I really like this plugin and I am not really a coder but I was wondering where do I get the specific info on the following:

1. YourEncryptionFunctionHERE
2. UPDATE CCC.TableWithPasswordHERE SET

I apologize for my ignorance on this matter. Thanks.

Martin

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #24 on: April 06, 2008, 01:34:11 PM »
Since you also left a comment on my blog, I also replied there :)

Offline acadia

  • Newbie
  • *
  • Posts: 1
Re: Change password postfix+courier+mysql
« Reply #25 on: April 10, 2008, 11:07:37 PM »
So, I'm new to roundcube, quick question, does a plugin already exist for mysql,exim,courier mail to change password (virtual user setup), or do I have to write my own? Basically, how would you do changepassword with roundcube given mysql,exim,courier mail virtual user setup? What I'm reading here are people are writing some bits of their own code, is this standard fair?

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #26 on: April 11, 2008, 02:58:09 AM »
Yes, sort of. AFAIK, there's no intention to bring change password functionality in roundcube because of the very different behavior each backend software has. The code I posted works directly on the underlying database to write password in it. You should be able to use it as well, if exim stores passwords in a database.

Offline speedyboy

  • Newbie
  • *
  • Posts: 5
Re: Change password postfix+courier+mysql
« Reply #27 on: April 13, 2008, 11:04:42 AM »
Hello boys

And Thanks for the ideas

How it would be possible to rewrite this md5 to native DES crypt (ENCRYPT) whit this script.

function rcmail_save_passwd($curpassword, $newpassword){
   global $DB, $CONFIG, $OUTPUT;
      
   $DB->query('select password from postfix.mailbox where username=\''.$_SESSION['username'].'\'');
   $row = $DB->fetch_assoc();
   $actualCryptedPassword = md5($curpassword);
   
   if ($actualCryptedPassword != $row['password'])
      return false;
   else {//ok, we can proceed
      $DB->query('update postfix.mailbox set password=\''.md5($newpassword).'\',modified=NOW() where username=\''.$_SESSION['username'].'\'');
      if (!$DB->is_error()) {
         $_SESSION['password'] = encrypt_passwd($newpassword); //save the new password in the session
        return true;
      } else
        return false;
      
   }
}

http://blog.julienwadin.be/index.php/2007/05/26/72-modification-du-password-email-dans-roundcube
-----------------------------------------------

Thank You

Offline CPECAH

  • Newbie
  • *
  • Posts: 1
what about roundcube-rc2-stable?
« Reply #28 on: January 11, 2009, 03:57:24 AM »
it looks like there is some change in the code - because in the
program\steps\settings\func.inc
i can not find where to put the password box.
can you help ?

Quote from: speedyboy;11090
program\steps\settings\save_prefs.inc
// Password MOD
password' => isset($_POST['_password']) ? TRUE : FALSE,
// End Password MOD


 // Password MOD
if (isset($_POST['_password']))
{
$tmpEncPass = ENCRYPT($_POST['_password'], "");
 
 mysql_query("UPDATE CCC.TableWithPasswordHERE SET password = '".$tmpEncPass."' WHERE username = '".$_SESSION['username']."'")
or die(mysql_error());
 
$_SESSION['password'] = encrypt_passwd($_POST['_password']);
}
 // End Password MOD


program\steps\settings\func.inc

 // Password MOD
$field_id = 'rcmfd_password';
$input_password = new textfield(array('name' => '_password', 'id' => $field_id, 'size' => 20));
$out .= sprintf("%s (empty = unchanged)\n",
$field_id,
rep_specialchars_output(rcube_label('password')),
$input_password->show();
// End Password MOD

Offline lion_kg

  • Newbie
  • *
  • Posts: 1
Change password postfix+courier+mysql
« Reply #29 on: January 20, 2009, 07:04:42 AM »
I am using roundcube 0.2.1 too and cannot find where to put the change password section in settings. I mean the part that should go into program\steps\settings\func.inc.  Has anyone applied this patch on stable version?