Can not edit package via api if it not begins with root_ in name

amaurigabriel

Registered
Jun 15, 2020
2
0
1
Brazil
cPanel Access Level
Root Administrator
Hi,

I have root access to my server, and I want to edit packages using the WHM API, but I am having the error “_modpkg” require a package name that you have permission to access.

If the package_name starts with root_ I am allowed to edit it; also, if I create a package using api, it starts with root_ in the name.

The issue is that I already have several packages created using the whm panel (non-api) which didn't start with root_ in the name. Shouldn't I be able to edit these packages with a api token too?

Thank you.
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,274
1,291
313
Houston
To confirm you're using WHM API 1 Functions - editpkg - Developer Documentation - cPanel Documentation

And what are the parameters you're using exactly? I tested this on my own server and I'm not seeing any issues

Code:
[[email protected] packages]# whmapi1 editpkg name=cptest_usercreatedpackage featurelist=default quota=10240 language=en max_emailacct_quota=1024 maxftp=unlimited maxsql=unlimited maxpop=unlimited maxlists=unlimited maxsub=5 maxpark=5 maxaddon=5
---
data:
  pkg: cptest_usercreatedpackage
metadata:
  command: editpkg
  reason: OK
  result: 1
  version: 1
I created this package with my reseller account, within WHM, then logged in through terminal and ran the command line function.

I'm also unable to replicate package addition automatically appending root to the package:

Code:
[[email protected] packages]# whmapi1 addpkg name=package1234 featurelist=default quota=unlimited
---
data:
  pkg: package1234
metadata:
  command: addpkg
  reason: OK
  result: 1
  version: 1
Code:
[[email protected] packages]# ls -lah /var/cpanel/packages/package1234
-rw-r--r-- 1 root root 355 Jun 16 14:19 /var/cpanel/packages/package1234
 

amaurigabriel

Registered
Jun 15, 2020
2
0
1
Brazil
cPanel Access Level
Root Administrator
Hi,

I am using WHM api. If I run whmapi1 using the terminal, I can edit any package that I want. But I am using the API via CURL, and if I create a package with my token, it get prepended with "root" in the name automatically. Also, if I try to edit any package that not begins with "root_" I got the previous error. If I try to edit it any package that starts with "root_" it works fine.

A minimalist example is:
Bash:
curl -XGET -H 'Authorization: whm root:MYTOKEN' -d 'name=TESTE' 'https://myserver:2087/json-api/editpkg'
It will return the previous error.

If I run
Bash:
curl -XGET -H 'Authorization: whm root:MYTOKEN' -d 'name=TESTE' 'https://myserver:2087/json-api/addpkg'
then the package root_TESTE is created.
 
Last edited: