Roundcube Change-password plugin

31 posts / 0 new
Last post
#1 Sun, 09/04/2011 - 06:20
Marked

Roundcube Change-password plugin

Hi,

I've got an 'out-of-the-box' installation of VirtualMin on Ubuntu 10.4 and have installed the latest Roundcube (version .5.3) and all is working well except for the Change-password plugin. The form-page for changing the password shows up okay, but each time I attempt to change the password I get a message "Password could not be changed".

In the config.inc.php file I've set it to:

$rcmail_config['password_driver'] = 'virtualmin';

... as the default is 'sql' and the mail is not using MySQL.

There seems to be a few methods of getting it to work described in a number of blogs and sites, but they seem to be about earlier versions. I've worked through a number of them but no luck.

Has anyone got any hints on getting this plugin to work?

Cheers, Mark.

Sun, 09/04/2011 - 09:32
andreychek

Howdy,

I don't have any experience with that particular plugin... but one thing you may want to check is the Apache error logs in $HOME/logs/error_log.

Try changing the password, then view the error log for any errors that may have shown up.

-Eric

Mon, 09/05/2011 - 06:49
Marked

Hi Eric,

The logfile is only showing a few errors for missing files (favicon.ico, robots.txt) - but nothing relating to roundcube or mail.

??

Mark

Sat, 10/01/2011 - 10:33
frnet

Hi,

I tried with different suggestions too, but finally this is what I do and it seems to work correctly:

  • edit your ./plugins/password/driver/virualmin.php
  • At line 22 afther $username = $_SESSION['username']; insert: $plugin = $rcmail->plugins->exec_hook('user2email', array('email' => NULL, 'user' => $username, 'first' => true, 'extended' => false)); $email = $plugin['email'][0]; $domain = substr(strrchr($email, "@"), 1);

  • comment the switch sentence because we have the user's domain.

In my system, I have users with serveral system names: user.domain, user-domain, user without domain, because these came from others systems. I prefer to obtain the domain from the postfix virtual table using the user2email function provided by virtusert_file plugin.

I hope this works for you. Regards.

Fri, 10/28/2011 - 15:04
agallo

Hi

I am having same issue. my users are this way: user.domain and tried every solution out there. Even hardcoding domain!!

But ends with: PHP Error, Password plugin: Unable to execute How can I fix it? Or, Is there a way to store mail's password in the database where users are stored?

Regards

Andres

Wed, 12/14/2011 - 08:03
jonkristian

Howdy, I tried exactly the same, and it is working when running from console, however on my system the binary turns out red after changing the permissions. I am running on CentOS.

@frnet: What exactly did you do to set correct permission on that file?

Could this be because of suexec?

Wed, 12/14/2011 - 08:25
andreychek

Howdy,

It's unlikely to be a suexec problem, since suexec doesn't directly run the PHP files, it instead executes the php5.cgi file in fcgi-bin or cgi-bin.

However, you would want to make sure that the plugin file is owned by your Virtual Server owner, and that the permissions on it are "755".

-Eric

Thu, 12/15/2011 - 06:54
jonkristian

I tried, still get:

[15-Dec-2011 13:46:39 +0100]: PHP Error: Password plugin: Unable to execute /home/divint/domains/sjekkepost.no/public_html/plugins/password/drivers/chgvirtualminpasswd in /home/divint/domains/sjekkepost.no/public_html/plugins/password/drivers/virtualmin.php on line 67 (POST /?_task=settings&_action=plugin.password-save?_task=&_action=)

I think this script is supposed to run as root, not sure why though.

// set the UID this script will run as (root user)
#define UID 0
#define CMD "/usr/sbin/virtualmin"

/* INSTALLING:
  gcc -o chgvirtualminpasswd chgvirtualminpasswd.c
  chown root.apache chgvirtualminpasswd
  strip chgvirtualminpasswd
  chmod 4550 chgvirtualminpasswd
*/
Thu, 12/15/2011 - 08:00
andreychek

Ah, so the password changing doesn't occur from within the PHP script, it calls out to a custom program for that.

So if you type this command, what output do you get:

ls -l /home/divint/domains/sjekkepost.no/public_html/plugins/password/drivers/chgvirtualminpasswd

Thu, 12/15/2011 - 10:39
jonkristian

Yes, there's a binary.

-rwxr-xr-x 1 divint divint 3420 Dec 14 14:36 /home/divint/domains/sjekkepost.no/public_html/plugins/password/drivers/chgvirtualminpasswd

This is the binary:

#include <stdio.h>
#include <unistd.h>

// set the UID this script will run as (root user)
#define UID 0
#define CMD "/usr/sbin/virtualmin"

/* INSTALLING:
  gcc -o chgvirtualminpasswd chgvirtualminpasswd.c
  chown root.apache chgvirtualminpasswd
  strip chgvirtualminpasswd
  chmod 4550 chgvirtualminpasswd
*/

main(int argc, char *argv[])
{
  int rc,cc;

  cc = setuid(UID);
  rc = execvp(CMD, argv);
  if ((rc != 0) || (cc != 0))
  {
    fprintf(stderr, "__ %s:  failed %d  %d\n", argv[0], rc, cc);
    return 1;
  }

  return 0;
}
Thu, 12/15/2011 - 11:05
andreychek

What instructions did you use for installing that particular module?

It doesn't seem to have the permissions that it would need (the instructions I see in the module source should provide that).

-Eric

Thu, 12/15/2011 - 11:17
jonkristian

The instructions in my post above were the only instructions apart from going trough the configuration. I followed the instructions but when they did not work (permission error), I tried to chown site user and group instead.

Thu, 12/15/2011 - 12:49
andreychek

Well, in the source code of the program you posted is the following comments:

/* INSTALLING:
  gcc -o chgvirtualminpasswd chgvirtualminpasswd.c
  chown root.apache chgvirtualminpasswd
  strip chgvirtualminpasswd
  chmod 4550 chgvirtualminpasswd
*/

Did you by chance run both the chown and the chmod commands?

While I'm not familiar with this plugin, it appears as if it's calling the "/usr/sbin/virtualmin" command line tool in order to change the user's password. It would indeed need to run as root in order for that to work, and you'd have to run both that chown and chmod command in order to run as root.

-Eric

Fri, 12/16/2011 - 04:31
jonkristian

Yes i did and it didn't work either:/ ls -l shows that the file in question is red, not sure exactly what it means on CentOS but I have a pretty good idea.

Fri, 12/16/2011 - 07:52
andreychek

The "ls -l" command you showed isn't showing that the chown and chmod commands worked correct then.

You may want to try running these again:

chown root.apache /home/divint/domains/sjekkepost.no/public_html/plugins/password/drivers/chgvirtualminpasswd
chmod 4550 /home/divint/domains/sjekkepost.no/public_html/plugins/password/drivers/chgvirtualminpasswd
Fri, 12/16/2011 - 14:30
jonkristian

That's true, because that was after trying ownership of site user/group..

This is after following the readme:

-r-sr-x--- 1 root   apache  3420 Dec 14 14:36 chgvirtualminpasswd
Fri, 12/16/2011 - 15:20
andreychek

Great! So is that plugin working for you now?

-Eric

Fri, 12/16/2011 - 16:34
jonkristian

No it's not, that's the problem:( I still get the error message.

Tue, 12/20/2011 - 09:18
taigher

Hello,

I am new user of Virtualmin and it's unclear for me how to execute this script, where to setup UID and define CMD in Virtualmin?

#include
#include

// set the UID this script will run as (root user)
#define UID 0
#define CMD "/usr/sbin/virtualmin"

/* INSTALLING:
gcc -o chgvirtualminpasswd chgvirtualminpasswd.c
chown root.apache chgvirtualminpasswd
strip chgvirtualminpasswd
chmod 4550 chgvirtualminpasswd
*/

main(int argc, char *argv[])
{
int rc,cc;

cc = setuid(UID);
rc = execvp(CMD, argv);
if ((rc != 0) || (cc != 0))
{
fprintf(stderr, "__ %s: failed %d %d\n", argv[0], rc, cc);
return 1;
}

return 0;
}

Regards,
Maciek

Tue, 12/20/2011 - 13:03
jonkristian

You don't, it's already there. just follow the instructions below INSTALLING: and good luck, I could not get it working using CentOS at least, virtualmin command line require root perms, somehow my system won't allow to run this...

Wed, 12/21/2011 - 03:14
taigher

Ok, but it's still unclear. I can't recognize the right place to install this script - as I suppose I need to run the shell and what else... to go to script directory? another place? maybe someone could show me the way step by step? I use CentOS also. If there are problems in CentOS, maybe should be better to change the system to Debian?

Mat

Wed, 12/21/2011 - 06:14
jonkristian

The virtualmin.php runs the binary which changes pw.

Follow the steps in the binary, then configure virtualmin in config.inc.php , a new password option will appear in settings of roundcube.

Sat, 01/14/2012 - 10:58
euzentay

Hi,

I follow the roundcube/plugins/password README file to change the setting and drivers chgvirtualminpasswd remind setting

/* INSTALLING: gcc -o chgvirtualminpasswd chgvirtualminpasswd.c chown root.apache chgvirtualminpasswd strip chgvirtualminpasswd chmod 4550 chgvirtualminpasswd */

but when roundcube change the password it come out the error "Could not save new password."

log file sh: /home/lblgh/public_html/roundcube/plugins/password/drivers/chgvirtualminpasswd: Permission denied

when change chmod 777 chgvirtualminpasswd, also get a some problems may I know got other thing need to change it? I install it by new function install script.

any other ppl solve this problems???

Mon, 06/25/2012 - 15:52
rogeriobrito

Hello guys,

I got it working. It is a permssion problem. If you are running PHP with FCGId mode, the domain owner user runs PHP, no apache. So, I've change the user group on the installation script, the chown line, like this:

/* INSTALLING:
  gcc -o chgvirtualminpasswd chgvirtualminpasswd.c
  chown root.<domain owner user> chgvirtualminpasswd
  strip chgvirtualminpasswd
  chmod 4550 chgvirtualminpasswd
*/

It works.

Cheers,

. Rogerio

Tue, 08/07/2012 - 06:15 (Reply to #24)
adrianmak

I just came across this issue. What is the domain own user referring to ?

Tue, 08/07/2012 - 10:42
rogeriobrito

Hello,

You can check the domain user on Virtualmin->Edit Virtual Server.

The domain user is the "Administration Username" on Vitual Server Details.

Rogerio

Tue, 08/07/2012 - 19:20
adrianmak

I have another findings regarding fail to change password using virtualmin drivers

http://www.virtualmin.com/node/23015

Tue, 09/18/2012 - 15:11
any-it

Hi Guys,

i'm stuck with the same problem here. i tried permission change to domain owner as suggested above, but no luck. strange thing is, that even when i rename the chgvirtualminpasswd file, the error message stays the same, so it seems that php is not even touching the file?

i've read some posts about exec rights and requiretty, but those settings are correct as well.

does anyone have a final solution for this?

i'm running on centos 6.2

many thanks in advance! Niels

Thu, 09/20/2012 - 19:59
andreychek

I looked into this a bit, and was able to get it working using the current RoundCube version (0.8.1), which is provided as a Virtual Install Script -- but I had to make one tweak.

It appears that there is a PHP syntax error in this file:

roundcube/plugins/password/drivers/virtualmin.php

You'll see these lines near line 54:

        case 7: // domain_username
            $pieces = explode("_", $username);
            $domain = $pieces[0];
            break;
                case 8: // domain taken from alias, username left as it was
                        $email = $rcmail->user->data['alias'];
                        $domain = substr(strrchr($email, "@"), 1);
                        break
        default: // username@domain

The problem is that second-to-last line, where it says "break".

There needs to be a semi-colon after that line. It should read "break;". Or, the entire code block would look like this:

        case 7: // domain_username
            $pieces = explode("_", $username);
            $domain = $pieces[0];
            break;
                case 8: // domain taken from alias, username left as it was
                        $email = $rcmail->user->data['alias'];
                        $domain = substr(strrchr($email, "@"), 1);
                        break;
        default: // username@domain

The only change I needed to make was just adding the ; character to that one line.

Let us know if that works for you!

Fri, 09/21/2012 - 16:00
andreychek

I wrote up more complete instructions available in the forum post here:

http://www.virtualmin.com/node/23427

Thu, 04/18/2013 - 22:42
karlos.vanger

Hi Guys,

I was able solve this issue by changing the group in to apache. My setup is Nginx+php-FPM. The php-FPM is running as apache user. So I changed the ownership as chown root.apache chgvirtualminpasswd

Thanks, Karlos

Topic locked