WHM API1 Account password change fails

welcho

Member
Feb 7, 2007
10
0
151
cPanel Access Level
Root Administrator
Hi,

I am trying to chenge a cPanel account password using the WHM API command "passwd" described here; Update cPanel account password

Autenticated with API Token as described here: API Tokens in WHM

This are the relevant parts of my code:

-------------------------------------------------
#/usr/bin/perl

use strict;
use warnings;
use LWP::UserAgent;
use LWP::Protocol::https;

my $ua = LWP::UserAgent->new(timeout => 30, ssl_opts => { verify_hostname => 0, SSL_verify_mode => 'SSL_VERIFY_NONE', SSL_use_cert => 0 });
my $req= HTTP::Request->new(
'GET'
, '<HOST_URL>:2087/json-api/passwd?api.version=1&password=<NEW_PASSWORD>&user=<ACCOUNT_USER_NAME>&db_pass_update=>0&enabledigest=0'
, [
Authorization => 'whm root:<WHM_API_TOKEN>'
, 'Accept-Encoding' => 'gzip, deflate'
]
);

my $RES = my $ua->request($req)

my $STR = $RES->decoded_content;
---------------------------------------------

When run i receive the server response:

---------------------------------------------

{"data":{"app":["system","ftp","mail","postgresql"]},"metadata":{"command":"passwd","reason":"Password changed for user “<ACCOUNT_USER_NAME>”.","output":{"raw":"Password for “<ACCOUNT_USER_NAME>” has been changed.FTP (File Transfer Protocol) password change has been queued.\n"},"result":1,"version":1}}

---------------------------------------------

But the new password don't work, i can't loggin to the account.


I apprecaite help.

Welcho
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,188
2,415
363
cPanel Access Level
Root Administrator
Hey there! I'm wondering if the server's task queue isn't processing quickly enough and leading to a delay in the FTP password change. If you check WHM >> Task Queue Monitor do you see processing lingering there?

If not, does running /scripts/ftpupdate get the password working after you run that command?
 

welcho

Member
Feb 7, 2007
10
0
151
cPanel Access Level
Root Administrator
Hi cPRex, thanks for your reply.

When run API, in the Task Queue monitor i only see this two tasks:


1685126698963.png

But they disappear a few seconds after. I belive the number 2 is ftpupdate.

Welcho
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,188
2,415
363
cPanel Access Level
Root Administrator
So even after the ftpupdate command runs, the password still doesn't work when you try and log in as the user? If that's the case, could you submit at ticket to our team so we can test this on your machine? I'm not seeing any obvious failures that would indicate why this isn't working.
 

welcho

Member
Feb 7, 2007
10
0
151
cPanel Access Level
Root Administrator
So even after the ftpupdate command runs, the password still doesn't work when you try and log in as the user? If that's the case, could you submit at ticket to our team so we can test this on your machine? I'm not seeing any obvious failures that would indicate why this isn't working.
I will send a submit the support ticket.
 

welcho

Member
Feb 7, 2007
10
0
151
cPanel Access Level
Root Administrator
I found the problem... URL encoding for the sent parameters solve the problem.

The only thing I think is bad is that de response was a confirmation of change when it was not.