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

Offline polinoma

  • Newbie
  • *
  • Posts: 2
Change password postfix+courier+mysql
« on: November 04, 2006, 09:15:28 AM »
It's a nice way to change password /http://postfix.pentachron.net/.

If you want, you can patch roundcube a bit so that your users can change their password in their user preferences. To do so edit the following two files:

First, open 'roundcube/program/steps/settings/func.inc' and search for 'function rcmail_user_prefs_form', then scroll down to the end of this function and add the following code before ' $out .= "\n$form_end";'

// CCC addition
 // show password form
 $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($CONFIG['password']));
// end CCC addition

Then open 'roundcube/program/steps/settings/save_prefs.inc' and insert the following after the line "$a_user_prefs['prefer_html'] = isset($_POST['_prefer_html']) ? TRUE : FALSE;":

// CCC addition
if ($_POST['_password'] != "")
{
  mysql_query("UPDATE ccc.emails SET password = '".$_POST['_password']."' WHERE concat(account, '@', domain) = '".$_SESSION['username']."'")
    or die(mysql_error());
  $_SESSION['password'] = encrypt_passwd($_POST['_password']);
}
// end of CCC addition

Notice: change ccc.emails to yourdatabase.emails if needed!

Notice: the roundcubemail mysql user needs update permissions for the email table!


Offline deejmer

  • Newbie
  • *
  • Posts: 2
Re: Change password postfix+courier+mysql
« Reply #1 on: January 10, 2007, 09:43:45 AM »
I appreciate the post....this is exactly what I'm looking for.....Pardon me, but I'm a total neub and need to ask a clarifying (probably dumb) question:

you say:
Quote
Notice: change ccc.emails to yourdatabase.emails if needed!
Notice: the roundcubemail mysql user needs update permissions for the email table!

I changed my code in the two files as instructed, and the new PW change field does show in Preferences, but when I attempt to change the password, the app says that I dont have update permissions to the email table. When I look at my DB for roundcubemail in phpmyadmin, i do not see an emails table. Am I missing something? Is this outside of the roundcube DB?

If you can clarify, I'd really appreciate it.

Thanks in advance!

Offline CReber

  • Newbie
  • *
  • Posts: 5
Re: Change password postfix+courier+mysql
« Reply #2 on: January 25, 2007, 01:43:41 PM »
It doesn't work in an existing roundcube system, right? What do I need that it works? Can you make a detailled tutorial on that?

Offline bswinnerton

  • Jr. Member
  • **
  • Posts: 49
Re: Change password postfix+courier+mysql
« Reply #3 on: August 24, 2007, 10:19:54 AM »
Yes, I am very interested in this.

Offline Julien

  • Jr. Member
  • **
  • Posts: 17
Re: Change password postfix+courier+mysql
« Reply #4 on: September 10, 2007, 11:51:58 AM »

Offline Le Veilleur

  • Newbie
  • *
  • Posts: 6
Re: Change password postfix+courier+mysql
« Reply #5 on: November 06, 2007, 08:55:15 AM »
Quote from: Julien
I wrote a pacth to do this a few months ago : http://blog.julienwadin.be/index.php/2007/05/26/72-modification-du-password-email-dans-roundcube
Very Nice work, I'll try it with the RC2 this evening.

Offline Le Veilleur

  • Newbie
  • *
  • Posts: 6
Re: Change password postfix+courier+mysql
« Reply #6 on: November 06, 2007, 11:39:33 AM »
Quote from: Julien
I wrote a pacth to do this a few months ago : http://blog.julienwadin.be/index.php/2007/05/26/72-modification-du-password-email-dans-roundcube
There is a bug in your mod. The link to the passwd page doesn't work. Exactly the same problem that's explain in your blog's comments

Offline stefan-becker

  • Newbie
  • *
  • Posts: 5
Re: Change password postfix+courier+mysql
« Reply #7 on: November 07, 2007, 11:40:24 AM »
Can I use this patch with Plesk from SWSoft?

Offline Julien

  • Jr. Member
  • **
  • Posts: 17
Re: Change password postfix+courier+mysql
« Reply #8 on: November 15, 2007, 02:15:38 PM »
Quote from: Le Veilleur
Quote from: Julien
I wrote a pacth to do this a few months ago : http://blog.julienwadin.be/index.php/2007/05/26/72-modification-du-password-email-dans-roundcube
There is a bug in your mod. The link to the passwd page doesn't work. Exactly the same problem that's explain in your blog's comments

My patch works with RC1. I've not yet tested it with RC2. It will be done quickly. Stay in touch.

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #9 on: November 27, 2007, 03:43:32 AM »
Hello there, I just wanted to tell you that I slightly modified your code to make it work for RC2. Works smoothly ;)

Aproximately near line 29 in file "program\steps\settings\save_prefs.inc", there is a block where an array is declared. It starts with "$a_user_prefs = array(". Just add the following line under the "'prefer_html' => isset($_POST['_prefer_html']) ? TRUE : FALSE," line

 // Password MOD
 'password' => isset($_POST['_password']) ? TRUE : FALSE,
 // End Password MOD

Now just AFTER the "foreach ((array)$CONFIG['dont_override'] as $p) ..." near line 39, add the block which handles password saving to DB

// Password MOD
if (isset($_POST['_password']))
{
  $tmpEncPass = YourEncryptionFunctionHERE($_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

Now in "program\steps\settings\func.inc", around line 200, there is some code like "$out .= "\n$form_end";". Just BEFORE this line, add the following block:

 // 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($CONFIG['password']));
 // End Password MOD

It should work :) One problem I'm experiencing is that the field is not empty when Preferences menu is opened, it has a "1" in it.

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #10 on: January 25, 2008, 04:53:44 AM »
Little update: instead of passing $CONFIG['password'] as a parameter for the show function, remove it from function parameters so that the show call looks like this:

$input_password->show()

This is needed to prevent users to erroneously change their password because field has a '1' in it.

Offline rockwilda

  • Jr. Member
  • **
  • Posts: 35
Re: Change password postfix+courier+mysql
« Reply #11 on: March 13, 2008, 03:22:29 PM »
Does this work with rc 0.1 stable?

Is there a patch file?

best regards,
Nico

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #12 on: March 14, 2008, 06:19:13 AM »
I don't know yet, didn't had a chance to test. Will do soon, a release a patch in case :)

Offline Dexterp37

  • Jr. Member
  • **
  • Posts: 14
Re: Change password postfix+courier+mysql
« Reply #13 on: March 16, 2008, 05:54:06 AM »
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!




Offline rockwilda

  • Jr. Member
  • **
  • Posts: 35
Re: Change password postfix+courier+mysql
« Reply #14 on: March 16, 2008, 10:42:42 AM »
Hey thanks for your patch file! But I'm unable to unzip it ... tried it with linux and windows ...