
    `fb                        d Z ddlZddlZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZ dd	lmZmZmZ dd
lmZ 	 ddlmZ n# e $ r dZY nw xY w ed          Z! ed          Z" ed          Z# ed          Z$ ed          Z%dZ& e'edd          Z(dZ) e'edd          Z* e'edd          Z+ e'edd          Z, ej-                    Z.e.dk    Z/e.dk    Z0dZ1ej2        ej3        z  ej4        z  Z5ej6        ej7        z  dz  ej6        dz  z  ej6        z  Z8dZ9dZ:d Z;d!Z<d"  e=e	          D             Z>d# e>D             Z?d$ Z@ G d% d&eA          ZB G d' d(          ZCeCZDd) ZEd* ZFd+ ZG G d, d-          ZH	 	 dId/ZId0 ZJd1 ZKd2 ZLd3 ZMd4 ZNd5 ZOd6 ZPdJd7ZQd8 ZR eSe	d9          rd: ZTnd; ZT G d< d=          ZU eU            ZVeVjW        ZXeVjY        ZZeVj[        Z\eVj]        Z^d> Z_d? Z`d@ ZdKdAZaejb        c                    dB          rdC ZdndJdDZddE ZeedF             ZfdG ZgdH ZhdS )LziPlatforms.

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grpzmultiprocessing.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_pathr   r   E   r   @   EX_CANTCREATI   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}
zYou'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.
c                 D    h | ]}|                     d           rd|v|S )SIG_)
startswith).0sigs     B/var/www/html/env/lib/python3.11/site-packages/celery/platforms.py	<setcomp>r?   [   s=       
~~e!$C !/    c                 :    i | ]}t          t          |          |S  )getattr_signal)r<   names     r>   
<dictcomp>rF   _   s$    	<	<	<4''4
 
 $	<	<	<r@   c                     t          t          d          rt          j                    S t          j                            d          rdt          j        z   S t          t          d          rd                    d t          j        dd         D                       } t          j        dd         r7| d	d
                    d t          j        dd         D                       z   z  } d| z   S dS )z<Return string identifying the current Python implementation.python_implementationjavazJython pypy_version_info.c              3   4   K   | ]}t          |          V  d S Nstrr<   ps     r>   	<genexpr>z#pyimplementation.<locals>.<genexpr>i   s(      ??SVV??????r@   Nr7   - c              3   4   K   | ]}t          |          V  d S rM   rN   rP   s     r>   rR   z#pyimplementation.<locals>.<genexpr>k   s(      II!s1vvIIIIIIr@   zPyPy CPython)hasattr	_platformrH   sysplatformr;   joinrJ   )vs    r>   r   r   b   s    y122 
.000		 	 	(	( 3<''	)	*	* HH??S%:2A2%>????? $ 	JrwwIIs/DQRR/HIIIIIIIA{yr@   c                       e Zd ZdZdS )r   z'Raised if a PID lock can't be acquired.N)__name__
__module____qualname____doc__rB   r@   r>   r   r   q   s        1111r@   r   c                   N    e Zd ZdZdZd Zd ZeZd Zd Z	e	Z
d Zd Zd	 Zd
 ZdS )r   aF  Pidfile.

    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).
    Nc                 N    t           j                            |          | _        d S rM   )ospathabspath)selfre   s     r>   __init__zPidfile.__init__   s    GOOD))			r@   c           	          	 |                                   n^# t          $ rQ}t          t          t          t	          |                    t          j                    d                    Y d}~nd}~ww xY w| S )zAcquire lock.   N)	write_pidOSErrorr   r   rO   rY   exc_info)rg   excs     r>   acquirezPidfile.acquire   s}    	INN 	I 	I 	IJ
3s88 4 4clnnQ6GHHHHHHHH	Is    
A2AA--A2c                 J    t           j                            | j                  S )z#Return true if the pid lock exists.)rd   re   existsrg   s    r>   	is_lockedzPidfile.is_locked   s    w~~di(((r@   c                 .    |                                   dS )zRelease lock.N)removerg   argss     r>   releasezPidfile.release   s    r@   c                    t          d          5  t          | j                  5 }|                                }|                                |k    rt          d| j                   	 t          |                                          cddd           cddd           S # t
          $ r t          d| j         d          w xY w# 1 swxY w Y   	 ddd           dS # 1 swxY w Y   dS )z Read and return the current pid.ENOENTzPartial or invalid pidfile Nzpidfile z contents invalid.)r-   openre   readlinestrip
ValueErrorint)rg   fhlines      r>   read_pidzPidfile.read_pid   s   (## 	B 	Bdi 
BB{{}}::<<4''$AdiAAC C CBtzz||,,
B 
B 
B 
B 
B 
B 
B	B 	B 	B 	B 	B 	B 	B 	B " B B B$@49@@@B B BB
B 
B 
B 
B 
B 
B 
B 
B 
B	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	BsG   C"AC	* B#
C"##CC		C	C"C	C""C&)C&c                     t          t          j        t          j                  5  t	          j        | j                   ddd           dS # 1 swxY w Y   dS )zRemove the lock.N)r-   errnorz   EACCESrd   unlinkre   rr   s    r>   ru   zPidfile.remove   s    %,55 	! 	!Idi   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   AAAc                 r   	 |                                  }n@# t          $ r3 t          dt          j                   |                                  Y dS w xY w|s|                                  dS 	 t          j        |d           n# t          $ ri}|j	        t          j
        k    s|j	        t          j        k    r5t          dt          j                   |                                  Y d}~dS Y d}~nCd}~wt          $ r3 t          dt          j                   |                                  Y dS w xY wdS )zhRemove the lock if the process isn't running.

        I.e. process does not respond to signal.
        z#Broken pidfile found - Removing it.fileTr   z#Stale pidfile exists - Removing it.NF)r   r~   printrY   stderrru   rd   killrl   r   ESRCHEPERMSystemError)rg   pidrn   s      r>   remove_if_stalezPidfile.remove_if_stale   sP   
	--//CC 	 	 	7cjIIIIKKMMM44	  	KKMMM4
	GCOOOO 	 	 	yEK''39+C+C;#*MMMMttttt ,D+C+C+C+C  	 	 	7cjIIIIKKMMM44	 us.    9AA0B 
D4AC44<D43D4c                 z   t          j                    }| d}t          j        | j        t          t
                    }t          j        |d          }	 |                    |           |                                 	 t          j	        |           n# t          $ r Y nw xY w|                                 n# |                                 w xY wt          | j                  }	 |                                |k    rt          d          	 |                                 d S # |                                 w xY w)N
wz7Inconsistency: Pidfile content doesn't match at re-read)rd   getpidr{   re   PIDFILE_FLAGSPIDFILE_MODEfdopenwriteflushfsyncAttributeErrorclosereadr   )rg   r   content
pidfile_fdpidfilerfhs         r>   rk   zPidfile.write_pid   s$   ikk***WTY|DD
)J,,		MM'"""MMOOO$$$$!    MMOOOOGMMOOOO49oo	xxzzW$$ MO O O % IIKKKKKCIIKKKKs<   )B8 >B B8 
B B8 B  B8 8C&'D$ $D:)r^   r_   r`   ra   re   rh   ro   	__enter__rs   rx   __exit__r   ru   r   rk   rB   r@   r>   r   r   u   s        	 	 D* * *   I) ) )   HB B B! ! !
  8    r@   r   c                 V    t          |           }t          j        |j                   |S )a  Create 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registerrx   r   pidlocks     r>   r   r      s(    " g&&G
OGO$$$Nr@   c                 P   t          |           }|                                rn|                                sZt          t                              | |                                          t          j                   t          t                    |                                 |S )Nr   )r   rs   r   r   	PIDLOCKEDformatr   rY   r   
SystemExitr1   ro   r   s     r>   r   r      s    gG '7#:#:#<#< 'iw(8(8(:(:;;#*MMMM&&&OONr@   c                    t                      | D ]}	 t          j        |t          j                  }n# t          $ r Y /w xY w	                     t          j        |          dd                    t          j        |           x# t          j        |           w xY wfdfdt          t          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/'])
    r	   r7   c                 d    	 t          j        |           dd         v S # t          $ r Y dS w xY w)Nr	   r7   F)rd   fstatrl   )fdstatss    r>   fd_in_statszfd_by_path.<locals>.fd_in_stats!  sF    	8B<<!$-- 	 	 	55	s   ! 
//c                 *    g | ]} |          |S rB   rB   )r<   _fdr   s     r>   
<listcomp>zfd_by_path.<locals>.<listcomp>'  s(    FFFC[[5E5EFCFFFr@   i   )
setrd   r{   O_RDONLYrl   addr   r   ranger   )pathsre   r   r   r   s      @@r>   r.   r.     s     EEE  	r{++BB 	 	 	H		IIbhrll1Q3'(((HRLLLLBHRLLLL     GFFF5411FFFFs   6
AA/BB!c                   B    e Zd ZdZdZ	 	 d
dZd Zd ZeZd Z	e	Z
d	 ZdS )r   z(Context manager daemonizing the process.FNTc                 "   t          |t                    r't          ||                    d          rdnd          }|pt          | _        || _        || _        || _        || _	        t          j        t          j        t          j        f| _        d S )N0   
   )
isinstancerO   r   r;   DAEMON_WORKDIRworkdirumaskfakeafter_chdirafter_forkersrY   stdinstdoutr   stdfds)rg   r   r   r   r   r   r   kwargss           r>   rh   zDaemonContext.__init__/  s     eS!! 	CE$4$4S$9$9AqqrBBE0.
	&*y#*cj9r@   c                     |@t          j        t           j        t           j                  }t          j        ||           d S d S rM   )rd   r{   devnullO_RDWRdup2)rg   r   dests      r>   redirect_to_nullzDaemonContext.redirect_to_null<  s;    >72:ry11DGD" >r@   c                 "   | j         s| j        s|                                  t          j        | j                   | j        t          j        | j                   | j        r|                                  | j        st          | j	                  t          dg          z   }t          |           | j	        D ]$}|                     t          |                     %| j        r t          t                                           d| _         d S d S )Nz/dev/urandomT)_is_openr   _detachrd   chdirr   r   r   listr   r.   r   r   r   r   mputil_run_after_forkers)rg   keepr   s      r>   r{   zDaemonContext.openA  s   } 	!9 HT\"""z%$$$ #  """9 0 DK((:~6F+G+GGt$$$+ < <B)),r*:*:;;;;% 0&*<--/// DMMM+	! 	!r@   c                 &    | j         r	d| _         d S d S )NF)r   rv   s     r>   r   zDaemonContext.close[  s!    = 	"!DMMM	" 	"r@   c                     t          j                    dk    r?t          j                     t          j                    dk    rt          j        d           nt          j        d           | S Nr   )rd   forksetsid_exitrr   s    r>   r   zDaemonContext._detacha  sK    799>>IKKKwyy1}}HQKKKr@   )NNNFNT)r^   r_   r`   ra   r   rh   r   r{   r   r   r   r   rB   r@   r>   r   r   *  s        22H9==A: : : :  
! ! !0 I" " " H    r@   r   Fc                      t           st          d          |t          j                    n|}t                              d           t          ||            fd}t          ||||          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gidc                       o!t           d                                           r#t                                                     d S d S )Na)r{   r   r   rx   )logfiler   s   r>   after_chdir_doz detached.<locals>.after_chdir_do  sV     	.D#&&,,.. 	/G$$,,.....	/ 	/r@   )r   r   r   r   )r   RuntimeErrorrd   getcwdr(   resetr'   r   )	r   r   r   r   r   r   r   optsr   s	   ``       r>   r    r    l  s    H  ECDDD$_bikkk'GMM(cs++++/ / / / / / W4^   r@   c                     	 t          |           S # t          $ rJ 	 t                              |           j        cY S # t
          t          f$ r t          d|            w xY ww xY w)zParse user id.

    Arguments:
        uid (str, int): Actual uid, or the username of a user.
    Returns:
        int: The actual uid.
    zUser does not exist: )r   r~   r   getpwnampw_uidr   KeyErrorr   s    r>   r!   r!     s    :3xx : : :	:<<$$++++) 	: 	: 	:8388999	::    
A%=A%$A!!A%c                     	 t          |           S # t          $ rJ 	 t                              |           j        cY S # t
          t          f$ r t          d|            w xY ww xY w)zParse group id.

    Arguments:
        gid (str, int): Actual gid, or the name of a group.
    Returns:
        int: The actual gid of the group.
    zGroup does not exist: )r   r~   r   getgrnamgr_gidr   r   r   s    r>   r"   r"     s    ;3xx ; ; ;	;<<$$++++) 	; 	; 	;9C99:::	;;r   c                 >   | d d          } 	 	 t          j        |           S # t          $ r& t          |           dk    r | d d         | d d <   Y nNt          $ rB}|j        t
          j        k    st          |           dk    r | d d         | d d <   Y d }~nd }~ww xY w)Nr	   )rd   r#   r~   lenrl   r   EINVAL)groupsrn   s     r>   _setgroups_hackr     s     AAAYF
$		$<''' 	$ 	$ 	$6{{assF111III 	$ 	$ 	$yEL((CKK1,<,<ssF111IIIIII	$
$s   ! -B	B8BBc                 :    d}	 t          j        d          }n# t          $ r Y nw xY w	 t           d|                   S # t          $ rN}|j        t
          j        k    r t           fdt          j                    D                       r Y d}~dS d}~ww xY w)z+Set active groups from a list of group ids.NSC_NGROUPS_MAXc              3       K   | ]}|vV  	d S rM   rB   )r<   groupr   s     r>   rR   zsetgroups.<locals>.<genexpr>  s(      ??uuF"??????r@   )	rd   sysconf	Exceptionr   rl   r   r   any	getgroups)r   
max_groupsrn   s   `  r>   r#   r#     s    JZ 011

   vkzk2333   9##????????? 		 	 	 	 	 	s$    
''A 
BABBc                    t           sdS t                               |           d         t          t          d          rt          j        |          S fdt
                                          D             }t          |           dS )zyInit process group permissions.

    Compat version of :func:`os.initgroups` that was first
    added to Python 2.7.
    Nr   r$   c                 0    g | ]}|j         v |j        S rB   )gr_memr   )r<   grusernames     r>   r   zinitgroups.<locals>.<listcomp>  s1     ( ( (BRY&& i&&&r@   )r   getpwuidrW   rd   r$   r   getgrallr#   )r   r   r   r  s      @r>   r$   r$     s      ||C  #Hr<   ,}Xs+++( ( ( (#,,.. ( ( (Ffr@   c                 H    t          j        t          |                      dS )z4Version of :func:`os.setgid` supporting group names.N)rd   r%   r"   r   s    r>   r%   r%         Iinnr@   c                 H    t          j        t          |                      dS )z2Version of :func:`os.setuid` supporting usernames.N)rd   r&   r!   r   s    r>   r&   r&     r  r@   c                    t           j        dk    rdS t          j                    r"t          j                    st          d          | ot          |           } |ot          |          }| rt          | |           n|ot          |           | r5t          j                    s"t          j                    st          d          |r5t          j
                    s$t          j                    st          d          dS dS dS )a  Change 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.
    win32Nzcontact supportz%Still root uid after drop privileges!z%Still root gid after drop privileges!)rY   rZ   rd   geteuidgetuidr
   r!   r"   _setuidr%   getgidgetegidr   s     r>   r'   r'     s    |w	z|| 3y{{ 	3 1222

 )C..C

 )C..C
 Ss
 E29;; Erz|| ECDDD
 E29;; Erz|| ECDDDE E E E E Er@   c                 H   |s&t           rt                               |           j        }t          |           t	          | |           t          |            	 t          d           t          d          # t          $ r!}|j        t          j	        k    r Y d }~d S d }~ww xY w)Nr   z6non-root user able to restore privileges after setuid.)
r   r  pw_gidr%   r$   r&   r
   rl   r   r   )r   r   rn   s      r>   r  r  "  s     '3 'll3& 3KKKsC 3KKK	Fq			 DF F 	F    9## $#####s   A6 6
B! BB!	setitimerc                 D    t          j        t           j        |            d S rM   )rD   r  ITIMER_REALsecondss    r>   
_arm_alarmr  ?  s    '-w77777r@   c                 R    t          j        t          j        |                      d S rM   )rD   alarmmathceilr  s    r>   r  r  B  s"    di(()))))r@   c                   f    e Zd ZdZej        Zej        Zd Z	d Z
d Zd Zd Zd Zd Zd	 ZddZd
S )SignalsaE  Convenience 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)
    c                      t          |          S rM   )r  )rg   r  s     r>   	arm_alarmzSignals.arm_alarml  s    '"""r@   c                 *    t          j        d          S r   )rD   r!  rr   s    r>   reset_alarmzSignals.reset_alarmo  s    }Qr@   c                 T    	 |                      |           dS # t          $ r Y dS w xY w)z@Return true value if signal by ``name`` exists on this platform.TF)signumr   rg   rE   s     r>   	supportedzSignals.supportedr  sD    	KK 4  	 	 	55	s    
''c                    t          |t          j                  r|S t          |t                    r|                                st          d          |                    d          sd|z   }t          t          |          S )zGet signal number by name.z%signal name must be uppercase string.r9   )	r   numbersIntegralrO   isupper	TypeErrorr;   rC   rD   r,  s     r>   r+  zSignals.signum{  s|    dG,-- 	K$$$ 	E||~~	ECDDDu%% 	 4<Dw%%%r@   c                 J                            fd|D                        dS )zReset signals to the default signal handler.

        Does nothing if the platform has no support for signals,
        or the specified signal in particular.
        c              3   *   K   | ]}|j         fV  d S rM   )defaultr<   r=   rg   s     r>   rR   z Signals.reset.<locals>.<genexpr>  s*      @@CS$,'@@@@@@r@   Nupdate)rg   signal_namess   ` r>   r   zSignals.reset  s2     	@@@@<@@@@@@@@r@   c                 J                            fd|D                        dS )zIgnore signal using :const:`SIG_IGN`.

        Does nothing if the platform has no support for signals,
        or the specified signal in particular.
        c              3   *   K   | ]}|j         fV  d S rM   )ignoredr6  s     r>   rR   z!Signals.ignore.<locals>.<genexpr>  s*      99CS$,'999999r@   Nr7  )rg   namess   ` r>   ignorezSignals.ignore  s2     	9999599999999r@   c                 P    t          j        |                     |                    S rM   )rD   	getsignalr+  r,  s     r>   __getitem__zSignals.__getitem__  s     T!2!2333r@   c                     	 t          j        |                     |          |           dS # t          t          f$ r Y dS w xY w)zInstall signal handler.

        Does nothing if the current platform has no support for signals,
        or the specified signal in particular.
        N)rD   signalr+  r   r~   )rg   rE   handlers      r>   __setitem__zSignals.__setitem__  sR    	N4;;t,,g66666
+ 	 	 	DD	s   (, A ANc                 ^    t          |pi fi |                                D ]
\  }}|| |<   dS )z#Set signal handlers from a mapping.N)dictitems)rg   _d_sigmaprE   rD  s        r>   r8  zSignals.update  sJ    !#)66v66<<>> 	! 	!MD' DJJ	! 	!r@   rM   )r^   r_   r`   ra   rD   SIG_IGNr<  SIG_DFLr5  r'  r)  r-  r+  r   r>  rA  rE  r8  rB   r@   r>   r%  r%  F  s           D oGoG# # #       	& 	& 	&A A A: : :4 4 4	 	 	! ! ! ! ! !r@   r%  c                 ,    t           |          dd         S )z)Return name of signal from signal number.r7   N)r   )r+  s    r>   r)   r)     s    &>!""r@   c                     d| d         v rdnd}t          |           |k    rd                    | |d                    S dS )Nmanager   rj   r	    rT   )r   r[   )argv	arg_starts     r>   strargvrS    sJ    a((aI
4yy9xxYZZ()))2r@   c                     t                               d          r;	 t          t                               d                     dS # t          $ r Y dS w xY wdS )z@Sends signal ``name`` to process when parent process terminates.SIGKILLN)r(   r-  _set_pdeathsigr+  rl   )rE   s    r>   r   r     si    ## 	7>>)4455555 	 	 	DD	 s   'A 
AAc                     d|  d}|r| d| n|}t           r't                               t          |                     |S )zxSet the :command:`ps` name for the currently running process.

    Only works if :pypi:`setproctitle` is installed.
    []rP  )_setproctitler   r   )prognameinfo	proctitles      r>   r*   r*     sX    
  HI)-<9%%t%%%9I 8""8I#6#6777r@   NOSETPSc                      dS )zDisabled feature.NrB   )r   ks     r>   r+   r+     s      r@   c                 x    |r|  d| } t           rt                      j        nd}t          |  d| |          S )z|Set the :command:`ps` name from the current process name.

        Only works if :pypi:`setproctitle` is installed.
        z: MainProcess:)r\  )r   rE   r*   )r[  r\  hostnamerE   s       r>   r+   r+     sX    
  	1"00h00H)8K  %%m H!5!5t!5!5DAAAAr@   c                 Z    t          | t                    rt          t          |           S | S )z(Get errno for string (e.g., ``ENOENT``).)r   rO   rC   r   )ns    r>   r,   r,     s)    !S !ua   Hr@   c               /      K   |                     d          pt          f}d | D             } 	 dV  dS # |$ r&}t          |d          s |j        | vr Y d}~dS d}~ww xY w)a  Context 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`.
    typesc                 ,    g | ]}t          |          S rB   )r,   )r<   r   s     r>   r   z ignore_errno.<locals>.<listcomp>  s     888nU##888r@   Nr   )getr  rW   r   )errnosr   rh  rn   s       r>   r-   r-     s      $ JJw/I<E88888F   sG$$ 	9F"" #"""""s   3 AAAc                    t           t          d S d| v pd| v }t          t          d          rt          j                    nd}t          t          d          rt          j                    nd}t          t          d          rt          j                    nd}t          t          d          rt          j                    nd}t          t          d          r(t          d	 d
D                       st          d          	 t           
                    |          }t           
                    |          }nJ# t          $ r= t          j        t          t                               t!          |||||           Y d S w xY w|d         }|d         }	||	fd}
|dk    p|dk    }|st#          fd|
D                       rt!          |||||           d S d S )Npicklez"application/group-python-serializer  i  r  r  r  fchownc              3   @   K   | ]}t          t          |          V  d S rM   )rW   rd   )r<   attrs     r>   rR   z#check_privileges.<locals>.<genexpr>  sH       K K 2t$$ K K K K K Kr@   )r  r  r  r  z$suspicious platform, contact supportr   )sudowheelc              3       K   | ]}|v V  	d S rM   rB   )r<   r  gids_in_uses     r>   rR   z#check_privileges.<locals>.<genexpr>/  s<       > > {* > > > > > >r@   )r   r   rW   rd   r  r  r  r  allr
   getgrgidr   warningswarnr   ASSUMING_ROOT_warn_or_raise_security_errorr  )accept_contentpickle_or_serializer   r   euidegid	gid_entry
egid_entrygid_grp_nameegid_grp_namegroups_with_security_riskis_rootrt  s               @r>   check_privilegesr    s(   
{ck#~5 UBnT  !X..
9")+++EC X..
9")+++EC"2y11<2:<<<uD"2y11<2:<<<uDr8 H K KIK K K K K 	H FGGG
LL%%	\\$''

   om44555%dD#s&9	; 	; 	;	 Q<LqMM  /K 1Qh#$!)G  ;# > > > >#<> > > > > ;%dD#s&9	; 	; 	; 	; 	;; ;s    4D5 5AE<;E<c           
         t           j                            dd          }|r-|s+t          t                              ||||                     t          j        t          t                              ||||                                d S )NC_FORCE_ROOTF)r   r}  r   r~  )
rd   environrj  r
   ROOT_DISALLOWEDr   rw  rx  r   ROOT_DISCOURAGED)r~  r}  r   r   r|  c_force_roots         r>   rz  rz  5  s    :>>.%88L < O22$Cd 3 
 
   	 M/"2"9"9d$ #: # #       r@   )NNNNr   NF)NNrM   )ira   r   r   r"  r/  rd   rZ   rX   rC  rD   rY   rw  
contextlibr   billiard.compatr   r   billiard.utilr   rV  kombu.utils.compatr   kombu.utils.encodingr   
exceptionsr
   r   r   localr   billiard.processr   ImportErrorrZ  r   r   r   r   __all__rC   r   r   r   r   r1   systemr   r   r   r   O_CREATO_EXCLO_WRONLYr   R_OKW_OKr   r   r  r  ry  dirSIGNAMESr   r   r  r   r   PIDFiler   r   r.   r   r    r!   r"   r   r#   r$   r%   r&   r'   r  rW   r  r%  r(   r+  
get_signalrE  install_signal_handlerr   reset_signalr>  ignore_signalr)   rS  r*   r  rj  r+   r,   r-   r  rz  rB   r@   r>   <module>r     s        				         



  % % % % % % 5 5 5 5 5 5 5 5 9 9 9 9 9 9 + + + + + + ) ) ) ) ) ) ? ? ? ? ? ? ? ? ? ?      0000000   OOO 
>**:j!!jj	*	+	+ 	GQ
-r2272z2&&wr>2..				Xy 

RY&427"q(bg!^<H+	 
 3w<<   
=	<8	<	<	<  2 2 2 2 2 2 2 2m m m m m m m m`   ,   G  G  GF? ? ? ? ? ? ? ?D DE %5 5 5 5p: : :"; ; ;"$ $ $&  "     
  
E E E E<F F F8 77K   *8 8 8 8* * *a! a! a! a! a! a! a! a!H '))^
 , }  
    	 	 	 	 :>>) B       B B B B     8*; *; *;Z
 
 
 
 
s   A A)(A)