parking and unparking domains - API function

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
I see in the latest API docs a function to park a domain called "create_parked_domain_for_user".
However, I don't see an obvious counterpart to "unpark domain for user".
I do see "delete_domain", but it doesn't mention the terms "unparking" anywhere in the docs for that function.

I tried running "delete_domain" where I previously (successfully) ran:
/json-api/cpanel?user=$user&cpanel_jsonapi_module=Park&cpanel_jsonapi_func=unpark&cpanel_jsonapi_version=2&domain=$unparkdomain

but it returned the error: Permission denied: You do not have the required privileges to run "delete_domain", which was surprising as I authenticate the call using the same credentials for the reseller account (the reseller for the account where the domain is parked).

I'm trying to determine if "delete_domain" is the correct function to unpark a parked domain or if there is a better one.
If it is the proper function to unpark a domain, why would the same credentials that worked with the old unpark function not work with this one? What additional privileges are needed for the new function?

Thanks!
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
Hey hey! As a test, I created a parked domain with this command:

Code:
whmapi1 create_parked_domain_for_user domain='testpark.domain.com' username='username' web_vhost_domain='domain.com'
After doing that, I didn't have any trouble using the delete_domain call to remove that:

Code:
[root@host /]# whmapi1 delete_domain domain='testpark.domain.com'
---
data:
  type: parked
  username: username
metadata:
  command: delete_domain
  reason: OK
  result: 1
  version: 1
so maybe it was something with the authentication string in the json formatted call?
 

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
Thanks for testing that. Were you logged in as root for your test?

The only reason I'm doubting the auth strings is that the code has been working for years and I only substituted the URL for the new API call with the proper domain (validated at runtime that the URL and domain specified are proper). The authentication credentials are not part of that URL; I pass them first using Perl:

Code:
$request->authorization_basic($user, $pass);
then the API URL is sent via a GET.

So the auth process is the same as it was under the old API call which worked which confuses me.

I'll keep investigating...
 

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
I can execute the WHMAPI1 command from a Putty shell as you did and call delete_domain successfully. However, I was logged in as root during this test. I tried logging into SSH using my reseller account, but when I issued the same WHMAPI1 command, it returned a long set of errors, including the usage of the command, as well as "This program can only be run by root!"
 

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
I have confirmed that if my Perl script uses "root" user and password, the delete_domain succeeds in deleting the specified subdomain. Using the reseller user and password worked in the same script using the old Park::unpark function. Does delete_domain really require root priviliges, and if so, is there some other way to remove a parked domain that doesn't?
 

swbrains

Well-Known Member
Sep 13, 2006
306
45
178
Thanks. Yes - I was using that Park::unpark function previously.

I'm currently going through all of our code trying to eliminate any functions that don't appear in the latest API docs, since I'm assuming if they aren't listed there that they are either being deprecated or likely to be deprecated in the near future, and I want our code to be on the latest API functions whenever possible to eliminate having to rewrite it later under a tighter timeframe (before the functions go away). :)

PS: Another suggestion to the doc group: It would be beneficial if the docs could clarify when any special privileges are required for a function; particularly if it requires root privileges.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator
As far as I know, anything in the cpanelapi section will not require root - only the whmapi tools do. Non-root items would be anything under this branch here: