Ñò ìÿÒXc @ sR d d k Z d d k Z d d k Z d d k Z d d k l Z d d k l Z d Z d Z d Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d d „ Z d „ Z d d d „ Z d d d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z e d j o7 e d d d d ƒ Z e e d ƒ Z e GHe e ƒ n d S( iÿÿÿÿN( t ipautil( t dogtags /var/lib/certmonger/requests/s /var/lib/certmonger/cas/i c C så d } d } t } xÌ | d j o¾ | d j o± | d } t i d ƒ t | d ƒ } | i ƒ } | i ƒ xn | D]f } | o' | i d ƒ p | S| | d } qr | i | d ƒ o t } | t | ƒ d } qr qr Wq W| S( s4 Return a value from a certmonger request file for the requested directive It tries to do this a number of times because sometimes there is a delay when ipa-getcert returns and the file is fully updated, particularly when doing a request. Generating a CSR is fast but not instantaneous. i i t rt t =N( t Nonet Falset timet sleept opent readlinest closet startswitht Truet len( t filenamet directivet triest valuet foundt fpt linest line( ( s8 /usr/lib/python2.6/site-packages/ipapython/certmonger.pyt find_request_value% s( !c C su t i t ƒ } x_ | D]W } t d t | f d ƒ } | d j o+ | i ƒ | j o t d t | f | ƒ Sq Wd S( s¢ There is no guarantee that the request_id will match the filename in the certmonger requests directory, so open each one to find the request_id. s %s/%st idN( t ost listdirt REQUEST_DIRR R t rstrip( t request_idR t fileListt fileR ( ( s8 /usr/lib/python2.6/site-packages/ipapython/certmonger.pyt get_request_valueG s c C s t | ƒ t j p t ‚ d } t i t ƒ } xê | D]â } t } x… | D]} \ } } } t d t | f | ƒ } | o# | t j o t i i | ƒ } n | d j p | i ƒ | j o t } PqI qI W| o | d j o t d ƒ ‚ n | o# t d t | f d ƒ i ƒ } q6 q6 W| S( s´ If you don't know the certmonger request_id then try to find it by looking through all the request files. An alternative would be to parse the ipa-getcert list output but this seems cleaner. criteria is a tuple of key/value/type to search for. The more specific the better. An error is raised if multiple request_ids are returned for the same criteria. None is returned if none of the criteria match. s %s/%ss/ multiple certmonger requests match the criteriaR N( t typet tuplet AssertionErrorR R R R R R t NPATHt patht abspathR R t RuntimeError( t criteriat reqidR R t matcht keyR t valtypet rv( ( s8 /usr/lib/python2.6/site-packages/ipapython/certmonger.pyt get_request_idU s&