Roundcube Community Forum

Third Party Contributions => Old Style Plug-Ins => Topic started by: lucifer on February 20, 2009, 02:06:22 PM

Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.1 (Updated)
Post by: lucifer on February 20, 2009, 02:06:22 PM
After a long searching I have found Andy and Natasha Wheatley’s Blog. They have made a virtual host password change for roundcube 0.2-stable. But I tried to use it but having some problem. Then I have modified again for them who are using qmail, mysql and vpopmail for their mail server. Thanks all the people who have worked for this password plug-in.

Downloads: A new patch file has been added

Qmail+Mysql+Vpopmail Password Change Patch v1.0 (http://www.roundcubeforum.net/downloads.php?do=file&id=17)

Note: Please follow the instruction before using
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 20, 2009, 02:12:13 PM
Qmail+Mysql+Vpopmail Password Change Patch v1.0 (http://www.roundcubeforum.net/downloads.php?do=file&id=17) has been updated!
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 20, 2009, 02:19:57 PM
Qmail+Mysql+Vpopmail Password Change Patch v1.0 (http://www.roundcubeforum.net/downloads.php?do=file&id=17) has been updated!
Title: nice job
Post by: crazy on February 21, 2009, 12:01:54 PM
It Worked! O0

This is really nice. but have some question.

what would be the proper permission for the roundcube database user to use vpopmail database ??

can you make a vacation and forwarder for qmail.
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 22, 2009, 01:09:34 PM
for database just give select and update permission to roundcube db user.

I am working on vacation plug-in. soon you will get it. :cool:
Title: Multiple Domains
Post by: myrrhh on February 23, 2009, 01:53:24 PM
Hello,
Thanks so much for your excellent documentation and patch.

  I have a question about how to select and update one of multiple domain tables from the vpopmail mysql database.  Is there a way to extract the domain from the $emailuser variable (in password.inc) and select and update the proper domain table contained in the vpopmail DB? In my vpopmail database the domains are stored as tables containing the user information fields (pw_name,pw_passwd...etc) The table names have an underscore substituted for the dot in the domain name.

Example: email user domain= exdomain.com - vpopmail domain table name= exdomain_com

I have tried my primitive abilities with php and regex and am unable to get this to work properly.  Any help or direction that anyone can offer is much appreciated. Thanks again.

Cheers
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 23, 2009, 11:52:19 PM
open /program/steps/settings/password.inc

and edit $passwordquery = "UPDATE vpopmail.domain_table SET pw_passwd = '$crypted',pw_clear_passwd='".$new_password."' WHERE pw_name = '$username';";

you can see red one is database name ie. vpopmail. and blue one is your table name ie. exdomain_com

just upadte this two value, I hope it will work.
Title: Multiple Domains
Post by: myrrhh on February 24, 2009, 03:34:22 AM
Thank you so much.  That does work for one domain... but if the vpopmail DB has multiple domains and users within those domains using one Round Cube interface then for each domain the "domain_table" must be different.  Since the $emailuser variable is set for each user after login can it be used to set the "domain_table" name within the vpopmail DB during a  password change?

Perhaps there could be a section of code within the function rcube_save_password that takes the $emailuser variable, splits out the email username and domain as two variables - $username and $domain.  then another line that replaces the dot(.) in the domain name variable $domain with an underscore and then assign it as variable $vdom.  Then lastly set up the mysql query string using the $vdom variable as the vpopmail."domain_table" name and the $username variable as the $pw_name variable(similar to below).  My poor regex, PHP and mysql skills prevent me from being able to modify this section properly.

I have tried adding code something like with no success...
 just after the line-

  $cryptedpw = mkpasswd3($new_password,$crypted);  

 list ($user,$domain) = split ( '@',$emailuser);
my bad php and regex
 $vdom = preg_replace ("/^[a-zA-Z0-9]+[\.][a-zA-Z]+/", "/^[a-zA-Z0-9]+[_][a-zA-Z]+/", $domain);  (I am soooo bad at regex)

$username = preg_replace( "/^([^@]+)(@.*)$/", "$1", $emailuser);

$passwordquery = "UPDATE vpopmail.'"$vdom"' SET pw_passwd = '$crypted',pw_clear_passwd='".$new_password."' WHERE pw_name = '$username';";

I can't figure out the php and  regex necessary for substituting the "_ " in the place of the "." in the $domain variable? and calling it $vdom

and then using this variable $vdom as the table name in the mysql query(or update)

I have no clue if something like this will work and am not the person to figure this out but perhaps you can help.  Any assistance with the regex and query string is greatly appreciated.  Many thanks to you for your consideration.
Cheers
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 24, 2009, 04:01:11 AM
Sorry I didn't notice that you are asking for multiple domain. Just give me some time i am fixing it. it should be dynamic and have to make another function. no porbs. give you the update soon. and thanks again for pointing this issue.
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: fritz001 on February 24, 2009, 11:08:39 AM
It seems there is a problem patching latest myroundcube !!

patch -p1 patching file index.php
Hunk #1 succeeded at 293 (offset 100 lines).
patching file program/js/app.js
Hunk #1 FAILED at 235.
Hunk #2 FAILED at 904.
2 out of 2 hunks FAILED -- saving rejects to file program/js/app.js.rej
patching file program/localization/en_GB/labels.inc
patching file program/localization/en_GB/messages.inc
patching file program/localization/en_US/labels.inc
patching file program/localization/en_US/messages.inc
patching file program/steps/settings/password.inc
patching file skins/default/includes/settingstabs.html
patching file skins/default/templates/password.html
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: crazy on February 25, 2009, 01:01:46 AM
It worked for me. I think you have already updated something in your app.js file. It's better you use a fresh roundcube folder and use the patch! or you can do it manually and just replace the patched password.inc file
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 25, 2009, 02:20:51 AM
UPDATE FOR MULTIPLE DOMAIN

just update the function. It will work for multiple domain. I will update my patch soon.

function rcube_save_password($current_password, $new_password)
{
        global $OUTPUT, $RCMAIL;

        $emailuser=$_SESSION['username'];

        $db = rcmail::get_instance()->get_dbh();

        $crypted = '';
        $cryptedpw = mkpasswd3($new_password,$crypted);

        $domain = split("@",$emailuser);

        $dom_table = str_replace(".","_",$domain[1]);

        // ONLY CHANGE YOUR vpopmail DATABASE NAME !!!!!

        $passwordquery = "UPDATE vpopmail.$dom_table SET pw_passwd = '$crypted',pw_clear_passwd='".$new_password."' WHERE pw_name = '$domain[0]';";

        $db->query($passwordquery);

        $_SESSION['password'] = encrypt_password($new_password);

        $OUTPUT->show_message('successfullysaved', 'confirmation');
}



-Thanks
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 25, 2009, 02:44:39 AM
Qmail+Mysql+Vpopmail Password Change Patch v1.1 (http://www.roundcubeforum.net/downloads.php?do=file&id=17) has been updated!
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: lucifer on February 25, 2009, 02:48:42 AM
Qmail+Mysql+Vpopmail Password Change Patch v1.1 (http://www.roundcubeforum.net/downloads.php?do=file&id=17) has been updated!
Title: Great Work - Multiple Domains Mysql+Vpopmail Password Change!
Post by: myrrhh on February 25, 2009, 04:44:24 PM
lucifer,
 Thank you so much for your excellent work! The password change for multiple domains works flawlessly with vpopmail.  I didn't used the new patch though, just modified the existing code with the code from your earlier posting, changed the db update permissions and voila!!
Thanks again.  This is something that I have wanted since I first started using rOundcube.

Lasty did I mention thank you! Excellent Work!
Cheers-
myrrhh
Title: I did it :)
Post by: nadir on February 26, 2009, 01:42:10 AM
Who-ho!! i did it. Now my roundcube works with postfix+dovecot. :D
Just change this line:
$passwordquery = "UPDATE vpopmail.$dom_table SET pw_passwd = '$crypted',pw_clear_passwd='".$new_password."' WHERE pw_name = '$domain[0]';";

to:
$passwordquery = "UPDATE postfix.mailbox SET password = '$crypted'  WHERE username = '$domain[0]@$domain[1]' and domain = '$domain[1]';"

postfix version: 2.5.6,1
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: fritz001 on March 03, 2009, 01:23:34 PM
it might be a good idea to modify password.inc to increase password complexity

something like that

rc_passwd_len
rc_passwd_uppcase_special_chars

to test somehow the password len and if password contains uppercases and special chars
Title: mods to handle aliased domain, old vpopmail schema
Post by: tjm74 on March 05, 2009, 09:28:19 PM
I guess I have an old version of vpopmail, my schema just has one table "vpopmail" but it has a pw_domain column and all users are stored there.

Also, I log in using an alias domain so for this to work it needs to resolve the domain alias.  I hacked together a new version of the function rcube_save_password (in program/steps/settings/password.inc) that works in my setup, maybe somebody else will find this useful:

Code: [Select]
function rcube_save_password($current_password,$new_password)
{
        global $OUTPUT, $RCMAIL;

        $emailuser=$_SESSION['username'];

        $db = rcmail::get_instance()->get_dbh();

        $crypted = '';
        $cryptedpw = mkpasswd3($new_password,$crypted);

        $domain = split("@",$emailuser);
        $true_domain = $domain[1];
        // resolve any domain aliasing (FIXME I should sanitize the dynamic part of this command)
        $true_domain = exec("/home/vpopmail/bin/vdominfo -n ".$true_domain);

        $dom_table = str_replace(".","_",$true_domain);

        // ONLY CHANGE YOUR vpopmail DATABASE NAME !!!!!

        $passwordquery = "UPDATE vpopmail.vpopmail SET "
            . "pw_passwd = " . $db->quote($crypted) . ","
            . "pw_clear_passwd = " . $db->quote($new_password)
            . " WHERE pw_domain = " . $db->quote($true_domain)
            . " AND pw_name = " . $db->quote($domain[0]) . ";";

        $db->query($passwordquery);

        $_SESSION['password'] = encrypt_password($new_password);

        $OUTPUT->show_message('successfullysaved', 'confirmation');
}


Watch out, I hardcoded the path to vdominfo (not sure how to grok it) and left a somewhat insecure "exec" call in there.

OTOH, the author should really use $db->quote as shown above to prevent SQL injection hacks (unlikely in this case but you never know).  But otherwise, nice mod!!!  Thanks,

 -tom
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: Unatine on March 26, 2009, 05:40:08 PM
Hi!
Some troubles with this patch (v1.1)
Use latest stable release of RoundCube.

After applying patch (app.js applied manualy), new tab appear in Settings, but when try click on Password tab, nothing happend.

If enter path like this: "?_task=settings&_action=password", password change form appear.
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: Unatine on March 27, 2009, 01:50:28 AM
Quote from: Unatine;18075
Hi!
Some troubles with this patch (v1.1)
Use latest stable release of RoundCube.

After applying patch (app.js applied manualy), new tab appear in Settings, but when try click on Password tab, nothing happend.

If enter path like this: "?_task=settings&_action=password", password change form appear.


Solved. Sorry :)
Title: i have same problem.
Post by: nadir on April 06, 2009, 01:22:51 PM
hi. i have a same problem too... password tab not works on new stable verion :(
anybody can give me new patch?
thanks
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: nadir on April 15, 2009, 06:20:41 AM
Quote from: Unatine;18081
Solved. Sorry :)


Hi, how did you fixed it?
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: alex_time on April 17, 2009, 02:01:51 PM
Quote from: nadir;18448
Hi, how did you fixed it?


I too would like to know how Unatine has solved the problem with the lastest 0.2.1 version.

Furthermore, I have another, maybe Bigger problem. My mail server is not on the same machine roundcube run, so the Mysql database is not on local host but on the mail server. There is a way to manually specify the host where vpopmail database is, before open the connection to the mysql server?
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: demomm on April 22, 2009, 06:49:04 AM
Quote from: nadir;18448
Hi, how did you fixed it?


I too would like to know how Unatine has solved the problem with the lastest 0.2.1 version.

I have the same problem :(
Anybody help me??

Thx.
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: xoma on April 23, 2009, 08:53:39 AM
try add file roundcube/skins/default/includes/settingscripts.html
Code: [Select]
<script type=&quot;text/javascript&quot;>

if (window.rcmail && rcmail.env.action)
  {
  var action = rcmail.env.action=='preferences' ? 'default' : (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action);
  var tab = document.getElementById('settingstab'+action);
  }
else
  var tab = document.getElementById('settingstabdefault');

if (tab)
  tab.className = 'tablink-selected';

</script>
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: EugeneXXX on April 26, 2009, 09:07:26 AM
Quote from: xoma;18648
try add file roundcube/skins/default/includes/settingscripts.html
Code: [Select]
<script type=&quot;text/javascript&quot;>

if (window.rcmail && rcmail.env.action)
  {
  var action = rcmail.env.action=='preferences' ? 'default' : (rcmail.env.action.indexOf('identity')>0 ? 'identities' : rcmail.env.action);
  var tab = document.getElementById('settingstab'+action);
  }
else
  var tab = document.getElementById('settingstabdefault');

if (tab)
  tab.className = 'tablink-selected';

</script>


Doesn't work.
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: DJManas on April 26, 2009, 12:50:16 PM
Quote from: fritz001;17270
It seems there is a problem patching latest myroundcube !!

patch -p1 patching file index.php
Hunk #1 succeeded at 293 (offset 100 lines).
patching file program/js/app.js
Hunk #1 FAILED at 235.
Hunk #2 FAILED at 904.
2 out of 2 hunks FAILED -- saving rejects to file program/js/app.js.rej
patching file program/localization/en_GB/labels.inc
patching file program/localization/en_GB/messages.inc
patching file program/localization/en_US/labels.inc
patching file program/localization/en_US/messages.inc
patching file program/steps/settings/password.inc
patching file skins/default/includes/settingstabs.html
patching file skins/default/templates/password.html


Same problem for me. Roundcube version roundcubemail-0.2.1 how to solve this problem? All files are fresh.
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: EugeneXXX on April 27, 2009, 01:29:47 AM
Quote from: DJManas;18709
Same problem for me. Roundcube version roundcubemail-0.2.1 how to solve this problem? All files are fresh.


Replace a file app.js with my file
Title: find a bug
Post by: sport on May 30, 2009, 11:05:53 AM
Hi,

I've placed my roundcube installation with vpopmail and mysql.

The change password plugin works very well, but it has a problem with the domain with a " - " in the middle

Ex: user@some-domain.ext

I've make my solution to correct this bug

This in my code to replace in password.inc file


$dom_table_1 = str_replace(".","_",$domain[1]);
        $dom_table_2 = str_replace("-","_",$dom_table_1);

        // ONLY CHANGE YOUR vpopmail DATABASE NAME !!!!!

        $passwordquery = "UPDATE vpopmail.$dom_table_2 SET pw_passwd = '$crypted',pw_clear_passwd='".$new_password."' WHERE pw_name = '$domain[0]';";


Bye bye :)
Title: for new release v0.2.2
Post by: nadir on June 03, 2009, 04:07:46 AM
Hi. can anybody help me? have the password change patch for new release?
old patch not works.
Why roundcube does not add this function to the project? :confused:
Title: patch for new release
Post by: nadir on June 12, 2009, 04:22:19 AM
Hi, somebody can help me fix problem with roundcube v0.2.2? :( current password change patch not works on this version. :mad: when i click to password tab, i see blank page. i tried fix this but i see that app.js and other js files changed.
Title: Help me.....
Post by: aalovesiti on June 15, 2009, 07:30:40 PM
what sql command to give permissions roundcube users to update vpopmail database. this is my database name
vpopmail databases name: vpopmail
vpopmail username : vopmailuser
roundcube databases name : roundcubemail
roundcube username : roundcubemail

are corect or not ?
        // ONLY CHANGE YOUR vpopmail DATABASE NAME !!!!!
$passwordquery = "UPDATE vpopmail.vpopmail SET pw_passwd = '$crypted',pw_clear_passwd='".$new_password."' WHERE pw_name = '".$emailuser."';";


Thanks
Title: help
Post by: nadir on July 06, 2009, 02:38:00 AM
this version of patch not works with roundcube version 0.2.2
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: siodseraph on July 10, 2009, 05:44:40 PM
Excellent - this is what I was looking for. It doesn't work with the SVN version of roundcube though. Which is not a big deal but it kinda raises the question: Would it be possible to get this plugin to work with the new Plugin API? Kinda like create a new tab in the Personal Settings menu called Password and let the Plugin API handle it?

Just an idea, great work on this, makes the whole application much more useful for us.
Title: Two different servers
Post by: drzymalski on August 26, 2009, 06:03:43 PM
I have two different servers. A html server hosting roundcubemail, and a mail server. I have the roundcubemail database on the webserver.

How do i change the password inc to access the sql database on the mail server?
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: Termi on September 28, 2009, 08:37:37 AM
Quote from: siodseraph;20019
Would it be possible to get this plugin to work with the new Plugin API? Kinda like create a new tab in the Personal Settings menu called Password and let the Plugin API handle it?

Just an idea, great work on this, makes the whole application much more useful for us.


There is already a qmail plugin for the RC0.3 plugin api which works like described (adding a password tab in prefs). Would be a good idea to extend this.

By the way: There is a qmail web interface for changing a users pw. I'd love to use this so if someone would extend the plugin api i'd really appreciate it :-)
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: jingo on December 04, 2009, 01:16:45 PM
Changing password using vpopmail can be done through the vpopmaild daemon.

I already made the driver, and it is committed in roundcube, see
http://www.roundcubeforum.net/api-based-plugins/5378-new-password-plugin-driver-vpopmaild.html
Title: Qmail web interface driver for password plugin problems
Post by: Termi on December 22, 2009, 06:24:32 PM
I don't know which mailer my isp is using but I asked for any support for users to change their passwords and my isp answered the only way would be their qmail web interface.

Thus I'm looking for a driver for the password plugin which simply sends a post with the three 4 needed entries (old pw) to that form and parses the error message or success message.

My ISPs password change form is located at
https://mail.bytecamp.net/cgi-bin/qmailadmin/qmailadmin/passwd/

The form fields are:

address -> e.g. "someone@somedomain.com"
oldpass
newpass1
newpass2

When posting these fields one gets an answer page which should be parsed.

I tried to change the direct admin parser which seemed appropriate for that task but it didn't work. Here comes the changed code (communication class code afterwards not changed):

Code: [Select]
function password_save($curpass, $passwd){

    $rcmail = rcmail::get_instance();
    $Socket = new HTTPSocket;

    $da_user    = $_SESSION['username'];
    $da_curpass = $curpass;
    $da_newpass = $passwd;
    $da_host    = $rcmail->config->get('password_directadmin_host');
    $da_port    = $rcmail->config->get('password_directadmin_port');

    $Socket->connect($da_host,$da_port);
    $Socket->set_method('POST');
    $Socket->query('/cgi-bin/qmailadmin/qmailadmin/passwd/',
        array(
            'address' => $da_user,
            'oldpass' => $da_curpass,
            'newpass1' => $da_newpass,
            'newpass2' => $da_newpass
    ));
    $response = $Socket->fetch_parsed_body();

//console(&quot;DA error response: $response[text] [$da_user]&quot;);
    if($Socket->result_status_code <> 200)
        return PASSWORD_CONNECT_ERROR;
    elseif($response['error'] == 1){ //Error description: $response[text]
        return PASSWORD_ERROR;
    }else
        return PASSWORD_SUCCESS;

}


I renamed the file to qmail.php and set the needed vars $da_host,$da_port in the config.inc.php within password directory.

Any ideas how I could get this to work? Thanks in advance...

Ingo
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: SKaero on December 23, 2009, 06:44:35 AM
Why not include it in a iframe?
Title: New File Added: Qmail+Mysql+Vpopmail Password Change Patch v1.0
Post by: Termi on December 24, 2009, 06:45:12 PM
Hi skaero,

Sorry but I don't get your point. I want to access my webhoster's qmail web interface via roundcube password plugin and just have to send a query via POST or GET and parse the result.

Do you mean I should show my webhosters qmail password change form in an iframe within roundcubemail? This wouldn't look nice and fit the look and feel of my skin.

I just don't know why it doesn't work :-(