Server IP : 66.29.132.122 / Your IP : 18.224.53.19 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/clcommon/public_hooks/bundle/directadmin/ |
Upload File : |
# -*- coding: utf-8 -*- # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT # import subprocess import logging from clcommon.public_hooks import ( POST_MODIFY_USER, POST_MODIFY_DOMAIN, POST_MODIFY_ADMIN, PRE_MODIFY_USER ) from clcommon.cpapi import cpinfo, is_admin from clcommon.utils import is_user_present ERR_NO_USER_FOUND = 'Unable to find system_user in hook env vars' logger = logging.getLogger(__name__) def domain_change_post(system_user, domain, new_domain): """ Triggered on domain rename in DA """ if system_user is None: logger.warning(ERR_NO_USER_FOUND) return 0 return subprocess.call([ POST_MODIFY_DOMAIN, 'modify', '--username', system_user, '--domain', domain, '--new-domain', new_domain, '--include-subdomains']) def user_create_post(system_user): """ Triggered after user/admin creation in directadmin """ if system_user is None: logger.warning(ERR_NO_USER_FOUND) return 0 exit_code = 0 owner = cpinfo(cpuser=system_user, keyls=('reseller', ))[0][0] exit_code += subprocess.call([ POST_MODIFY_USER, 'create', '--username', system_user, '--owner', owner]) if is_admin(system_user): exit_code += subprocess.call([ POST_MODIFY_ADMIN, 'create', '--name', system_user]) return exit_code def post_destroy_user(system_user, usertype): """ Triggered after user modification in DA. """ if system_user is None: logger.warning(ERR_NO_USER_FOUND) return 0 exit_code = subprocess.call([ POST_MODIFY_USER, 'delete', '--username', system_user]) if usertype == 'admin': exit_code += subprocess.call([ POST_MODIFY_ADMIN, 'delete', '--name', system_user]) return exit_code def user_destroy_pre(system_user, usertype): if system_user is None: logger.warning(ERR_NO_USER_FOUND) return 0 if not is_user_present(system_user): logger.warning('User %s does not present in the system, skip hook', system_user) return 0 return subprocess.call([ PRE_MODIFY_USER, 'delete', '--username', system_user]) # TODO: add if needed # if usertype == 'admin': # subprocess.call([ # PRE_MODIFY_ADMIN, 'delete', # '--name', system_user]) def user_restore_post(system_user): if system_user is None: logger.warning(ERR_NO_USER_FOUND) return 0 return subprocess.call([ POST_MODIFY_USER, 'restore', '--username', system_user])