HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/celery/__pycache__/platforms.cpython-39.pyc
a

X>h
d�@sdZddlZddlZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddlm
Z
ddlmZmZddlmZddlmZddlmZdd	lmZmZmZdd
lmZzddlmZWne y�dZYn0ed�Z!ed
�Z"ed�Z#ed�Z$ed�Z%dZ&e'edd�Z(dZ)e'edd�Z*e'edd�Z+e'edd�Z,e�-�Z.e.dkZ/e.dkZ0dZ1ej2ej3Bej4BZ5ej6ej7Bd>ej6d>Bej6BZ8dZ9dZ:d Z;d!Z<d"d#�e=e	�D�Z>d$d%�e>D�Z?d&d'�Z@d(d)�ZAGd*d+�d+eB�ZCGd,d-�d-�ZDeDZEd.d/�ZFd0d1�ZGd2d3�ZHGd4d5�d5�ZIded7d8�ZJd9d:�ZKd;d<�ZLd=d>�ZMd?d@�ZNdAdB�ZOdCdD�ZPdEdF�ZQdfdGdH�ZRdIdJ�ZSeTe	dK��rtdLdM�ZUndNdM�ZUGdOdP�dP�ZVeV�ZWeWjXZYeWjZZ[eWj\Z]eWj^Z_dQdR�Z`dSdT�ZadUdV�ZdgdWdX�Zbejc�ddY��r�dZd[�Zen
dhd\d[�Zed]d^�Zfe
d_d`��Zgdadb�Zhdcdd�ZidS)iziPlatforms.

Utilities dealing with platform specifics: signals, daemonization,
users, groups, and so on.
�N)�contextmanager)�close_open_fds�	get_fdmax)�
set_pdeathsig)�maybe_fileno)�safe_str�)�
SecurityError�SecurityWarning�reraise)�
try_import)�current_process�setproctitle�resource�pwd�grpzmultiprocessing.util)�EX_OK�
EX_FAILURE�EX_UNAVAILABLE�EX_USAGE�SYSTEM�IS_macOS�
IS_WINDOWS�SIGMAP�pyimplementation�
LockFailedr�Pidfile�create_pidlockr�
DaemonContext�detached�	parse_uid�	parse_gid�	setgroups�
initgroups�setgid�setuid�maybe_drop_privileges�signals�signal_name�set_process_title�set_mp_process_title�get_errno_name�ignore_errno�
fd_by_path�isattyrr�Er�@�EX_CANTCREAT�I�Darwin�Windows�/��zLERROR: Pidfile ({0}) already exists.
Seems we're already running? (pid: {1})a>Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!

If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).

User information: uid={uid} euid={euid} gid={gid} egid={egid}
z�You're running the worker with superuser privileges: this is
absolutely not recommended!

Please specify a different user using the --uid option.

User information: uid={uid} euid={euid} gid={gid} egid={egid}
ziAn entry for the specified gid or egid was not found.
We're assuming this is a potential security issue.
cCs"h|]}|�d�rd|vr|�qS)�SIG�_)�
startswith��.0�sig�r>�:/usr/local/lib/python3.9/site-packages/celery/platforms.py�	<setcomp>[s�r@cCsi|]}tt|�|�qSr>)�getattr�_signal)r<�namer>r>r?�
<dictcomp>_�rDcCs"z
|��WStyYn0dS)z6Return true if the process has a controlling terminal.N)r.�AttributeError)�fhr>r>r?r.bs
r.cCs�ttd�rt��Stj�d�r(dtjSttd�r�d�dd�tjdd	�D��}tjd	d�r�|d
d�dd�tjd	d�D��7}d
|SdSdS)z<Return string identifying the current Python implementation.�python_implementation�javazJython �pypy_version_info�.css|]}t|�VqdS�N��str�r<�pr>r>r?�	<genexpr>qrEz#pyimplementation.<locals>.<genexpr>Nr7�-�css|]}t|�VqdSrLrMrOr>r>r?rQsrEzPyPy �CPython)�hasattr�	_platformrH�sys�platformr:�joinrJ)�vr>r>r?rjs


&rc@seZdZdZdS)rz'Raised if a PID lock can't be acquired.N)�__name__�
__module__�__qualname__�__doc__r>r>r>r?rysrc@s\eZdZdZdZdd�Zdd�ZeZdd�Zd	d
�Z	e	Z
dd�Zd
d�Zdd�Z
dd�ZdS)raFPidfile.

    This is the type returned by :func:`create_pidlock`.

    See Also:
        Best practice is to not use this directly but rather use
        the :func:`create_pidlock` function instead:
        more convenient and also removes stale pidfiles (when
        the process holding the lock is no longer running).
    NcCstj�|�|_dSrL)�os�path�abspath)�selfr`r>r>r?�__init__�szPidfile.__init__c
CsRz|��Wn@tyL}z(tttt|��t��d�WYd}~n
d}~00|S)z
Acquire lock.�N)�	write_pid�OSErrorrrrNrW�exc_info)rb�excr>r>r?�acquire�s
2zPidfile.acquirecCstj�|j�S)z#Return true if the pid lock exists.)r_r`�exists�rbr>r>r?�	is_locked�szPidfile.is_lockedcGs|��dS)z
Release lock.N)�remove�rb�argsr>r>r?�release�szPidfile.releasec
Cs�td���t|j���}|��}|��|kr:td|j����z*t|���WWd�Wd�Sty�td|j�d���Yn0Wd�n1s�0YWd�n1s�0YdS)z Read and return the current pid.�ENOENTzPartial or invalid pidfile Nzpidfile z contents invalid.)r,�openr`�readline�strip�
ValueError�int)rbrG�liner>r>r?�read_pid�s

�*�zPidfile.read_pidcCs>ttjtj��t�|j�Wd�n1s00YdS)zRemove the lock.N)r,�errnorq�EACCESr_�unlinkr`rkr>r>r?rm�szPidfile.removec
Csz|��}Wn*ty6tdtjd�|��YdS0|sH|��dS|t��kr`|��dSzt�|d�Wn�t	y�}zH|j
t
jks�|j
t
jkr�tdtjd�|��WYd}~dSWYd}~n4d}~0t
�y�tdtjd�|��YdS0dS)zhRemove the lock if the process isn't running.

        I.e. process does not respond to signal.
        z#Broken pidfile found - Removing it.��fileTrz#Stale pidfile exists - Removing it.NF)rxru�printrW�stderrrmr_�getpid�killrfryZESRCH�EPERM�SystemError)rb�pidrhr>r>r?�remove_if_stale�s0"zPidfile.remove_if_stalecCs�t��}|�d�}t�|jtt�}t�|d�}z@|�|�|��zt�	|�Wnt
ybYn0W|��n
|��0t|j�}z |��|kr�t
d��W|��n
|��0dS)N�
�wz7Inconsistency: Pidfile content doesn't match at re-read)r_r�rrr`�
PIDFILE_FLAGS�PIDFILE_MODE�fdopen�write�flush�fsyncrF�close�readr)rbr��contentZ
pidfile_fd�pidfileZrfhr>r>r?re�s&


�zPidfile.write_pid)r[r\r]r^r`rcri�	__enter__rlrp�__exit__rxrmr�rer>r>r>r?r}s rcCst|�}t�|j�|S)aCreate and verify pidfile.

    If the pidfile already exists the program exits with an error message,
    however if the process it refers to isn't running anymore, the pidfile
    is deleted and the program continues.

    This function will automatically install an :mod:`atexit` handler
    to release the lock at exit, you can skip this by calling
    :func:`_create_pidlock` instead.

    Returns:
       Pidfile: used to manage the lock.

    Example:
        >>> pidlock = create_pidlock('/var/run/app.pid')
    )�_create_pidlock�atexit�registerrp�r�Zpidlockr>r>r?r�srcCsFt|�}|��r:|��s:tt�||���tjd�t	t
��|��|S)Nr|)rrlr�r~�	PIDLOCKED�formatrxrWr�
SystemExitr1rir�r>r>r?r�
sr�c
s�t��|D]b}zt�|tj�}Wnty6Yq
Yn0z&��t�|�dd��Wt�|�q
t�|�0q
�fdd���fdd�tt	d��D�S)a[Return a list of file descriptors.

    This method returns list of file descriptors corresponding to
    file paths passed in paths variable.

    Arguments:
        paths: List[str]: List of file paths.

    Returns:
        List[int]: List of file descriptors.

    Example:
        >>> keep = fd_by_path(['/dev/urandom', '/my/precious/'])
    rr7cs2zt�|�dd��vWSty,YdS0dS)Nrr7F)r_�fstatrf)�fd)�statsr>r?�fd_in_stats-szfd_by_path.<locals>.fd_in_statscsg|]}�|�r|�qSr>r>)r<Z_fd)r�r>r?�
<listcomp>3rEzfd_by_path.<locals>.<listcomp>i)
�setr_rr�O_RDONLYrf�addr�r��ranger)�pathsr`r�r>)r�r�r?r-s
r-c@sFeZdZdZdZddd�Zdd�Zd	d
�ZeZdd�Z	e	Z
d
d�ZdS)rz(Context manager daemonizing the process.FNTcKsZt|t�r"t||�d�rdnd�}|p(t|_||_||_||_||_	t
jt
jt
j
f|_dS)N�0��
)�
isinstancerNrvr:�DAEMON_WORKDIR�workdir�umask�fake�after_chdir�
after_forkersrW�stdin�stdoutr�stdfds)rbr�r�r�r�r�r��kwargsr>r>r?rc;s

zDaemonContext.__init__cCs(|dur$t�tjtj�}t�||�dSrL)r_rr�devnull�O_RDWR�dup2)rbr��destr>r>r?�redirect_to_nullHszDaemonContext.redirect_to_nullcCs�|js�|js|��t�|j�|jdur6t�|j�|jrD|��|js�t|j	�t
dg�}t|�|j	D]}|�t
|��ql|jr�tdur�t��d|_dS)Nz/dev/urandomT)�_is_openr��_detachr_�chdirr�r�r��listr�r-rr�rr��mputilZ_run_after_forkers)rbZkeepr�r>r>r?rrMs 

zDaemonContext.opencGs|jrd|_dS)NF)r�rnr>r>r?r�gszDaemonContext.closecCs:t��dkr,t��t��dkr6t�d�n
t�d�|S�Nr)r_�fork�setsid�_exitrkr>r>r?r�ms
zDaemonContext._detach)NNNFNT)r[r\r]r^r�rcr�rrr�r�r�r�r>r>r>r?r6s�

rFc	sTtstd��|durt��n|}t�d�t||d���fdd�}t||||d�S)a�Detach the current process in the background (daemonize).

    Arguments:
        logfile (str): Optional log file.
            The ability to write to this file
            will be verified before the process is detached.
        pidfile (str): Optional pid file.
            The pidfile won't be created,
            as this is the responsibility of the child.  But the process will
            exit if the pid lock exists and the pid written is still running.
        uid (int, str): Optional user id or user name to change
            effective privileges to.
        gid (int, str): Optional group id or group name to change
            effective privileges to.
        umask (str, int): Optional umask that'll be effective in
            the child process.
        workdir (str): Optional new working directory.
        fake (bool): Don't actually detach, intended for debugging purposes.
        **opts (Any): Ignored.

    Example:
        >>> from celery.platforms import detached, create_pidlock
        >>> with detached(
        ...           logfile='/var/log/app.log',
        ...           pidfile='/var/run/app.pid',
        ...           uid='nobody'):
        ... # Now in detached child process with effective user set to nobody,
        ... # and we know that our logfile can be written to, and that
        ... # the pidfile isn't locked.
        ... pidlock = create_pidlock('/var/run/app.pid')
        ...
        ... # Run the program
        ... program.run(logfile='/var/log/app.log')
    z&This platform does not support detach.N�SIGCLD��uid�gidcs&�ot�d����r"t����dS)N�a)rrr�r�rpr>��logfiler�r>r?�after_chdir_do�sz detached.<locals>.after_chdir_do)r�r�r�r�)r�RuntimeErrorr_�getcwdr'�resetr&r)	r�r�r�r�r�r�r��optsr�r>r�r?rxs$
�rcCsZz
t|�WStyTzt�|�jWYSttfyNtd|����Yn0Yn0dS)z�Parse user id.

    Arguments:
        uid (str, int): Actual uid, or the username of a user.
    Returns:
        int: The actual uid.
    zUser does not exist: N)rvrur�getpwnam�pw_uidrF�KeyError�r�r>r>r?r �s
r cCsZz
t|�WStyTzt�|�jWYSttfyNtd|����Yn0Yn0dS)z�Parse group id.

    Arguments:
        gid (str, int): Actual gid, or the name of a group.
    Returns:
        int: The actual gid of the group.
    zGroup does not exist: N)rvrur�getgrnam�gr_gidrFr��r�r>r>r?r!�s
r!c
Cs�|dd�}zt�|�WStyLt|�dkr4�|dd�|dd�<Yqty�}z:|jtjksrt|�dkrt�|dd�|dd�<WYd}~qd}~00qdS)Nr���)r_r"ru�lenrfry�EINVAL)�groupsrhr>r>r?�_setgroups_hack�sr�c
s�d}zt�d�}Wnty$Yn0zt�d|��WSty�}z6|jtjkrV�t�fdd�t��D��rr�WYd}~n
d}~00dS)z+Set active groups from a list of group ids.N�SC_NGROUPS_MAXc3s|]}|�vVqdSrLr>�r<�group�r�r>r?rQ�rEzsetgroups.<locals>.<genexpr>)	r_�sysconf�	Exceptionr�rfryr��any�	getgroups)r�Z
max_groupsrhr>r�r?r"�sr"csNtsdSt�|�d�ttd�r,t��|�S�fdd�t��D�}t|�dS)zyInit process group permissions.

    Compat version of :func:`os.initgroups` that was first
    added to Python 2.7.
    Nrr#csg|]}�|jvr|j�qSr>)�gr_memr�)r<Zgr��usernamer>r?r�s
�zinitgroups.<locals>.<listcomp>)r�getpwuidrUr_r#r�getgrallr")r�r�r�r>r�r?r#�s
r#cCst�t|��dS)z4Version of :func:`os.setgid` supporting group names.N)r_r$r!r�r>r>r?r$sr$cCst�t|��dS)z2Version of :func:`os.setuid` supporting usernames.N)r_r%r r�r>r>r?r%sr%cCs�tjdkrdSt��r&t��s&td��|o0t|�}|o<t|�}|rNt||�n|oXt	|�|rvt��svt��svtd��|r�t�
�s�t��s�td��dS)aChange process privileges to new user/group.

    If UID and GID is specified, the real user/group is changed.

    If only UID is specified, the real user is changed, and the group is
    changed to the users primary group.

    If only GID is specified, only the group is changed.
    �win32Nzcontact supportz%Still root uid after drop privileges!z%Still root gid after drop privileges!)rWrXr_�geteuid�getuidr	r r!�_setuidr$�getgid�getegidr�r>r>r?r&s

r&c
Csz|strt�|�j}t|�t||�t|�ztd�Wn2tyl}z|jtjkrX�WYd}~nd}~00t	d��dS)Nrz6non-root user able to restore privileges after setuid.)
rr��pw_gidr$r#r%rfryr�r	)r�r�rhr>r>r?r�.s
�r��	setitimercCst�tj|�dSrL)rBr��ITIMER_REAL��secondsr>r>r?�
_arm_alarmKsr�cCst�t�|��dSrL)rB�alarm�math�ceilr�r>r>r?r�Nsc@sfeZdZdZejZejZdd�Z	dd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zddd�ZdS)�SignalsaEConvenience interface to :mod:`signals`.

    If the requested signal isn't supported on the current platform,
    the operation will be ignored.

    Example:
        >>> from celery.platforms import signals

        >>> from proj.handlers import my_handler
        >>> signals['INT'] = my_handler

        >>> signals['INT']
        my_handler

        >>> signals.supported('INT')
        True

        >>> signals.signum('INT')
        2

        >>> signals.ignore('USR1')
        >>> signals['USR1'] == signals.ignored
        True

        >>> signals.reset('USR1')
        >>> signals['USR1'] == signals.default
        True

        >>> from proj.handlers import exit_handler, hup_handler
        >>> signals.update(INT=exit_handler,
        ...                TERM=exit_handler,
        ...                HUP=hup_handler)
    cCst|�SrL)r�)rbr�r>r>r?�	arm_alarmxszSignals.arm_alarmcCs
t�d�Sr�)rBr�rkr>r>r?�reset_alarm{szSignals.reset_alarmcCs,z|�|�Wnty"YdS0dSdS)z@Return true value if signal by ``name`` exists on this platform.FTN)�signumrF�rbrCr>r>r?�	supported~s
zSignals.supportedcCsFt|tj�r|St|t�r"|��s*td��|�d�s<d|}tt|�S)zGet signal number by name.z%signal name must be uppercase string.r8)	r��numbers�IntegralrN�isupper�	TypeErrorr:rArBr�r>r>r?r��s
�
zSignals.signumcs���fdd�|D��dS)z�Reset signals to the default signal handler.

        Does nothing if the platform has no support for signals,
        or the specified signal in particular.
        c3s|]}|�jfVqdSrL)�defaultr;rkr>r?rQ�rEz Signals.reset.<locals>.<genexpr>N��update)rbZsignal_namesr>rkr?r��sz
Signals.resetcs���fdd�|D��dS)z�Ignore signal using :const:`SIG_IGN`.

        Does nothing if the platform has no support for signals,
        or the specified signal in particular.
        c3s|]}|�jfVqdSrL)�ignoredr;rkr>r?rQ�rEz!Signals.ignore.<locals>.<genexpr>Nr)rb�namesr>rkr?�ignore�szSignals.ignorecCst�|�|��SrL)rB�	getsignalr�r�r>r>r?�__getitem__�szSignals.__getitem__c	Cs2zt�|�|�|�Wnttfy,Yn0dS)z�Install signal handler.

        Does nothing if the current platform has no support for signals,
        or the specified signal in particular.
        N)rB�signalr�rFru)rbrC�handlerr>r>r?�__setitem__�szSignals.__setitem__NcKs.t|pifi|����D]\}}|||<qdS)z#Set signal handlers from a mapping.N)�dict�items)rbZ_d_ZsigmaprCrr>r>r?r�s zSignals.update)N)r[r\r]r^rB�SIG_IGNr�SIG_DFLr�r�r�r�r�r�rrr	rr>r>r>r?r�Rs"	r�cCst|dd�S)z)Return name of signal from signal number.r7N)r)r�r>r>r?r(�sr(cCs6d|dvrdnd}t|�|kr2d�||d��SdS)NZmanagerrdr� rS)r�rY)�argvZ	arg_startr>r>r?�strargv�srcCs4t�d�r0ztt�d��Wnty.Yn0dS)z@Sends signal ``name`` to process when parent process terminates.�SIGKILLN)r'r��_set_pdeathsigr�rf)rCr>r>r?r�s

rcCs8d|�d�}|r|�d|��n|}tr4t�t|��|S)zxSet the :command:`ps` name for the currently running process.

    Only works if :pypi:`setproctitle` is installed.
    �[�]r)�
_setproctitlerr)�progname�infoZ	proctitler>r>r?r)�s
r)ZNOSETPScOsdS)zDisabled feature.Nr>)r��kr>r>r?r*�sr*cCs8|r|�d|��}trt�jnd}t|�d|��|d�S)z|Set the :command:`ps` name from the current process name.

        Only works if :pypi:`setproctitle` is installed.
        z: �MainProcess�:)r)r
rCr))rr�hostnamerCr>r>r?r*�scCst|t�rtt|�S|S)z(Get errno for string (e.g., ``ENOENT``).)r�rNrAry)�nr>r>r?r+�s

r+c
osj|�d�ptf}dd�|D�}z
dVWn<|yd}z$t|d�sD�|j|vrP�WYd}~n
d}~00dS)aContext manager to ignore specific POSIX error codes.

    Takes a list of error codes to ignore: this can be either
    the name of the code, or the code integer itself::

        >>> with ignore_errno('ENOENT'):
        ...     with open('foo', 'r') as fh:
        ...         return fh.read()

        >>> with ignore_errno(errno.ENOENT, errno.EPERM):
        ...    pass

    Arguments:
        types (Tuple[Exception]): A tuple of exceptions to ignore
            (when the errno matches).  Defaults to :exc:`Exception`.
    �typescSsg|]}t|��qSr>)r+)r<ryr>r>r?r�
rEz ignore_errno.<locals>.<listcomp>Nry)�getr�rUry)Zerrnosr�rrhr>r>r?r,�s


r,c	sLtdustdurdSd|vp"d|v}ttd�r6t��nd}ttd�rLt��nd}ttd�rbt��nd}ttd�rxt��nd}ttd�r�td	d
�dD��s�t	d��zt�
|�}t�
|�}Wn2ty�t�
tt��t|||||�YdS0|d
}|d
}	||	f�d}
|d
k�p|d
k}|�s8t�fdd
�|
D���rHt|||||�dS)N�picklez"application/group-python-serializer�i��r�r�r��fchowncss|]}tt|�VqdSrL)rUr_)r<�attrr>r>r?rQ s�z#check_privileges.<locals>.<genexpr>)r�r�r�r�z$suspicious platform, contact supportr)Zsudo�wheelc3s|]}|�vVqdSrLr>r��Zgids_in_user>r?rQ;s�)rrrUr_r�r�r�r��allr	�getgrgidr��warnings�warnr
�
ASSUMING_ROOT�_warn_or_raise_security_errorr�)Zaccept_content�pickle_or_serializer�r��euid�egidZ	gid_entryZ
egid_entryZgid_grp_nameZ
egid_grp_nameZgroups_with_security_riskZis_rootr>r#r?�check_privilegessD�
�

��

�r-c	CsLtj�dd�}|r,|s,ttj||||d���t�tt	j||||d���dS)NZC_FORCE_ROOTF)r�r+r�r,)
r_�environrr	�ROOT_DISALLOWEDr�r&r'r
�ROOT_DISCOURAGED)r,r+r�r�r*Zc_force_rootr>r>r?r)As�
�r))NNNNrNF)NN)N)NN)jr^r�ryr�r�r_rXrVrrBrWr&�
contextlibrZbilliard.compatrrZ
billiard.utilrrZkombu.utils.compatrZkombu.utils.encodingr�
exceptionsr	r
r�localrZbilliard.processr
�ImportErrorrrrrr��__all__rArrrrr1�systemrrrr��O_CREAT�O_EXCL�O_WRONLYr��R_OK�W_OKr�r�r/r0r(�dirZSIGNAMESrr.rr�rrZPIDFilerr�r-rrr r!r�r"r#r$r%r&r�rUr�r�r'r�Z
get_signalr	Zinstall_signal_handlerr�Zreset_signalrZ
ignore_signalr(rr)r.rr*r+r,r-r)r>r>r>r?�<module>s�
 
	�t	#B�
8

d




-