Ñò i'dWc@s[dZddkZddkZddkZddkZddkZddkZddkZddkZddk l Z ddk l Z l Z lZlZlZlZddklZddklZdZdZd Zd Zd Zd Zd ZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'd„Z(d„Z)d„Z*d„Z+d„Z,dS(sF Utility functions for managing sysconfig configurations for archives iÿÿÿÿN(tetree(tPopentrunt SetUIDasEUIDtCalledProcessErrortSYSTEM_TEMP_DIRt_(t ArchiveError(tINSTALL_LOGGER_NAMEs/usr/sbin/chroots/usr/bin/getents /usr/bin/greps/usr/sbin/netadms/usr/bin/passwds/usr/bin/pgreps /usr/bin/pss /usr/bin/rms/usr/sbin/rolemods/usr/sbin/routes/usr/sbin/svccfgs/lib/svc/bin/svc.configds/usr/bin/svcprops/usr/bin/userattrs/usr/sbin/userdels /usr/sbin/zfss$etc/sudoers.d/svc-system-config-usercCsMtitƒ}|idƒtitii|dƒƒ}tii|dƒ}||jo¿titii|dƒƒ}xƒ|D]’}ti |ƒ}ti ddƒ}d|_ |i ƒi d|ƒxÒ|i ƒid ƒD]»} | id } g} |D]$} ti| | ƒo | | qûqû~ } | oi|i| dƒti dd | ƒ}d|_ | iƒi d |ƒ| iƒi| ƒ|pPq˜qÝqÝWtiƒ}|d jo d}nt|dƒiiƒ}z5|~}|iti|dtd|dtƒƒWdQXqWnæhtii|dƒd6}h}xG|D]?} y#td| dddddg}t|d|ƒ}|io¨| idƒd i dƒ}|ii ƒidƒ}xq|D]e}|i dƒ}||jo|i!|gƒi"|ƒqÂ|||jo||i"|ƒqÂqÂWnt#ƒiiƒz&td| dg}t|d|ƒWdQXWqDt$j oqDXqDWxv|i%ƒD]h\}}tii||ƒ}tii&|ƒpq”q”ti |ƒ}ti ddƒ}d|_ |i ƒi d|ƒxœ|i ƒid ƒD]…} | id } | |joe|i| ƒti dd | ƒ}d|_ | iƒi d |ƒ| iƒi| ƒ|pPqªq%q%Wt|dƒiiƒ}z/|~}|iti|dtdtƒƒWdQXq”Wd}y t'i(tii||ƒƒWnt)j onX|id ƒdS(!s;Function to clean up the smf site-profile and admin layers.sPurging SMF layers.s etc/svc/*setc/svc/repository.dbsetc/svc/profile/site/*.xmlttexts‰This file has been touched by archiveadm(1m) during archive creation. Entries for Oracle Solaris system configuration have been removed.s itservicetnames5The smf service %s has been removed by archiveadm(1m)it646sUS-ASCIIsw+txml_declarationtencodingt pretty_printNtSVCCFG_REPOSITORYs-stlistprops-ls site-profiles-otfiletenvt:t/tdelcustsetc/svc/profile/sysconfig/sPurginig SMF layers completed.(*tloggingt getLoggertILNtdebugtglobtostpathtjoinRtparsetCommentttailtgetroottinserttfindalltattribtretsearchtremovet getparenttlocaletgetpreferredencodingtopent__exit__t __enter__twritettostringtTruetSVCCFGRtstdouttsplittstript setdefaulttappendRRt iteritemstexiststshutiltrmtreetOSError(taltroottservicestloggertetc_svc_contentstsmf_repotprofilest site_profilettreet archCommentt smf_servicetsvc_namet_[1]txR t svcCommentRt_[2]tfhRtsvcs_in_site_layertcmdtpt config_svctprofilet_[3]tsysconfig_path((s../sysconfig_util.pytcleanup_smf_layers?s®     8       &            & c Cs[titƒ}|idƒtitii|dƒƒ}tii|dƒ}||joûhtii|dƒd6}xÜ|D]Ð}y´td|ddg}t |d|ƒ}|i o|i i ƒ} t | ƒd joY| d d joHt ƒiiƒz-td|d | d g}t |d|ƒWdQXq8nWqtj oqXqWndS(sRFunction to clean up scheduling data for periodic and scheduled services. s)Purging Periodic Service Scheduling Data.s etc/svc/*setc/svc/repository.dbRs-stlistpgtperiodic_restarterRiit frameworktdelpgiN(RRRRRRRRR2RR3R4tlenRR-R.R( R=t instancesR?R@RARtinstanceRNtproctvalues((s../sysconfig_util.pytcleanup_periodic_servicesÆs(   $"c #Csýtitƒ}d}titii|dƒƒ}tii|dƒ}||jo|Shtii|dƒd6}tdddddd g}yt |d |ƒ}Wn!t j o|i d ƒ|SX|i i ƒ}|oH|d jo;tƒiiƒz%t|td |g}t |ƒ}WdQX|i i ƒidƒd}tƒiiƒzqy&t|tdd|g}t |ƒWnDtj o8} |i d| ƒ|i dƒttdƒƒ‚nXWdQXtƒiiƒz@tii|tƒ} yti| ƒWntj onXWdQXn|i dƒtƒiiƒzlt|tddg}y0t |ƒt|tdddg}t |ƒWn t j o|i dƒnXWdQXtƒiiƒz)t|tddddg}t |ƒWdQX|S(s\Function to delete the sysconfig admin user and root account file from the archive. s etc/svc/*setc/svc/repository.dbRs-sssvc:/system/config-userRs-otvaluesconfigured_user/loginRs-A config-user is not configured in this zone.s""tpasswdNRis-Stfiless%ss&Please add the required authorization.sEThe archive operation requires the solaris.user.manage authorization.sNo sysconfig user to deletettypetroots-Ks type=normals!Root is not configured as a role.s-rs-d(RRRtNoneRRRRR2RRRR3R5RR-R.tCHROOTtGETENTR4tUSERDELtAttributeErrorRRtETC_SUDOERS_FILER(R<tUSERATTRtROLEMODtPASSWD( R=R?thomedirR@tsmf_repRRNROt login_nametaetsudoers((s../sysconfig_util.pytcleanup_config_user_rootès`      c CsÇtitƒ}|idƒdddddddd d d d d dg }xj|D]b}tii||ƒ}ti|ƒ}x5|D]-}yti|ƒWqt j oqXqWqPW|idƒdS(sPFunction to perform network configuration cleanup on the clone archive. sClean up network configuration.svar/dhcp/*.dhcsvar/dhcp/*.dh6s var/dhcp/duids var/dhcp/iaidsetc/dhcp/*.dhcsetc/dhcp/*.dh6s etc/dhcp/duids etc/dhcp/iaidsetc/defaultroutersetc/inet/static_routes-*s var/ldap/*setc/defaultdomainsetc/resolv.confs)Clean up network configuration completed.N( RRRRRRRRR(R<(R=R?tnetwork_rm_filestnw_filet alt_nwfiletpathstnw_path((s../sysconfig_util.pytcleanup_network_config4s*   cCsVtitƒ}|idƒtitii|dƒƒ}tii|dƒ}dddg}||joptƒ}t i dddd ƒ\}}t i dtii|t i d ƒƒƒ} h|d 6} t|td |d dg} t| d| ƒ} | iƒxª|D]¢} ygt|td| ddddddg } t| d| ƒ}|ii ƒo|i|ii ƒƒnWqtj o&}|id|ƒ|idƒqXqWx·|D]¯}tii|ƒ\}}tii| |i d ƒƒ}tiitii|ƒƒptitii|ƒƒntitii||i d ƒƒtii||ƒƒq´Wt|tdg} yt| dtid| ƒWn7tj o+}|id|ƒttdƒƒ‚nXtdd|g} t| ƒ}|ii ƒ}yti t!|ƒt"i#ƒWn7t$j o+}|id|ƒttdƒƒ‚nXybti t!|ƒdƒti%t!|ƒti&ƒ\}}|djottd |ƒƒ‚nWnt$j onXtii|d!ƒ}tii|ƒo%tii'|ƒ oti(|ƒnx{|D]s}tii|ƒ\}}tii||i d ƒƒ}titii| |i d ƒƒtii||ƒƒq!Wti)|ƒti*tii||i d ƒƒƒti*|ƒng}|D]}|tii||ƒqæ~}tt+|ƒt+|ƒƒ}x|D]}ti*|ƒq.W|id"ƒd#S($sÜFunction to remove all data from the smf repository for the services that are managed by sysconfig. First, the manifests for the services are saved off to a temporary location, then svccfg cleanup is run to remove all data for the services from the SMF repository. Finally, copy the manifests back to the /lib/svc/manifest directory so that they will be imported on first boot as a new service. As part of this process, a svc.configd daemon is activated for the archive repository path. This needs to be killed, once the repository has been cleaned up. Finally, remove everything from the /etc/svc/ directory except for repository.db, the profile directory, and the volatile directory. sPurging SMF repository.s etc/svc/*setc/svc/repository.dbsetc/svc/profilesetc/svc/volatiletdirs/tmptprefixtrepository_door_Rt SVCCFG_DOORs-ds-rs/etc/svc/repository.dbRs-sRs-ltmanifests-oRssysconfig/groups%ss%Service does not exist for this zone.tcleanupt check_resultsUFailed to clean up services. This operation required for successful archive creation.s-fs/lib/svc/bin/svc.configd -d %ss~Failed to clean up an archive process. This may leave the archive database is in an unknown state. Please retry the operation.is*Unable to kill svc.configd daemon (pid %s)sdev/nullsSMF repository purge completed.N(,RRRRRRRRtlistttempfiletmkstemptmkdtempRR5Ret SVCCONFIGDRtwaitR2RR3R7RR4R9tmakedirsR:tmovetANYRRtPGREPtkilltinttsignaltSIGTERMR<twaitpidtWNOHANGtislinktunlinktcloseR(tset(R=R>R?R@Rnt saved_etc_svct manifeststfdesct repo_tempdirtmanifest_tempdirRRNtsubproc1R ROtcpeR}tmdirtmfiletmdesttsubproc3tpidtoet killedpidt_statustfnullRHRIt cleanup_listtcu_file((s../sysconfig_util.pytpurge_smf_repositoryRs˜        !  !  '! %0(-t__doc__RR*RRR&R:RŒRtlxmlRtsolaris_installRRRRRRtsolaris_install.archive.utilRtsolaris_install.loggerRRReRftGREPtNETADMRlR‰tPStRMRktROUTER2R„tSVCPROPRjRgtZFSRiRTR^RrRxR¦(((s../sysconfig_util.pytsD        . ‡ " L