,[+ d Z ddlZddlZddlmZmZmZmZ ddlm Z ddl
mZ dZdee
eeeeeef f f fdZd edeeeef fd
ZdS )zv
common helper functions, related to processing api using custom binary
currently available for Directadmin and Plesk
N)ListTupleUnionOptional)exec_utility)ClPwdz#/usr/share/python-cllib/userdomainsreturnc t t g \ } } t j | }| dk r| d |D fS n# t j $ r Y nw xY w| |fS )a
Calls USERDOMAINS(userdomains.c) bin and returns rc and loaded json output
This is equals to call `userdomains(pwd.getpwuid(os.getuid()).pw_name, as_root=True)`
Returns: return code of USERDOMAINS and json output
if rc == 0: `out` is out from `userdomains()`
NB: there is no tuples in JSON so da_out's type is List[List[str, str]] instead of List[Tuple[str, str]]
if rc != 0: `out` type is str
error codes:
1: diradmin/psaadmin user not found
2: not DA/Plesk panel
3: seteuid() syscall failed
4: executed as root
10: exception during `userdomains()` call
11: no such user in panel
r c g | ]>}t | d k t d |D .|d |d f?S ) c 3 @ K | ]}t |t V d S )N)
isinstancestr).0ps /builddir/build/BUILDROOT/alt-python27-cllib-3.4.36-1.el9.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/cpapi/cpapicustombin.py