Author Topic: cpanel password extension - no CPanel pw reqd  (Read 9804 times)

Offline nicholak

  • Newbie
  • *
  • Posts: 1
cpanel password extension - no CPanel pw reqd
« on: March 16, 2010, 10:23:39 AM »
I extended the password plugin to allow users to change their password without the need for the CPanel admininstrator credentials in the config file - didn't like that idea.

Here is the package containing 2 files: a new config default file, and a new driver file - just unpack into /plugins/password and then configure the "cpaneluserauth" parameters.

« Last Edit: March 16, 2010, 10:27:09 AM by nicholak »

Offline ElrondBCN

  • Newbie
  • *
  • Posts: 2
cpanel password extension - no CPanel pw reqd
« Reply #1 on: March 27, 2010, 02:12:43 PM »
This doesn't seem to work for me. I receive the error:
Could not save new password.

It does seem to properly check the existing password however.


Offline ElasticUser

  • Full Member
  • ***
  • Posts: 83
Re: cpanel password extension - no CPanel pw reqd
« Reply #3 on: December 07, 2017, 01:48:41 PM »
The default change password plugin doesn't seem to run properly with cPanel.  And the above cPanel password change like is no longer valid.  :--)

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: cpanel password extension - no CPanel pw reqd
« Reply #4 on: December 08, 2017, 07:49:55 AM »
The password plugin that comes with Roundcube should work fine with cPanel, the plugin that was talked about here most likely no longer works.

Offline ElasticUser

  • Full Member
  • ***
  • Posts: 83
Re: cpanel password extension - no CPanel pw reqd
« Reply #5 on: December 08, 2017, 12:51:37 PM »
When I test changing a password, it basically says unable to change password.  :--)

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: cpanel password extension - no CPanel pw reqd
« Reply #6 on: December 08, 2017, 02:42:07 PM »
Have you read the README file and configured it to work with your cpanel account?

Offline ElasticUser

  • Full Member
  • ***
  • Posts: 83
Re: cpanel password extension - no CPanel pw reqd
« Reply #7 on: December 13, 2017, 06:10:18 PM »
I added the below code and it said success when I tested changing a password, but when I logged out and back in, it only logs in with the original password;  Any suggestions?  :--)

// See README file for list of supported driver names.
$config['password_driver'] = 'chpasswd';
« Last Edit: December 13, 2017, 07:11:50 PM by ElasticUser »

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: cpanel password extension - no CPanel pw reqd
« Reply #8 on: December 13, 2017, 07:16:53 PM »
If your using cPanel the chpasswd driver wouldn't work.

Offline ElasticUser

  • Full Member
  • ***
  • Posts: 83
Re: cpanel password extension - no CPanel pw reqd
« Reply #9 on: December 13, 2017, 07:49:53 PM »
I also tested the below code, but nothing seemed to happen.

// See README file for list of supported driver names.
$config['password_driver'] = 'cpanel';

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: cpanel password extension - no CPanel pw reqd
« Reply #10 on: December 14, 2017, 12:10:14 AM »
You also need to read the section for the password driver your attempting to use, most require additional steps and configurations.

Offline ElasticUser

  • Full Member
  • ***
  • Posts: 83
Re: cpanel password extension - no CPanel pw reqd
« Reply #11 on: December 14, 2017, 06:23:41 PM »
Below is all the code that cpanel.php has.  I doesn't see to say to change any of it.  :--)

<?php

/**
 * cPanel Password Driver
 *
 * Driver that adds functionality to change the users cPanel password.
 * Originally written by Fulvio Venturelli <fulvio@venturelli.org>
 *
 * Completely rewritten using the cPanel API2 call Email::passwdpop
 * as opposed to the original coding against the UI, which is a fragile method that
 * makes the driver to always return a failure message for any language other than English
 * see http://trac.roundcube.net/ticket/1487015
 *
 * This driver has been tested with o2switch hosting and seems to work fine.
 *
 * @version 3.0
 * @author Christian Chech <christian@chech.fr>
 *
 * Copyright (C) 2005-2013, The Roundcube Dev Team
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

class rcube_cpanel_password
{
    public function save($curpas, $newpass)
    {
        require_once 'xmlapi.php';

        $rcmail = rcmail::get_instance();

        $this->cuser = $rcmail->config->get('password_cpanel_username');

        // Setup the xmlapi connection
        $this->xmlapi = new xmlapi($rcmail->config->get('password_cpanel_host'));
        $this->xmlapi->set_port($rcmail->config->get('password_cpanel_port'));
        $this->xmlapi->password_auth($this->cuser, $rcmail->config->get('password_cpanel_password'));
        $this->xmlapi->set_output('json');
        $this->xmlapi->set_debug(0);

        return $this->setPassword($_SESSION['username'], $newpass);
    }

    /**
     * Change email account password
     *
     * @param string $address  Email address/username
     * @param string $password Email account password
     *
     * @return int|array Operation status
     */
    function setPassword($address, $password)
    {
        if (strpos($address, '@')) {
            list($data['email'], $data['domain']) = explode('@', $address);
        }
        else {
            list($data['email'], $data['domain']) = array($address, '');
        }

        $data['password'] = $password;

        $query  = $this->xmlapi->api2_query($this->cuser, 'Email', 'passwdpop', $data);
        $query  = json_decode($query, true);
        $result = $query['cpanelresult']['data'][0];

        if ($result['result'] == 1) {
            return PASSWORD_SUCCESS;
        }

        if ($result['reason']) {
            return array(
                'code'    => PASSWORD_ERROR,
                'message' => $result['reason'],
            );
        }

        return PASSWORD_ERROR;
    }
}

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,876
    • SKaero - Custom Roundcube development
Re: cpanel password extension - no CPanel pw reqd
« Reply #12 on: December 14, 2017, 10:54:32 PM »
Its in the README file in the password plugin folder, there is a section for each password driver.

Offline ElasticUser

  • Full Member
  • ***
  • Posts: 83
Re: cpanel password extension - no CPanel pw reqd
« Reply #13 on: December 15, 2017, 05:11:05 PM »
I still don't appear to be cating on to all the README steps for the password plugin.  I might have a friend look at that.  :--)

Offline ElasticUser

  • Full Member
  • ***
  • Posts: 83
Re: cpanel password extension - no CPanel pw reqd
« Reply #14 on: December 21, 2017, 08:35:40 PM »
I techie friend of mine looked at the pw plugin, and it was also over his head.  :--)