Author Topic: Password plugin error (chpasswd)  (Read 10523 times)

Offline balbung

  • Newbie
  • *
  • Posts: 5
Password plugin error (chpasswd)
« on: April 03, 2012, 12:35:17 PM »
Hi friends,

I have a little problem with the password plugin. I see many people it is the same, i receive the error message "password could not be saved".  i´m  trying to do it with chpassword and in config.inc.php i have:
Code: [Select]
$rcmail_config['password_driver'] = 'chpasswd';
And in chpasswd.php:
Code: [Select]
function password_save($currpass, $newpass)
{
    $cmd = rcmail::get_instance()->config->get('password_chpasswd_cmd');
    $username = $_SESSION['username'];

    $handle = popen($cmd, "w");
    fwrite($handle, "$username:$newpass\n");

    if (pclose($handle) == 0) {
        return PASSWORD_SUCCESS;
    }
    else {
        raise_error(array(
            'code' => 600,
            'type' => 'php',
            'file' => __FILE__, 'line' => __LINE__,
            'message' => "Password plugin: Unable to execute $cmd"
            ), true, false);
    }

    return PASSWORD_ERROR;

I have checked the open tickets but i can´t find anything.

Anybody can help me?

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Password plugin error (chpasswd)
« Reply #1 on: April 04, 2012, 02:30:17 AM »
Whats in your error log?

Offline balbung

  • Newbie
  • *
  • Posts: 5
Re: Password plugin error (chpasswd)
« Reply #2 on: April 04, 2012, 04:22:12 AM »
Thanks for your reply!!!

I forgot the log  :-[

Code: [Select]
[04-Apr-2012 10:18:31 +0200]: PHP Error: Password plugin: Unable to execute sudo /usr/sbin/chpasswd 2> /dev/null in /var/www/html/webmail/plugins/password/drivers/chpasswd.php on line 30 (POST /webmail/?_task=settings&_action=plugin.password-save?_task=&_action=)
maybe I should mention that i´m working with Centos 5.7

Thanks in advance

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Password plugin error (chpasswd)
« Reply #3 on: April 04, 2012, 05:54:56 AM »
It looks like the user who runs the script (most likely apache) doesn't have the permissions to run the sudo command.

Offline balbung

  • Newbie
  • *
  • Posts: 5
Re: Password plugin error (chpasswd)
« Reply #4 on: April 04, 2012, 06:50:06 AM »
It could make sense, but i allow user apache to execute chpasswd but still doesn´t work. Still i have the same error message in log  :(
This is the way i do it:
I execute visudo and add the line
Code: [Select]
apache  ALL=NOPASSWD: /usr/sbin/chpasswdalso execute
Code: [Select]
usermod -s /bin/bash apache
Any ideas?

Thanks for everything

Offline balbung

  • Newbie
  • *
  • Posts: 5
Re: Password plugin error (chpasswd)
« Reply #5 on: April 04, 2012, 10:57:49 AM »
I just to saw another thing. I have logged into the bash with the apache user and wen i tried execute /usr/sbin/chpasswd i received the follow message:
chpasswd can't lock password file.

do not know if this error is related to what happens

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Password plugin error (chpasswd)
« Reply #6 on: April 04, 2012, 11:40:45 AM »
Not sure, has the error changed?

Offline balbung

  • Newbie
  • *
  • Posts: 5
Re: Password plugin error (chpasswd)
« Reply #7 on: April 04, 2012, 11:51:06 AM »
it hasn´t changed . Its the same error.....Unable to execute..... Also i gave root permisions to user apache in sudoers without success....

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: Password plugin error (chpasswd)
« Reply #8 on: April 04, 2012, 04:39:18 PM »
Hmm, maybe RoundCube isn't running under apache, how do you have the users setup on the system?

Offline bonowax

  • Newbie
  • *
  • Posts: 1
Re: Password plugin error (chpasswd)
« Reply #9 on: May 04, 2012, 08:50:01 AM »
Hello;

I just ran into this problem, and figured it out by looking at the Apache error log.

### log sample ###

sudo: sorry, you must have a tty to run sudo

### end log sample ###

What I needed was to edit sudoers and comment out the line which had 'requiretty'

I hope this helps.

Offline pjnb

  • Newbie
  • *
  • Posts: 2
Re: Password plugin error (chpasswd)
« Reply #10 on: January 14, 2015, 12:25:13 AM »
Solution:

modify sudoers, use visudo, only add:

apache ALL=NOPASSWD: /usr/sbin/chpasswd
Defaults:apache !requiretty

don't change any lines