403Webshell
Server IP : 107.13.46.68  /  Your IP : 216.73.216.135
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux mariOS 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/bup/bup/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/bup/bup/__pycache__/helpers.cpython-312.pyc
�

"��e^���:�dZddlmZmZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZddlmZmZdd	lmZdd
lmZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl!m"Z"dd
l!m#Z#ddl$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+ddl,m-Z.e/e
jjadd��Z1Gd�d�Z2d�Z3Gd�d�Z4d�Z5e
jld�Z7e7dkDsJ�e
jld�Z8e8dk(rdZ8d�Z9	e
jtZ;ej|jd�rddl@Z@d�Z:ne;Z:d�ZAd �ZBd!�ZCd"�ZDd#�ZEdaFd$�ZGd%�ZHd&�ZIe
j�d'�xs%e/e
jjad(d��d'zZKe
j�d)�xs%e/e
jjad(d��d)zZLd*aMd+�ZNd,�ZOd-�ZPdxd.�ZQGd/�d0�ZRdxd1�ZSd2�ZTej�d3�ZVej�d4�ZWd5�ZXd6�ZYd7�ZZd8�Z[ej�Z]							dyd9�Z^dzd:�Z_d;�Z`d<�Zade8fd=�Zbd>�Zcd?�Zdej|jd@�rdA�ZendB�ZedC�ZfdagdD�ZhdE�ZiGdF�dGej�ZkGdH�dI�ZlGdJ�dKel�ZmdL�ZndMZodN�ZpGdO�dPel�ZqdQ�ZrdxdR�ZsGdS�dT�ZtdU�ZudV�Zvd{dW�Zwd{dX�Zxd{dY�Zyeze"dZd�Z{e{reze"d[d'�Z|da}d\�Z~d]�Zd^�Z�d_�Z�ga�d`�Z�da�Z�d|db�Z�dc�Z�dd�Z�de�Z�df�Z�dg�Z�dh�Z�di�Z�dj�Z�dk�Z�e�jZ�eze"dld�Z�e�redmgdn��Z�e�r
do�Z�dp�Z�dq�Z�ne �j&Z�dr�Z�ds�Z�ej�dt�Z�du�Z�ej�dv�Z�dw�Z�y#e<$re
jzZ;Y��~wxYw)}z%Helper functions and classes for bup.�)�absolute_import�division)�
namedtuple)�	ExitStack)�sizeof�c_void_p)�floor)�environ)�PIPE�Popen)�mkdtemp��rmtreeN)�_helpers)�io)�
argv_bytes�byte_int�nullcontext�
pending_raise)�byte_stream�path_msg)�
_tty_width�	BUP_DEBUGc��eZdZdZy)�Nonlocalz)Helper to deal with Python scoping issuesN)�__name__�
__module__�__qualname__�__doc__���/usr/lib/bup/bup/helpers.pyrrs��3�r!rc��|�|St�S�N)r)�managers r"�nullcontext_if_notr& s���)�7�<�{�}�<r!c� �eZdZdd�Zd�Zd�Zy)�	finalizedNc�(�|sJ�||_||_yr$��finalize�enter_result)�selfr,r+s   r"�__init__zfinalized.__init__%s����x� ��
�(��r!c��|jSr$)r,�r-s r"�	__enter__zfinalized.__enter__)s��� � � r!c�:�|j|j�yr$r*�r-�exc_type�	exc_value�	tracebacks    r"�__exit__zfinalized.__exit__+s���
�
�d�'�'�(r!)NN)rrrr.r1r7r r!r"r(r($s��)�!�)r!r(c�.�tt|i|��d��S)Nc��t|�Sr$r��xs r"�<lambda>ztemp_dir.<locals>.<lambda>5s
�����r!)r(r
)�args�kwargss  r"�temp_dirr?.s���W�d�-�f�-�/B�C�Cr!�SC_PAGE_SIZE�
SC_ARG_MAX���i c��d}|D]}�|Sr$r )�iterable�results  r"�lastrF>s��
�F��
���
��Mr!�darwinc���	tj|tj�S#t$r3}|jtjk(rt|�cYd}~S�d}~wwxYwr$)�fcntl�F_FULLFSYNC�IOError�errno�ENOTSUP�
_fdatasync)�fd�es  r"�	fdatasyncrQLsK��	��;�;�r�5�#4�#4�5�5���	��w�w�%�-�-�'�!�"�~�%���	�s �#&�	A"�'A�A"�A�A"c�v����t���t��d�_���fd�}��fd�}|�|�fS)z�Returns (leading_matches_it, rest_it), where leading_matches_it
    must be completely exhausted before traversing rest_it.

    Nc3�H�K��D]}�|�r|���|f�_yy�wr$��first_nonmatch)r;�ns�	predicate�streams ���r"�leading_matchesz"partition.<locals>.leading_matchesas/������	�A���|���%&�D��!��	�s�"c3�`�K��jr�jd���D]}|���yy�w�NrrT)r;rVrXs ��r"�restzpartition.<locals>.resths:�����
����#�#�A�&�&��
����
��s�+.)�iterrrU)rWrXrYr\rVs``  @r"�	partitionr^Ys9���
�&�\�F�	��B��B����

��t�v�&�&r!c�:�i}|D]}|j|��|Sr$)�update)�xsrEr;s   r"�
merge_dictrbps'��
�F�
����
�
�a����Mr!c#�xK�	|j�}|r|jd�s|d��||k(ry|���6�w)N�
zHit EOF while reading line)�readline�endswith)�f�sentinel�ex_type�lines    r"�lines_until_sentinelrkwsC����
��z�z�|������u�-��6�7�7��8����
�
�s�8:c��	tj|�S#t$r(}|jtjk7r�Yd}~yd}~wwxYwr$)�os�stat�OSErrorrL�ENOENT)�pathrPs  r"�stat_if_existsrr�s@����w�w�t�}������7�7�e�l�l�"��#����s��	A�A�Ac��|rQtjg|ggd�\}}}|std��	tj||�}dk\sJ�||d}|r�Pyy#t$r(}|j
t
jk7r�Yd}~�=d}~wwxYw)Nz*select(fd) returned without being writabler)�selectrKrm�writerorL�EAGAIN)rO�buf�r�wr;�szrPs       r"�_hard_writer{�s���

��-�-��R�D�"�d�3���1�Q���F�G�G�	����"�c�"�B��Q�w��w��"�#�h�����	��w�w�%�,�,�&��'��	�s�A�	B�B�Bc���tjj�ttjj�t
|t�r|n|j��da	y)zPrint a log message to stderr.rN)
�sys�stdout�flushr{�stderr�fileno�
isinstance�bytes�encode�
_last_prog��ss r"�logr��sA���J�J������
�
�!�!�#�*�Q��*>�Q�A�H�H�J�O��Jr!c�.�tdk\rt|�yy�N���buglvlr�r�s r"�debug1r�����
��{��A��r!c�.�tdk\rt|�yy)N�r�r�s r"�debug2r��r�r!r��
BUP_FORCE_TTYr��c�,�trt|�|ayy)z8Calls log() if stderr is a TTY.  Does nothing otherwise.N)�istty2r��_last_progressr�s r"�progressr��s����A����r!c�`�tj�}|tz
dkDrt|�|ayy)z�Calls progress() only if we haven't printed progress in a while.

    This avoids overloading the stderr buffer with excess junk.
    g�������?N)�timer�r�)r��nows  r"�	qprogressr��s-���)�)�+�C�
�Z��#������
�r!c�\�tr&tjd�rtt�yyy)z�Calls progress() to redisplay the most recent progress message.

    Useful after you've printed some other message that wipes out the
    progress line.
    �
N)r�rfr�r r!r"�
reprogressr��s#���.�1�1�$�7��� �8�~r!c���	|rtj||�ytj|�y#t$r)}|jtjk(rn�Yd}~yd}~wwxYw)z�Recursively create directories on path 'd'.

    Unlike os.makedirs(), it doesn't raise an exception if the last element of
    the path already exists.
    N)rm�makedirsrorL�EEXIST)�d�moderPs   r"�mkdirpr��sN��	���K�K��4� ��K�K��N�����7�7�e�l�l�"���
���s�1�1�	A#�A�A#c��eZdZd�Zd�Zy)�
MergeIterItemc� �||_||_yr$)�entry�read_it)r-r�r�s   r"r.zMergeIterItem.__init__�s����
���r!c�4�|j|jkSr$)r�)r-r;s  r"�__lt__zMergeIterItem.__lt__�s���z�z�A�G�G�#�#r!N)rrrr.r�r r!r"r�r��s���$r!r�c#�B�K��r�fd�}ntj}d}td�|D��}d�|D�}d�|D�}|D�	�
cgc]\}	}
|	s�	t|	|
���}}	}
t	j
|�d}|ro||zs	|||�|dj|dj}
}	||	|�s|	}|	��|dz
}	t|
�}	t	j|t|	|
��|r�o|||�ycc}
}	w#t$rt	j|�Y�3wxYw�w)Nc�8��t|��t|�d�k(Sr$)�getattr)rP�pe�keys  �r"r<zmerge_iter.<locals>.<lambda>�s�����3��7�2�s�D�3I� I�r!rc3�2K�|]}t|����y�wr$��len��.0�its  r"�	<genexpr>zmerge_iter.<locals>.<genexpr>�s����(�B��B��(���c3�2K�|]}t|����y�wr$)r]r�s  r"r�zmerge_iter.<locals>.<genexpr>�s����&�"�T�"�X�&�r�c3�8K�|]}t|d�|f���y�wr$)�nextr�s  r"r�zmerge_iter.<locals>.<genexpr>�s����0�B�T�"�d�^�B��0�s�r�)�operator�eq�sumr��heapq�heapifyr�r�r��heapreplace�
StopIteration�heappop)�iters�pfreq�pfunc�pfinalr��samekey�count�total�heaprPr�r�s    `       r"�
merge_iterr��s�����
�I���+�+��
�E��(�%�(�(�E�&��&�E�0�%�0�D�.2�8�U�Q��a�M�!�R� �8�D�8�	�M�M�$��	
�B�
��u�}��%����Q��
�
�t�A�w���2���q�"�~��B��G�
��
��	:��R��A�

���d�M�!�R�$8�9���5�%���'9���	 ��M�M�$��	 �sC�AD�
C5�C5� AD�=C;�"D�+D�;D�D�D�Dc��	tj|�y#t$r(}|jtjk7r�Yd}~yd}~wwxYw)z�Delete a file at path 'f' if it currently exists.

    Unlike os.unlink(), does not throw an exception if the file didn't already
    exist.
    N)rm�unlinkrorLrp)rgrPs  r"r�r�	s:���
�	�	�!������7�7�e�l�l�"��#���s��	A	�A�A	s^[-_./a-zA-Z0-9]+$z^[-_./a-zA-Z0-9]+$c�f�|dk(rytj|�r|Sd|jdd�zS)Nr!s''s'%s'�'s'"'"')�_bq_simple_id_rx�match�replacer:s r"�bquoter�s5���C�x�����a� ����Q�Y�Y�t�Z�0�0�0r!c�f�|dk(rytj|�r|Sd|jdd�zS)Nr�z''z'%s'�'z'"'"')�_sq_simple_id_rxr�r�r:s r"�squoter� s5���B�w�����a� ����A�I�I�c�9�-�-�-r!c�r�t|t�rt|�St|t�rt	|�SJ�r$)r�r�r��strr�r:s r"�quoter�'s/���!�U���a�y���!�S���a�y���5r!c�$�t|ttf�r|Std�|D��rdj	tt|��Std�|D��rdj	tt|��Stdt|�z��)aMReturn a shell quoted string for cmd if it's a sequence, else cmd.

    cmd must be a string, bytes, or a sequence of one or the other,
    and the assumption is that if cmd is a string or bytes, then it's
    already quoted (because it's what's actually being passed to
    call() and friends.  e.g. log(shstr(cmd)); call(cmd)

    c3�<K�|]}t|t����y�wr$)r�r��r�r;s  r"r�zshstr.<locals>.<genexpr>;s����/�a�Z��5�
!�/���� c3�<K�|]}t|t����y�wr$)r�r�r�s  r"r�zshstr.<locals>.<genexpr>=s����-�A�Z��3�
�-�r�� zunsupported shstr argument: )
r�r�r��all�join�mapr�r��	TypeError�repr)�cmds r"�shstrr�0st���#��s�|�$��
�	�/�3�/�	/��y�y��V�S�)�*�*�	�-��-�	-��x�x��F�C�(�)�)�
�2�T�#�Y�>�
?�?r!c	�6�|r|dtfvsJ�t}t||t||||��}|j|�\}	}
|rU|jdk7rFt	ddjt
t|��|j|
rd|
zfz��dfz��|	|
|fS)N)�stdinr~r��shell�
preexec_fn�	close_fdsrz%subprocess %r failed with status %d%sr�z, stderr: %rr�)rr�communicate�
returncode�	Exceptionr�r�r�)r��inputr�r�r��checkr�r��p�out�errs           r"�exor�Ds���
���t��$�$�$���
�c��$�v��#�!�		#�A�
�}�}�U�#�H�C�������"��?��9�9�S���_�5�q�|�|�36�>�C�/�@�@�A�	A�<>�@�@�A�	A���Q�;�r!c�$�t|||��dS)z'Run a subprocess and return its output.)r�r�r)r�)�argvr�r�s   r"�readpiper�[s���t�
�%�8��;�;r!c���d}|D]}|t|�dzz
}�tj�D]2\}}|t|�t|�zdztt�zz
}�4|S)Nir�r�)r�r
�itemsrr)�command�	base_size�c�k�vs     r"�_argmax_baser`sm���I�
�&���S��\�A�%�%�	�&��
�
��<���1��S��V�c�!�f�_�q�(�6�(�+;�;�;�	�<��r!c�&�td�|D��S)Nc3�XK�|]"}t|�dztt�z���$y�w)r�N)r�rrr�s  r"r�z$_argmax_args_size.<locals>.<genexpr>js"����;��s�1�v��z�F�8�,�,�;�s�(*)r�)r=s r"�_argmax_args_sizeris���;�d�;�;�;r!c#�K�t|�}|ru||z
}d}|t|�kr3t|||dz�}||z
dkrn||z}|dz
}|t|�kr�3|d|}||d}t|�sJ�t||z|����|r�tyy�w)z�If args is not empty, yield the output produced by calling the
command list with args as a sequence of strings (It may be necessary
to return multiple strings in order to respect ARG_MAX).rr�N)r�)rr�rr�)	r�r=r��arg_maxr��room�i�	next_size�sub_argss	         r"�	batchpiper
ms������W�%�I�
���"��
���#�d�)�m�)�$�q��1��+�6�I��i��!�#���I��D�
��F�A��#�d�)�m����8���A�B�x���8�}��}��w��)�j�A�A��s�AB�+B�Bc��	tj|�}|r�tj|j
�rctjj|�\}}tjj|�}tjj||�}|Stjj|�}|S#t$rd}Y��wxYw)aReturn the absolute path of a file without following any final symlink.

    Behaves like os.path.realpath, but doesn't follow a symlink for the last
    element. (ie. if 'p' itself is a symlink, this one won't follow it, but it
    will follow symlinks in p's directory)
    N)
rm�lstatrorn�S_ISLNK�st_moderq�split�realpathr�)r��st�dir�namer�s     r"�resolve_parentr�s����
�X�X�a�[��
�d�l�l�2�:�:�&��g�g�m�m�A�&���d��g�g���s�#���g�g�l�l�3��%���J��g�g���q�!���J����
���s�B<�<C
�	C
c�2�tjd�dk7S)z6Return True if we appear to be running under fakeroot.�FAKEROOTKEYN)rm�getenvr r!r"�detect_fakerootr�s��
�9�9�]�#�t�+�+r!�cygwinc�>�tj�}d|vxsd|vS)Ni r)rm�	getgroups)�groupss r"�is_superuserr �s ��������f�}�+��V��+r!c�0�tj�dk(Sr[)rm�geteuidr r!r"r r �s���z�z�|�q� � r!c��	||}|dfS#t$rYnwxYwd}	||�x||<}|dfS#t$rd||<Y|dfSwxYw)z�Return (value, was_cached).  If there is a value in the cache
    for key, use that, otherwise, call get_value(key) which should
    throw a KeyError if there is no value -- in which case the cached
    and returned value will be None.
    TNF)�KeyError)�	get_valuer��cache�values    r"�cache_key_valuer(�sx��
��c�
���d�{����
��
���E��&�s�^�+��c�
�U��%�<�������c�
��%�<���s��	��
.�A�Ac�B�tstj�atS)zGet the FQDN of this machine.)�	_hostnamer�gethostnamer r!r"�hostnamer,�s����(�(�*�	��r!c���d}t|�}||krd|zSttj|�tj|�z�}d|dz
}d|tj||�z|fzS)Ng�@z%d�KMGTPEr�z%.1f%s)�float�int�mathr��pow)�size�unit�exponent�size_prefixs    r"�format_filesizer7�sn���D���;�D��d�{��t�}���4�8�8�D�>�T�X�X�d�^�3�4�H��8�a�<�(�K��t�d�h�h�t�X�6�6��D�D�Dr!c��eZdZy)�NotOkN)rrrr r!r"r9r9�s��r!r9c�l�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�BaseConnc� �d|_||_y�NF)�_base_closed�outp)r-r?s  r"r.zBaseConn.__init__�s��!�����	r!c��d|_y�NT�r>r0s r"�closezBaseConn.close�s
�� ��r!c��|Sr$r r0s r"r1zBaseConn.__enter__�s���r!c�h�t|d��5|j�ddd�y#1swYyxYw)NF)�rethrow)rrC)r-r4r5�tbs    r"r7zBaseConn.__exit__�s*��
�9�e�
4�	��J�J�L�	�	�	�s�(�1c� �|jsJ�yr$rBr0s r"�__del__zBaseConn.__del__�s��� � � � r!c��td��)NzSubclasses must implement _read��NotImplementedError�r-r3s  r"�_readzBaseConn._read�s��!�"C�D�Dr!c�X�|jj�|j|�S)z$Read 'size' bytes from input stream.)r?rrNrMs  r"�readz
BaseConn.read�s���	�	�����z�z�$��r!c��td��)Nz#Subclasses must implement _readlinerKrMs  r"�	_readlinezBaseConn._readline�s��!�"G�H�Hr!c�V�|jj�|j�S)z0Read from input stream until a newline is found.)r?rrRr0s r"rezBaseConn.readline�s���	�	�����~�~��r!c�:�|jj|�y)zWrite 'data' to output stream.N)r?ru�r-�datas  r"ruzBaseConn.write�s��	
�	�	����r!c��td��)z(Return true if input stream is readable.z#Subclasses must implement has_inputrKr0s r"�	has_inputzBaseConn.has_input�s��!�"G�H�Hr!c�&�|jd�y)z.Indicate end of output from last sent command.s
ok
N)rur0s r"�okzBaseConn.ok�s���
�
�9�r!c�Z�tjdd|�}|jd|z�y)z$Indicate server error to the client.s\s+r�s

error %s
N)�re�subru)r-r�s  r"�errorzBaseConn.errors%���F�F�7�D�!�$���
�
�?�Q�&�'r!c���|jj�d}t|�D]5}|s�|dk(ry|jd�rt	|dd�cS||��7td��)Nr!sokserror �z,server exited unexpectedly; see errors above)r?r�
linereader�
startswithr9r�)r-�onempty�rls   r"�	_check_okzBaseConn._check_oksj���	�	����
���T�"�
	�B����u������y�)��R���V�}�$����
	��F�G�Gr!c�*�d�}|j|�S)z:Remove all data for the current command from input stream.c��yr$r �rds r"rcz,BaseConn.drain_and_check_ok.<locals>.onemptys��r!�re�r-rcs  r"�drain_and_check_okzBaseConn.drain_and_check_oks��	��~�~�g�&�&r!c�*�d�}|j|�S)z1Verify that server action completed successfully.c��td|z��)Nzexpected "ok", got %r)r�rhs r"rcz"BaseConn.check_ok.<locals>.onemptys���3�b�8�9�9r!rirjs  r"�check_okzBaseConn.check_oks��	:��~�~�g�&�&r!N)rrrr.rCr1r7rIrNrPrRrerurXrZr^rerkrnr r!r"r;r;�sV���!���!�E� �
I� �
�
I��(�
H� '�'r!r;c�$�eZdZd�Zd�Zd�Zd�Zy)�Connc�>�tj||�||_yr$)r;r.�inp)r-rrr?s   r"r.z
Conn.__init__#s�����$��%���r!c�8�|jj|�Sr$)rrrPrMs  r"rNz
Conn._read's���x�x�}�}�T�"�"r!c�6�|jj�Sr$)rrrer0s r"rRzConn._readline*s���x�x� � �"�"r!c��tj|jj�gggd�\}}}|r#|d|jj�k(sJ�yy)NrT)rtrrr�)r-rd�wl�xls    r"rXzConn.has_input-sP���}�}�d�h�h�o�o�&7�%8�"�b�!�D���R��
��a�5�D�H�H�O�O�-�-�.�-��r!N)rrrr.rNrRrXr r!r"rprp"s���#�#�r!rpc#��K�|dkDretj|ggg�\}}}|d|k(sJ�tj||�}|std|z��|��|t	|�z}|dkDr�dyy�w)Nrz$Unexpected EOF reading %d more bytes)rtrmrPr�r�)rO�nrd�_rws     r"�checked_readerr{6st����
�a�%��=�=�"��r�2�.���A�q��!�u��{��{��g�g�b�!�n���)�$J�Q�$N�O�O��	�	�S��X�
��
�a�%�s�A)A.�,A.ic
��	||g}|j���tj|gg�\}}}|D]�}||k(rVtj|t�}|sn�tj
|t
jdt|�d�|z��^||k(s�dtj|d�}|sn9tj
|t
jdt|�d�|z���|j����tj
|t
jddd��y#tj
|t
jddd��wxYw)N�!IBr��r�r�)	�pollrtrmrP�
MAX_PACKETru�struct�packr�)	r��outfd�outr�errr�fdsrdrzrOrws	         r"�muxr�As��2��T�l���f�f�h���}�}�S�"�b�1�H�B��1��
K����:��'�'�$�
�3�C����H�H�U�F�K�K��s�3�x��$C�c�$I�J��4�Z��'�'�$��-�C����H�H�U�F�K�K��s�3�x��$C�c�$I�J�
K��f�f�h��	�������E�1�a�0�1���������E�1�a�0�1�s�BD'�A#D'�'-Ec�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�	DemuxConnz0A helper class for bup's client-server protocol.c��tj||�d}ttj�}|dk7r�tj|t|�dkxrdt|�z
xsd�}|s@td�}t|�5|j|�|j�ddd�||z
}|j|dd�|dd}|dk7r��|j�||_d|_
d|_d|_y#1swY�ZxYw)Nr!sBUPMUXr`r�z+demux: unexpected EOF during initializationi����F)r;r.rr}r�rmrPr�rKrrur�infd�readerrw�closed)r-r�r?�tailr��b�exs       r"r.zDemuxConn.__init__Us������$��%����S�Z�Z�(���i������s�4�y�1�}�?�1�S��Y�;�D�1�E�A���J�K��"�2�&�#��L�L��&��L�L�N�#�
�A�I�D��L�L��c�r��#����9�D��i��	������	����������#�#�s�"D�D	c�R�|jd�tj||�yr[)�	_load_bufr;rurUs  r"ruzDemuxConn.writels�����q�����t�T�"r!c��|jrytj|jggg|�\}}}|sy|d|jk(sJ�djt	|jd��}tjd|�\}}|tkDrh|tj|jd�z
}ttj�}|j|�|j�td��|dk(rt	|j|�|_y|d	k(rDt	|j|�D]*}	ttj�j|	��,y|d
k(rd|_t#d�y)
NFrr!�r}r~zConnection brokenr�r�rTzDemuxConn: marked closed
)r�rtr�r�r{r��unpackr�rmrPrr}r�rurr�r�r�)
r-�timeoutrdrvrwrVry�fdwr�rws
          r"�_next_packetzDemuxConn._next_packetps;���;�;�u��]�]�D�I�I�;��B��@�
��B���%��!�u��	�	�!�"�!�
�X�X�n�T�Y�Y��2�
3�����u�b�)���3��z�>��"�'�'�$�)�)�T�*�*�B� ����,�F��L�L����L�L�N��/�0�0��!�8�(����A�6�D�K��
�A�X�%�d�i�i��3�
3���C�J�J�'�-�-�c�2�
3�
��A�X��D�K��/�0�r!c��|j�y|jsG|js|j|�sy|js�	t	|j�|_yy#t
$r
d|_YnwxYw|js�k�%)NTF)rwr�r�r�r�r�)r-r�s  r"r�zDemuxConn._load_buf�sv���8�8����+�+��k�k��(�(��1� ��k�k�
#�����,������!�
#�"���
#���+�+�s�A"�"A5�4A5c#�DK�|jd�r�|j�J�||j�}|�|t|j�k(r|j}d|_n#|jd|}|j|d|_|��|�y|jd�r��yy�wr$)r�rwr�)r-�ix_fnr
�yvs    r"�_read_partszDemuxConn._read_parts�s������n�n�T�"��8�8�'�(�'��d�h�h��A��y�A��T�X�X��.��X�X������X�X�b�q�\���8�8�A�B�<����H��}���n�n�T�"�s�BB �B c�H�d�}dj|j|��S)Nc�J�	|jd�dzS#t$rYywxYw)Nrdr�)�index�
ValueError)rws r"�find_eolz%DemuxConn._readline.<locals>.find_eol�s-��
��y�y��'��)�)���
��
�s��	"�"r!�r�r�)r-r�s  r"rRzDemuxConn._readline�s#��	�
�x�x��(�(��2�3�3r!c�T��|g��fd�}dj|j|��S)Nc�^��t|��dkr�dxxt|�zcc<y�dSr[r�)rw�csizes �r"�
until_sizez#DemuxConn._read.<locals>.until_size�s1����3�x�%��(�"��a��C��H�$����Q�x�r!r!r�)r-r3r�r�s   @r"rNzDemuxConn._read�s+������	 ��x�x��(�(��4�5�5r!c�$�|jd�Sr[)r�r0s r"rXzDemuxConn.has_input�s���~�~�a� � r!N)rrrrr.rur�r�r�rRrNrXr r!r"r�r�Ss-��:��.#��0��4�6�!r!r�c#�BK�	|j�}|sy|dd����w)zEGenerate a list of input lines from 'f' without terminating newlines.NrB)re)rgrjs  r"rara�s*����
��z�z�|�����3�B�i��	�s�c#��K�|dk7rJ|dkDrD|jt|d��}|std|z��|��|t|�z}|dkDr�Cyy	|jd�}|sy|����w)z�Generate a list of chunks of data read from 'f'.

    If count is None, read until EOF is reached.

    If count is a positive integer, read 'count' bytes from 'f'. If EOF is
    reached while reading, raise IOError.
    NrizEOF with %d bytes remaining)rP�minrKr�)rgr�r�s   r"�chunkyreaderr��s{����
��}��a�i����s�5�%�(�)�A���;�e�C�D�D��G��S��V�O�E��a�i�����u�
�A��e��G��s�A
A,�A,c�&�eZdZdd�Zd�Zd�Zd�Zy)�atomically_replaced_filec�t�d|vsJ�||_||_||_d|_d|_t�|_y)acReturn a context manager supporting the atomic replacement of a file.

        The context manager yields an open file object that has been
        created in a mkdtemp-style temporary directory in the same
        directory as the path.  The temporary file will be renamed to
        the target path (atomically if the platform allows it) if
        there are no exceptions, and the temporary directory will
        always be removed.  Calling cancel() will prevent the
        replacement.

        The file object will have a name attribute containing the
        file's path, and the mode and buffering arguments will be
        handled exactly as with open().  The resulting permissions
        will also match those produced by open().

        E.g.::

          with atomically_replaced_file('foo.txt', 'w') as f:
              f.write('hello jack.')

        ryFN)rqr��	buffering�canceled�tmp_pathr�cleanup)r-rqr�r�s    r"r.z!atomically_replaced_file.__init__�s<��,�d�{��{���	���	�"�����
���
� �{��r!c���|j5tjj|j�\}}|jj	t||dz���}|dz|_t|j|j|j��}|jj	|�}|jj�|_|cddd�S#1swYyxYw)N�-)r�prefixs/pending)r�r�)r�rmrqr�
enter_contextr?r��openr�r��pop_all)r-�parentr�tmpdirrgs     r"r1z"atomically_replaced_file.__enter__�s���
�\�\�	��7�7�=�=����3�L�F�D��\�\�/�/��V�@D�t��1M�N�F�"�[�0�D�M��T�]�]����d�n�n�M�A����*�*�1�-�A��<�<�/�/�1�D�L��	�	�	�s�CC�C'c��|j5|js,|s*tj|j|j
�ddd�y#1swYyxYwr$)r�r�rm�renamer�rqr3s    r"r7z!atomically_replaced_file.__exit__s=��
�\�\�	4��M�M�X��	�	�$�-�-����3�	4�	4�	4�s�9A�Ac��d|_yrA)r�r0s r"�cancelzatomically_replaced_file.cancels	����
r!N)ryrB)rrrr.r1r7r�r r!r"r�r��s��#�:	�4�r!r�c�Z�t|t�sJ�|r|jd�s|dzS|S)z2Append "/" to 's' if it doesn't aleady end in "/".�/)r�r�rfr�s r"�slashappendr�	s.���a���������D�!��4�x���r!c���|s/tj|j��}|j}|syt	j
|j�|||�}|r|j
�|S)Nr�)rm�fstatr��st_sizer�mmaprC)rgrz�flags�protrCrr�s       r"�_mmap_dor�sU��
�
�X�X�a�h�h�j�
!��
�Z�Z��
��
�'�'�!�(�(�*�b�%��
.�C��	���	��Jr!c�X�t||tjtj|�S)zpCreate a read-only memory mapped region on file 'f'.
    If sz is 0, the region will cover the entire file.
    )r�r��MAP_PRIVATE�	PROT_READ�rgrzrCs   r"�	mmap_readr�!s!���A�r�4�+�+�T�^�^�U�C�Cr!c�z�t||tjtjtjz|�S)zqCreate a read-write memory mapped region on file 'f'.
    If sz is 0, the region will cover the entire file.
    )r�r��
MAP_SHAREDr��
PROT_WRITEr�s   r"�mmap_readwriter�(s-���A�r�4�?�?�D�N�N�4�?�?�,J���r!c�z�t||tjtjtjz|�S)z�Create a read-write memory mapped region on file 'f'.
    If sz is 0, the region will cover the entire file.
    The map is private, which means the changes are never flushed back to the
    file.
    )r�r�r�r�r�r�s   r"�mmap_readwrite_privater�0s/���A�r�4�+�+�T�^�^�D�O�O�-K���r!�mincore�MINCORE_INCOREc�J�d}t}t|krt|tzz}|ay)Ni)�sc_page_size�_fmincore_chunk_size)�pref_chunk_size�
chunk_sizes  r"�_set_fmincore_chunk_sizer�@s)��*��!�
��?�*�%��L�)H�I�J�)�r!c
�V�tj|�}|jdk(rtd�Sts
t�ttz}|jtzdz
tz}|jtzdz
tz}t|�}t|�D]p}t|z}tt|j|z
�}	tj||tjdd|�}	|	5	t!|	|d|||z�	ddd��r|S#tj$r9}
|
jtjtjfvrYd}
~
y|
�d}
~
wwxYw#t"$r1}
|
jtj$k(rYd}
~
ddd�y�d}
~
wwxYw#1swY��xYw)z�Return the mincore() data for fd as a bytearray whose values can be
        tested via MINCORE_INCORE, or None if fd does not fully
        support the operation.rr�N)rmr�r��	bytearrayr�r�r��ranger�rr�r�r^rL�EINVAL�ENODEV�_mincorero�ENOSYS)rOr�pages_per_chunk�
page_count�chunk_countrE�ci�pos�msize�mr�s           r"�fmincorer�Hsv���X�X�b�\���J�J�!�O��Q�<��#�$�&�.�,�>���j�j�<�/�!�3��D�
��z�z�$8�8�1�<�AU�U���:�&����$�	�B�&��+�C��,�b�j�j�3�.>�?�E�
��G�G�B��t�'7�'7��A�s�C���
���Q��q�&�"��2F�G�
�
�	�"�
���:�:�
��8�8����e�l�l�;�;�����	
�����x�x�5�<�<�/�#�
�
�����
�
�sT�(D�1F�3E!�E�%,E�E�E�!	F�*F�F�F�F�F�F(	c���ddddd�}tjd|�}|s+tjd|�rtd��t��|jdd	�\}}|sd}t	|�}|||zS)
z�Return the number of nanoseconds since the epoch that are described
by epoch_str (100ms, 100ns, ...); when epoch_str cannot be parsed,
throw a ValueError that may contain additional information.iʚ;i@Bi�r�)r��ms�usrVz ^((?:[-+]?[0-9]+)?)(s|ms|us|ns)$z^([-+]?[0-9]+)$z*must include units, i.e. 100ns, 100ms, ...r�)r\r�r��groupr0)�	epoch_str�ns_perr�ry�unitss     r"�parse_timestampr�is��� �����F�
�H�H�8�)�D�E��
�8�8�&�	�2��I�J�J��l�����Q��"�J�Q���
���A��A��v�e�}��r!c��t|t�r|jd�}tjdt|��}|st
d|z��|j�\}}t|�}|j�}|dvrd}n-|dvrd}n&|dvrd	}n|d
vrd}n|dvrd
}nt
d|�d|����t||z�S)z�Parse string or bytes as a possibly unit suffixed number.

    For example:
        199.2k means 203981 bytes
        1GB means 1073741824 bytes
        2.1 tb means 2199023255552 bytes
    �asciiz([-+\d.e]+)\s*(\w*)zcan't parse %r as a number)�trGl)�g�gbi@)r��mbi)r�kbr~)r�r�r�z
invalid unit z in number )r�r��decoder\r�r�r�rr/�lowerr0)r�r��valr4�num�mults      r"�	parse_numr}s����!�U��
�H�H�W���
���'��Q��0�A���5��9�:�:��(�(�*�K�S�$�
��*�C��:�:�<�D��{��"��	
��	���	
��	���	
��	���	
��	����4��C�D�D��s�4�x�=�r!c�J�tj|�td|z�y)z�Append an error message to the list of saved errors.

    Once processing is able to stop and output the errors, the saved errors are
    accessible in the module variable helpers.saved_errors.
    z%-70s
N)�saved_errors�appendr�)rPs r"�	add_errorr�s��������	�A�
�r!c��gayr$)rr r!r"�clear_errorsr�s���Lr!c�z�tr5|sdtt�z}t|�tj|�yy)Nzwarning: %d errors encountered
)rr�r�r}�exit)�msg�statuss  r"�
die_if_errorsr�s/����4�s�<�7H�H�C��C�������	r!c�F��tj��fd�}|t_y)z�Replace the default exception handler for KeyboardInterrupt (Ctrl-C).

    The new exception handler will make sure that bup will exit without an ugly
    stacktrace when Ctrl-C is hit.
    c�D��|tk(rtd�y�|||�y)Nz
Interrupted.
)�KeyboardInterruptr�)�exctyper'r6�oldhooks   �r"�newhookzhandle_ctrl_c.<locals>.newhook�s!����'�'��"�#��G�U�I�.r!N)r}�
excepthook)rrs @r"�
handle_ctrl_cr�s����n�n�G�/�
�C�Nr!c�J���t|t�}|rdnd}|rdnd}|s|S|dd}td�|D���t�t	|�z
�dzz}|dkrd}d	�g}t	|�|zr |j|�t	|�|zr� t	|�|z}t
d	t	|�|�D]}|j||||z��g}	|rd
nd�t|�D]2}
|	j||j��fd�|
D��z|z��4|j|	�S)
z�Format elements of 'l' in columns with 'prefix' leading each line.

    The number of columns is determined automatically based on the string
    lengths.
    r!r�rd�
Nc3�2K�|]}t|����y�wr$r�)r�r�s  r"r�zcolumnate.<locals>.<genexpr>�s����!�!�s�1�v�!�r�r�r�rs%-*sz%-*sc3�2�K�|]}��dz|fz���y�w)r�Nr )r�r��clen�fmts  ��r"r�zcolumnate.<locals>.<genexpr>�s�����(J��#��a����*;�(J�s�)	r�r��max�	tty_widthr�rr��zipr�)
�lr��binary�nothing�nl�ncols�cols�rowsr�r��rowrrs
           @@r"�	columnater&�s-������
&�F��c��G���d�B����	�!��A��!�q�!�!�D�
�[�3�v�;�
&�D�1�H�5�E���z�����
�D�

�a�&�5�.�	������a�&�5�.��q�6�U�?�D�
�1�c�!�f�d�
#�!�����A�a��$��K� �!�
�C��'��C��D�z�Q���
�
�6�G�L�L�(J�c�(J�J�J�R�O�P�Q��<�<���r!c�V�	t|�}|S#t$r}|d|z��d}~wwxYw)zdParses the given date or calls Option.fatal().
    For now we expect a string that contains a float.z+invalid date format (should be a float): %rN)r/r�)r��fatal�daterPs    r"�parse_date_or_fatalr*�s<����S�z������G��A�A�E�F�F��G�s��	(�#�(c��g}|D]�}|\}}|dk(r$|jtt|����1|dk(s�7	ttt|��d�}|j�D]/}t|j
��}|s�|j|��1��tt|��S#t$r}|d|z��d}~wwxYw)zFTraverse the options and extract all excludes, or call Option.fatal().z	--excludez--exclude-from�rb�couldn't read %rN)	rrrr�rK�	readlines�strip�sorted�	frozenset)	�optionsr(�excluded_paths�flag�option�	parameterrgrP�exclude_paths	         r"�parse_excludesr8�s����N��
8��"�����[� ��!�!�.��I�1F�"G�H�
�'�
'�
<���
�9�(=�>��E��!"���
�
8��-�l�.@�.@�.B�C���"�)�)�,�7�	
8�
8��)�N�+�,�,���
<��.��:�;�;��
<�s�B3�3	C�<C�Cc	�N�g}|D]�}|\}}|dk(r/	|jtjt|����<|dk(s�B	tt
|�d�}|j�D];}	|	jd�}
|
s�	|jtj|
���=��|S#tj$r}|d|�d|���Yd}~��d}~wwxYw#t$r}|d|z��d}~wwxYw#tj$r}|d|
�d|���Yd}~��d}~wwxYw)	zMTraverse the options and extract all rx excludes, or call
    Option.fatal().z--exclude-rxzinvalid --exclude-rx pattern (z): Nz--exclude-rx-fromr,r-rd)
rr\�compilerr^r�rrKr.�rstrip)r2r(�excluded_patternsr4r5r6r�rgrP�pattern�spatterns           r"�parse_rx_excludesr?s3�����T��"�����^�#�
Q�!�(�(����J�y�4I�)J�K��*�
*�
<���	�2�D�9���;�;�=�
T��"�>�>�%�0����T�%�,�,�R�Z�Z��-A�B�
T�T�(����8�8�
Q���B�O�P�P��
Q��
�
<��.��:�;�;��
<���x�x�T��X�r�R�S�S��T�sG�-B/�C�$C9�/C�C�C�	C6�&C1�1C6�9D$�D�D$c�p�|D]1}|j|�s�td|�d|j�d��yy)z@Return True if path matches a regular expression in exclude_rxs.z	Skipping z: excluded by rx pattern z.
TF)�searchr�r=)rq�exclude_rxs�rxs   r"�should_rx_exclude_pathrD s:�����
�9�9�T�?���B�J�J�(�
)��	�
r!c��|jd�stdt|�z��dg}tjj|�}|dk(r|Sd}|j
d�ddD]}|d|zz
}|j||f��|S)z�Break path into a list of pairs of the form (name,
    full_path_to_name).  Path must start with '/'.
    Example:
      '/home/foo' -> [('', '/'), ('home', '/home'), ('foo', '/home/foo')]r�zpath must start with "/": %s)r!r�r!r�N)rbr�rrmrq�abspathrr)rqrE�	norm_path�	full_pathr�s     r"�path_componentsrI2s���
�?�?�4� ��6��$��G�H�H��]�F�������%�I��D���
��I�
�_�_�T�
"�1�2�
&�&���T�A�X��	��
�
�q�)�n�%�&��Mr!c��tjj|�}t|td��}|D]�}tjj|�}|dk(r�(|j|�s�:|dt	|�}g}|t	|�dj
d�D]!}|r|dz
}||z
}|j||f��#|cSt|�S)z�Strip any prefix in strip_prefixes from path and return a list
    of path components where each component is (name,
    none_or_full_fs_path_to_name).  Assume path startswith('/').
    See thelpers.py for examples.T)r��reverser�N)	rmrqrFr0r�rbrrrI)	rq�strip_prefixes�normalized_path�sorted_strip_prefixes�bp�
normalized_bpr�rEr�s	         r"�stripped_path_componentsrQEs���
�g�g�o�o�d�+�O�"�>�s�D�I��#���������+�
��D� ���%�%�m�4�$�%8�c�-�&8�9�F��F�$�S��%7�%8�9�?�?��E�
+����d�N�F��!����
�
�q�&�k�*�	
+�
�M���4� � r!c���tjj|�}|D�]3}|\}}tjj|�}tjj|�}|j	|�s�Ytj|�}tjd|z||�}d|jd�z}t|�}|dk(rdn|jd�}	|jd�}
|jd�d|jd�}|D�cgc]}|df��c}||	dz}
t|�}|
d||	df|
|<|dk(r|
ddcS|
cSt|�Scc}w)N�^r�rrBr�)
rmrqrF�normpathrbr\�escaper]�lstriprIr�rr�)�graft_pointsrq�
clean_path�graft_point�
old_prefix�
new_prefix�escaped_prefix�grafted_path�clean_path_components�strip_count�new_prefix_parts�
result_prefixr�rEs              r"�grafted_path_componentsrb]ss��������&�J�#���!,��
�J��W�W�%�%�j�1�
��W�W�%�%�j�1�
�� � ��,��Y�Y�z�2�N��6�6�%�.�"8�*�j�Q�L��,�"5�"5�d�";�;�L�$3�J�$?�!�)�T�1�!�z�7G�7G��7M�K�)�/�/��5��(�.�.�t�4�5L�j�6F�6F�t�6L�M�M�)6�7�A�q�$�i�7�'���5�6�F��m�,�K�!�"�%�'<�[�'I�!�'L�M�
�;���T�!��a�b�z�!��M�/�0�:�&�&��8s�E$�	localtime�bup_time)�tm_year�tm_mon�tm_mday�tm_hour�tm_min�tm_sec�tm_wday�tm_yday�tm_isdst�	tm_gmtoff�tm_zonec	�\�ttjtt	|����Sr$)rdrrcr0r	)r�s r"rcrc�s!����+�+�C��d��,<�=�>�>r!c��t|�j}t|�dz}|dz}||z
dz}d|dkr||fzS||fzS)z�Return the local offset from UTC as "+hhmm" or "-hhmm" for time t.
        If the current UTC offset does not represent an integer number
        of minutes, the fractional component will be truncated.�<s	%+03d%02dr)rcrn�abs)r��off�offminr��hs     r"�utc_offset_strrw�s\����l�$�$���S��R����R�K��
�a�Z�B����S�1�W��r�Q�7�7�7�!�Q�7�7�7r!c�j�t|tj�r|Stj|dd�S)N�	)r�r��struct_timer:s r"�
to_py_timer{�s.���a��)�)�*��H�����"�1��&�&r!c�@�tjdt|��S)Ns%z)r��strftimerc)r�s r"rwrw�s���}�}�U�I�a�L�1�1r!c��|Sr$r r:s r"r{r{�s���r!s[\[ ~^:?*\\]|\.\.|//|@{c�`�|dk(s3|jd�s"|jd�s|jd�rytj|�ry|D] }t	|�dkst	|�dk(s� y|jd�D]&}|jd�s|jd�s�&yy)	N�@r��.F� �s.lockT)rbrf�_some_invalid_save_parts_rxrArr)rr�parts   r"�valid_save_namer��s����t�|�
�/�/�$�
�4�=�=��#6�
�-�-��
��"�)�)�$�/��
����A�;����!���!4����
�
�4� ����?�?�4� �D�M�M�(�$;���r!s^([0-9]+)(s|min|h|d|w|m|y)$c	���|dk(rtd�Stj|�}|syt|j	d��}|j	d�}|dddddd	d
d�|zS)Nsforever�infr�r�rrii�Qi�:	i��(i��)�ssmin�h�d�w�m�y)r/�
_period_rxr�r0r�)r�r��mag�scales    r"�period_as_secsr��sx���J���U�|�����Q��E���

�e�k�k�!�n�
�C��K�K��N�E�����$�(�)�*�
,�-2�
3�3�3r!r$)NNNFTNTr=)rTr�)�r�
__future__rr�collectionsr�
contextlibr�ctypesrrr1r	rmr
�
subprocessrr�tempfiler
�shutilrr}rLrtr�rnr\r��hashlibr�r�r��buprr�
bup.compatrrrr�bup.iorr�bup.optionsrrr0�getr�rr&r(r?�sysconfr��
sc_arg_maxrFrQrN�AttributeError�fsync�platformrbrIr^rbrkrrr{r�r�r�r��isatty�istty1r�r�r�r�r�r�r�r�r�r:r�r�r�r�r�r��
check_call�excr�r�rrr
rrr r(r*r,r7r�r9r;rpr{r�r�r�rar�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr&r*r8r?rDrIrQrb�sha1�Sha1�
_localtimerdrcrwr{r�r�r�r�r r!r"�<module>r�s��+�0�"� �#���"���A�A�A�A�A�+�+�+���G�G�(�0�

�R�Z�Z�^�^�K��
+�	,��	�	�
=�)�)�D��r�z�z�.�)���a����
�R�Z�Z��
%�
�
��� �J������J��<�<���8�$����I�'�.�����
���
�

����1��	F�#�b�j�j�n�n�_�a�@�A�A�E��	����1��	F�#�b�j�j�n�n�_�a�@�A�A�E�����	�!��$$�$��>
��2�:�:�4�5���2�:�:�3�4��1�.��@�$������������.<�
�<�)-�j�B�,�*,�
�<�<���8�$�,�
!��&
�	��E�	�I�	�N'�N'�b�8��(��
�2�$d!��d!�N��,-�-�`��D����8�Y��-����X�'7��;�N���*��B�(�B����
���<�-�*�8�$�&!�0('�V�|�|���X�{�D�
1�
�
��*�'K�L�H��?�	8�'�
���I�2��)�b�j�j�)D�E���"�R�Z�Z�7�
8�
�3��#�����J��s�N�N�N

Youez - 2016 - github.com/yon3zu
LinuXploit