PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  #^c@@s ddlmZddlZddlZddlZddlZddlZddlZejrtddl m Z nddl m Z ddl m Z ddlmZejreZnejeZejZdZdZd efd YZd efd YZdS( i(tabsolute_importN(t ConfigParser(tSafeConfigParser(ttasks(tpathsssysrestore.indexssysrestore.statet FileStorecB@sheZdZeedZdZdZdZdZ d dZ dZ dZ d ZRS( s.Class for handling backup and restore of filescC@sJ||_tjj|j||_tj|_i|_|jdS(sCreate a _StoreFiles object, that uses @path as the base directory. The file @path/sysrestore.index is used to store information about the original location of the saved files. N( t_pathtostpathtjoint_indextrandomtRandomtfilest_load(tselfRt index_file((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt__init__;s   cC@stjd|ji|_t}t|_|j|jxP|jD]B}|dkrKx-|j |D]\}}||j| no files, removing fileNR tw(RRR tlenR RRtexiststremoveRRRt add_sectionRtsettopentwrite(RRRRtf((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pytsave]s    c C@sMtjd|tjj|s1tdntjj|sWtjd|dStjj|\}}d}x7tdD])}d|j j dd }||7}qW|d |7}tjj |j |}tjj |rtjd |dStj||tj|}d } | jd |d||j|<|jdS(sCreate a copy of the file at @path - so long as a copy does not already exist - which will be restored to its original location by restore_files(). s)Backing up system configuration file '%s'sAbsolute path requireds( -> Not backing up - '%s' doesn't existNtis%02xiit-s1 -> Not backing up - already have a copy of '%s's1{stat.st_mode},{stat.st_uid},{stat.st_gid},{path}tstatR(RRRRtisabst ValueErrortisfiletsplittrangeR trandintR RRtshutiltcopy2R)tformatR R&( RRt_reldirt backupfiletfilenamet_itht backup_pathR)ttemplate((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt backup_filess, c C@s^t}xQ|jjD]@\}}|jdd\}}}}||krt}PqqW|S(sChecks whether file at @path was added to the file store Returns #True if the file exists in the file store, #False otherwise t,i(tFalseR RR-tTrue( RRtresultt_keyRt_modet_uidt_gidtfilepath((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pythas_files c C@s|d krtjd|ntjd||tjj|sStdn|d k rtjj| rtdnd }d }d }d }xQ|jjD]@\}}|j dd\}}}} | |kr|}PqqW|stdntjj |j |} tjj | s@tjd| t S|d k rU|}ntj| |tj| tj|t|t|tj|t|tj||j|=|jtS( s<Restore the copy of a file at @path to its original location and delete the copy. Takes optional parameter @new_path which specifies the location where the file is to be restored. Returns #True if the file was restored, #False if there was no backup file to restore s(Restoring system configuration file '%s's0Restoring system configuration file '%s' to '%s'sAbsolute path requiredsAbsolute new path requiredR;isNo such file name in the indexs' -> Not restoring - '%s' doesn't existN(tNoneRRRRR*R+R RR-R RRR<R0tcopyR tchowntinttchmodRtrestore_contextR&R=( RRtnew_pathtmodetuidtgidR5RRRCR8((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt restore_filesF             cC@s t|jdkrtSx|jjD]\}}|jdd\}}}}tjj|j|}tjj |st j d|q)nt j ||tj|tj|t|t|tj|t|tj|q)Wi|_|jtS(sRestore the files in the inbdex to their original location and delete the copy. Returns #True if the file was restored, #False if there was no backup file to restore iR;is' -> Not restoring - '%s' doesn't exist(RR R<RR-RRR RRRRR0RFR RGRHRIRRJR&R=(RR5RRLRMRNRR8((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pytrestore_all_filess"    cC@st|jdkS(sReturn True or False if there are any files in the index Can be used to determine if a program is configured. i(RR (R((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt has_filessc C@s6tjd|tjj|s1tdnd}xQ|jjD]@\}}|j dd\}}}}||krG|}PqGqGW|stdntjj |j |} tjj | stjd| t Sytj| Wn,tk r} tjd| t| nX|j|=|jtS( sRemove file at path @path from list of backed up files. Does not remove any files from the filesystem. Returns #True if the file was untracked, #False if there was no backup file to restore s)Untracking system configuration file '%s'sAbsolute path requiredR;isNo such file name in the indexs' -> Not restoring - '%s' doesn't existsError removing %s: %sN(RRRRR*R+RER RR-R RRR<tunlinkt ExceptionterrorRR&R=( RRR5RRR@RARBRCR8te((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt untrack_file s.     N(t__name__t __module__t__doc__tSYSRESTORE_PATHtSYSRESTORE_INDEXFILERRR&R:RDRERORPRQRV(((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyR8s   $ ; # t StateFilecB@s\eZdZeedZdZdZdZdZ dZ dZ dZ RS( sfA metadata file for recording system state which can be backed up and later restored. StateFile gets reloaded every time to prevent loss of information recorded by child processes. But we do not solve concurrency because there is no need for it right now. The format is something like: [httpd] running=True enabled=False cC@s/tjj|||_i|_|jdS(sCreate a StateFile object, loading from @path. The dictionary @modules, a member of the returned object, is where the state can be modified. @modules is indexed using a module name to return another dictionary containing key/value pairs with the saved state of that module. The keys in these latter dictionaries are arbitrary strings and the values may either be strings or booleans. N(RRR RtmodulesR(RRt state_file((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyRAs  cC@stjd|ji|_t}t|_|j|jx|jD]z}i|j| no modules, removing fileNR(RRRtlistR]RRRRR RRRR!RR"R#R$(RR_RRRR%((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyR&gs"     !cC@st|tttfs'tdn|j||jkrPi|j||jy|j||=Wntk r/n X|jdS(sDelete system state from @module, identified by the string @key. If the item doesn't exist, no change is done. N(RR]tKeyErrorR&(RR_R((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt delete_states   cC@s5|j||}|dk r1|j||n|S(s Return the value of an item of system state from @module, identified by the string @key, and remove it from the backed up system state. If the item doesn't exist, #None will be returned, otherwise the original string or boolean value is returned. N(RfRERh(RR_RR((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt restore_states  cC@s ||jkS(sReturn True or False if there is any state stored for @module. Can be used to determine if a service is configured. (R](RR_((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyt has_states( RWRXRYRZtSYSRESTORE_STATEFILERRR&RdRfRhRiRj(((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyR\4s       (t __future__RtloggingRtos.pathR0R tsixtPY3t configparserRRtipaplatform.tasksRtipaplatform.pathsRRRct getLoggerRWRtTMPRZR[RktobjectRR\(((s=/usr/lib/python2.7/site-packages/ipalib/install/sysrestore.pyts&