%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/utils/ |
Current File : //lib/python2.7/site-packages/salt/utils/crypt.pyc |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z e j e � Z d d l Z d d l Z d d l m Z y d d l Z e Z Wn e k r� e Z n Xe d d d d � Z d � Z d d d d � Z d S( u# Functions dealing with encryption i ( t absolute_importt print_functiont unicode_literalsN( t SaltInvocationErrorc C@ s� y: | r9 | | k r9 t d j | d j | � � � � n Wn8 t k rt } t | t � ra � n t j d | � n X| d k r� | d k r� t d � � n t j j | i � } n | j | � } | d k r� t d j | � � � n | | d | �S( u .. versionadded:: 2017.7.0 Decrypt a data structure using the specified renderer. Written originally as a common codebase to handle decryption of encrypted elements within Pillar data, but should be flexible enough for other uses as well. Returns the decrypted result, but any decryption renderer should be recursively decrypting mutable types in-place, so any data structure passed should be automagically decrypted using this function. Immutable types obviously won't, so it's a good idea to check if ``data`` is hashable in the calling function, and replace the original value with the decrypted result if that is not the case. For an example of this, see salt.pillar.Pillar.decrypt_pillar(). data The data to be decrypted. This can be a string of ciphertext or a data structure. If it is a data structure, the items in the data structure will be recursively decrypted. rend The renderer used to decrypt translate_newlines : False If True, then the renderer will convert a literal backslash followed by an 'n' into a newline before performing the decryption. renderers Optionally pass a loader instance containing loaded renderer functions. If not passed, then the ``opts`` will be required and will be used to invoke the loader to get the available renderers. Where possible, renderers should be passed to avoid the overhead of loading them here. opts The master/minion configuration opts. Used only if renderers are not passed. valid_rend A list containing valid renderers, used to restrict the renderers which this function will be allowed to use. If not passed, no restriction will be made. u@ '{0}' is not a valid decryption renderer. Valid choices are: {1}u , u+ Non-iterable value %s passed for valid_rendu opts are requiredu* Decryption renderer '{0}' is not availablet translate_newlinesN( R t formatt joint TypeErrort isinstancet logt errort Nonet saltt loadert rendert get( t datat rendR t rendererst optst valid_rendt exct rend_func( ( s4 /usr/lib/python2.7/site-packages/salt/utils/crypt.pyt decrypt s$ 0c C@ s t r t j j � n d S( u� When a fork arises, pycrypto needs to reinit From its doc:: Caveat: For the random number generator to work correctly, you must call Random.atfork() in both the parent and child processes after using os.fork() N( t HAS_CRYPTOt Cryptot Randomt atfork( ( ( s4 /usr/lib/python2.7/site-packages/salt/utils/crypt.pyt reinit_cryptog s u sha256c C@ s� | s{ t j j | � s d St j j j | d � �B } d j g | j � D] } | j � rJ | ^ qJ d d !� } Wd QXn t t | � | � j � } d } xL t | � D]>