Author Topic: Password plugin problem! chpasswd...  (Read 19301 times)

Offline sneiks

  • Newbie
  • *
  • Posts: 2
Password plugin problem! chpasswd...
« on: September 09, 2010, 11:26:53 AM »
Hi all i really need help! System Linux Fedora 9 with sendmail + Dovecot IMAP/POP3 Server all users local... so i think only way is chpasswd Driver... when i press save i get message that i cant save new password, in logs i got error:

[09-Sep-2010 11:20:50 +0300]: PHP ErrorPassword pluginUnable to execute echo 'xoxma:123456' sudo /usr/sbin/chpasswd 2> /dev/null; echo $? in /usr/share/roundcubemail/plugins/password/drivers/chpasswd.php on line 0 (POST /mail/?_task=settings&_action=plugin.password-save?_task=&_action=)

how to fix it and where is a problem??? :( maybe you could give advice to try another password driver....???

I found one fix but it didnt help me...

UpdateI have the chpasswd driver working with 0.4-beta on Fedora 11 with ApacheMy users are local users.

Here's how I got it to work:

1: enable the "password" plugin that comes with roundcube.
2: set it to use the chpasswd driver
3: type visudo
4: Add the following lines in this order(replace "apache" with the account that your apache install runs under and make sure you have the correct path to the chpasswd program):

Defaults:apache !requiretty
apache ALL=NOPASSWD: /usr/sbin/chpasswd
« Last Edit: September 09, 2010, 11:30:10 AM by sneiks »

Offline sneiks

  • Newbie
  • *
  • Posts: 2
Password plugin problem! chpasswd...
« Reply #1 on: September 12, 2010, 03:21:07 AM »
No ONE can help??? i could pay some $ for help!!! :(

Offline sengst

  • Newbie
  • *
  • Posts: 1
Password plugin problem! chpasswd...
« Reply #2 on: September 14, 2010, 07:50:54 AM »
Same problem here!
Any help would be appreciated!

Offline TopQuark

  • Newbie
  • *
  • Posts: 7
Password plugin problem! chpasswd...
« Reply #3 on: September 18, 2010, 04:54:00 PM »
+1

Same problem here.  It look like a permissions error but I, too, cannot figure out which file and setting.

Offline edkedk

  • Newbie
  • *
  • Posts: 3
Password plugin problem! chpasswd...
« Reply #4 on: March 16, 2011, 05:27:21 AM »
Hello all,

I had the same problem here. I want to setup chpasswd to change linux system password with the 'chpasswd' driver.
Now after my own changes to the chpasswd.php file, I got it working !!

Here is the solution. The lines of php code UNDER the comment '// REMOVED' are the original, I have outcomment the to keep the original in the php file just in case.
The codeline under the line with comment '// FIX...' is the replacement for the original line.

What I did was in the first place, reconstruct what should be happening when executing the change password command on the system. As root:

#echo "test:111" | chpasswd

where test is my mail user and 111 is the new password for this mail user.
In the driver php file ('chpasswd.php' in the plugins/password/driver folder) the change password function is opening a pipe and then the user's name and new password are written to this opened pipe. Unfortunately this is not working the way it should, and I can not figure out why yet. But my fix make the password plugin with chpasswd as driver working.

In this scenario, you also have to config the /etc/sudoers file, so the user your webserver runs under (and therefore roundcube), can execute the chpasswd binary on your system as root. I use Debian lenny over here, and my /etc/sudoers line looks like this:

www-data ALL=NOPASSWD: /usr/sbin/chpasswd


HERE IS THE SOLUTION
for chpasswd.php file (in the plugins/password/drivers folder):
------------------------------------------------------------------

function password_save($currpass, $newpass)
{
    $username = $_SESSION['username'];
// REMOVED (ORIGINAL LINE):
// $cmd = rcmail::get_instance()->config->get('password_chpasswd_cmd');
// FIX:
$cmd = "echo '".$username.":".$newpass."' |"  . rcmail::get_instance()->config->get('password_chpasswd_cmd');

    $handle = popen($cmd, "w");
// REMOVED (ORIGINAL LINE):
//    fwrite($handle, "$username:$newpass");
// FIX:
    fwrite($handle, "");[/SIZE]

-----------------------------------------------------
Other lines of code do not have to be altered.


Any feedback if it helped will be appreciated !
Cheers,
Erik de Keijzer
The Netherlands
« Last Edit: March 16, 2011, 05:34:56 AM by edkedk »

Offline edkedk

  • Newbie
  • *
  • Posts: 3
Password plugin problem! chpasswd...
« Reply #5 on: March 17, 2011, 10:38:23 AM »
UPDATE:

Tpday I tried the new 0.5.1 version of Roundcube, and the password plugin in this version is working 100%. So my modification in the driver source is not necessary.

Greetings,
Erik

Offline dbyte

  • Newbie
  • *
  • Posts: 9
problem with chpasswd script
« Reply #6 on: January 29, 2012, 01:40:05 PM »
Ok, I just found an issue with the chpasswd script.

If your roundcube configuration is setup to use %u but they login with the @domainname, the session(username) is apparently causing the chpasswd script to try and use chpasswd user@domain.com instead of chpasswd user.

Can someone help with a quick fix?

I am on ver .7.1

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Password plugin problem! chpasswd...
« Reply #7 on: January 29, 2012, 01:53:37 PM »
Just a quick guess off the top of my head (un tested) but how about changing the line:
Code: [Select]
$username = $_SESSION['username'];To:
Code: [Select]
$username = explode('@', $_SESSION['username']);And then change the line:
Code: [Select]
$cmd = "echo '".$username.":".$newpass."' |" . rcmail::get_instance()->config->get('password_chpasswd_cmd');To:
Code: [Select]
$cmd = "echo '".$username[0].":".$newpass."' |" . rcmail::get_instance()->config->get('password_chpasswd_cmd');

Offline dbyte

  • Newbie
  • *
  • Posts: 9
Password plugin problem! chpasswd...
« Reply #8 on: January 29, 2012, 02:05:42 PM »
That did it, Thank You!

Offline insert

  • Newbie
  • *
  • Posts: 1
Re: Password plugin problem! chpasswd...
« Reply #9 on: September 05, 2012, 11:39:25 AM »
Hi edkedk,
I tried your solution for my server based on CentOS 6, but the chpasswd driver still not works...

Test echo... from root is ok.

In the /etc/sudoers file I wrote:
apache ALL=NOPASSWD: /usr/sbin/chpasswd

I changed lines in the chpasswd.php how you have posted.

Have you some ideas?

Offline SebOOl84

  • Newbie
  • *
  • Posts: 1
Re: Password plugin problem! chpasswd...
« Reply #10 on: August 07, 2014, 07:29:45 AM »
Hi all/
In CentOS SELinux is the problem. It is a violation of SELinux policy to write in /etc by http_t security context. This module needs to do that.
You can try to make a policy or disable SELinux (I'm not a fan of that).