ó ¸sWc@sÒdZddlmZddlmZddlZddlZddlZdefd„ƒYZdefd „ƒYZ d efd „ƒYZ d efd „ƒYZ defd„ƒYZ defd„ƒYZ dS(sNIS classes used by nscfg.iÿÿÿÿ(tprint_functioni(tNssbaseNt NisDomaincBsæeZdZdZdZdZdZdZdZdgZ ie d6e d6e d6Z dZ dZd Zd Zd ZdZdZdZd ZdZd ZdZdZdZdZd„Zd„Zd„Zd„Zd„Z d„Z!RS(s€Network Information Service (NIS) class. Represents the configuration of a NIS Domain. See defaultdomain(4) for details.ssvc:/network/nis/domainttconfigs3# See ypfiles(4) and defaultdomain(4) for details. t domainnamet ypserverst securenetss/etcs/var/yps/var/yp/bindingt defaultdomainthostnamethosttastrings)solaris.smf.value.name-service.nis.domaincCstj|ƒdS(N(Rt__init__(tself((s common/nis.pyR DscCsh|jdƒ|jd|jƒ}|dks:|dkr†|j|jƒ|j|jƒytj |j ƒƒWn |j SX|j Sd}|j d|jƒ}t|ƒtdƒkrçt|ƒdkrçdj|ƒ}|d7}nd}|j d|jƒ}t|ƒtdƒkr¥t|ƒdkr¥d}xX|D]P}t|ƒtdƒks9t|jƒƒdkruq9n||7}|d7}q9W|dkr¥d}q¥ntjj|jƒsÁ|jStjj|jƒsÝ|jStjj|j|ƒ}tjj|ƒscyKtjdƒj}tjdƒj} tj|dƒtj ||| ƒWqc|jSXn|j } |j } |j } |jd ƒ|j|jƒ|j|jƒ|d} |j!t"| ƒsÎ|jS|j#ƒ} | |jkr|jd ƒ|j$ƒ|jS|dkr’|jd ƒ|j|ƒ|j|j%ƒ|j!t&|ƒsV|jS|j#ƒ} | |jkr’|jd ƒ|j$ƒ|jSn|dkr |jd ƒ|j|jƒ|j|j'ƒ|j!t&|ƒsä|jS|j#ƒ} | |jkr |jd ƒ|j$ƒ|jSn| |j krT| |j krT| |j krT|j S|jd ƒ|j S(s Export from SMF. Re-generate the following configuration file: domainname, ypservers, securenets Non-existent or empty domain name means no domain.sexporting NIS DOMAIN legacy...tpropRis itrootiísexporting defaultdomain.sfail move to legacy...sexporting ypservers.sexporting securenets.ssuccessful export.N((((t print_msgt get_prop_valtDOMNAMEtNonet legacy_dirt LEGACY_ETCDIRt legacy_filet LEGACYDEFDOMtostunlinkt legacy_pathtNOCHANGEtSUCCESStget_prop_val_listt YPSERVERSttypetlentjoint SECURENETStsplittpathtisdirt LEGACY_YPDIRtFAILtLEGACY_YPBINDDIRtpwdtgetpwnamtpw_uidtgrptgetgrnamtgr_gidtmkdirtchownt save_to_tmptFalset tmp_to_legacyt unlink_tmptLEGACYYPSERVERStTruetLEGACYSECURENETS(R tdomainRtypsRtsnettsarrtdomdirtuidtgidtddrettysrettsnrettdata((s common/nis.pytexport_from_smfGs  * * 0                          c Csˆ|jdƒ|j|jƒ|j|jƒ|jƒ}t}tjj |ƒsX|j S|j ƒ}|dks‚t |ƒdkr‰|j S|d}|jd|ƒg}g}tjj|jƒrïtjj|jƒrïtjj|j|ƒ}tjj|ƒrï|j|ƒ|j|jƒ|jdƒ|j ƒ}|dkrNg}nx›|D]}|jddƒ}t |ƒdkrU|jdƒr”qUn|j|j|ƒsÕd|j|f} |j| ƒt}qUn|j|ƒqUqUWqïn|rü|jS|jd |ƒ|j|jƒ|j|jƒ|jd ƒ|j ƒ}|dkrZg}n|jd |ƒxc|D][}t |ƒdkrq|jdƒržqqnt |jƒƒd kr¼qqn|j|ƒqqqqW|jd |ƒ|jrð|jS|jdƒ|j |j!ƒs|jS|j"ƒs)|jS|jdƒ|jd|ƒ|j#|j!|j$|j%|ƒ} | st|jSt |ƒdkrÑ|jd|ƒ|j#|j!|j&|j|ƒsÑ|jd|ƒ|jSnt |ƒdkr.|jd|ƒ|j#|j!|j'|j(|ƒs.|jd|ƒ|jSn|jdƒ|j"|j!ƒsT|jS|jdƒ|j)ƒst|jS|jdƒ|jS(s{Import to SMF. Configure SMF using /var/yp configuration. If the domainname files does not exists, there is no domain.s!importing legacy defaultdomain...iis processed domain: simporting legacy ypservers...s t#sIllegal value (%s): %ss processed ypservers yserv: simporting legacy securenets...s legacy securenets...is processed securenets snet: s delete customizations.s loading pg...s adding: domainname s adding: ypservers s ERR adding ypservers: s adding: securenets s ERR adding securenets: s committing pg...s validating pg...ssuccessful import.N(*RRRRRRR2RR$texiststNOCONFIGt load_legacyRR R%R&R(R!R5t translatet startswitht typecheckt YPHOSTTYPEterr_msgR6tappendR'R7ttraceitR#tno_writeRt delcust_pgtDEFPGtcommitt add_prop_valRtDOMTYPERR"t YPASTRINGtvalidate( R tlegacyterrtlinesR8tyservR:R<tstemsgtret((s common/nis.pyt import_to_smf«s¬                    !        cCsZ|jdƒ|jdƒ|j|jƒs3|jS|jƒsF|jS|jdƒ|jS(sUnconfigure SMF. Reset DEFPG.sunconfiguring NIS DOMAIN...sDelete customizations.ssuccessful unconfigure.(RRPRQR'RRR(R ((s common/nis.pyt unconfig_smfs    cCs2|jƒ}|dkr.|j|kr.tSntS(s/Is SMF populated with this service? True/FalseN(tget_pgsRRQR6R2(R tpgs((s common/nis.pyt is_populated%s   c Cs4|jƒrtS|jƒ}|dkr,tS|j|kr?tS|jd|jƒ}|dkrdtSt}t}t}t}|j|j ƒ|j |j ƒ|dkrÀ|j ƒs-t}q-nm|j ƒsÕt}nX|j ƒ}t|ƒtgƒkr-t|ƒdkr-|d|kr-t}t}q-n|s7tS|sAtStjj|jƒsZtStjj|jƒrµtjj|jƒrµtjj|j|ƒ}tjj|ƒs¹tSntS|j|ƒ|j |jƒ|j ƒró|jƒ rótS|j|jƒ|j |jƒ|j ƒr0|jƒ r0tStS(s-Is this SMF service configured from SMF data?RRiN(t is_enabledR6R`RR2RQRRRRRRt legacy_existsRGRR RR$R%R&R(R!R5tis_autogeneratedR7( R RaR8t dom_is_confthas_domt srv_is_conft sec_is_confRYR<((s common/nis.pyt is_configured3s^          *  (RR R("t__name__t __module__t__doc__tSERVICEtLEGACYt LEGACYDIRRQtDEFPROPtDOCtALLPGSR6R2tALLPROPStBACKENDRR&R(RR5R7RRTRRKR"RUtUNCPROPt VALUE_AUTHR RCR^R_RbRj(((s common/nis.pyR#s<   d n t NisClientcBs‹eZdZdZdZdZdZdZdgZie d6e d6Z dZ dZ d „Z d „Zd „Zd „Zd „Zd„ZRS(s|Network Information Service (NIS) class. Represents the configuration of the NIS client. See ypinit(1m) for details.ssvc:/network/nis/clientRs/etcRt use_broadcastt use_ypsetmetnss_niss)solaris.smf.value.name-service.nis.clientcCstj|ƒdS(N(RR (R ((s common/nis.pyR ‘scCs|jdƒ|jS(s9Do nothing for nis/client. No properties to auto export.ssuccessful export.(RR(R ((s common/nis.pyRC”s cCs|jdƒ|jS(s9Do nothing for nis/client. No properties to auto import.ssuccessful import.(RR(R ((s common/nis.pyR^™s cCsZ|jdƒ|jdƒ|j|jƒs3|jS|jƒsF|jS|jdƒ|jS(sUnconfigure SMF. Reset DEFPG.sunconfiguring NIS client...sDelete customizations.ssuccessful unconfigure.(RRPRQR'RRR(R ((s common/nis.pyR_žs    cCs2|jƒ}|dkr.|j|kr.tSntS(s/Is SMF populated with this service? True/FalseN(R`RRQR6R2(R Ra((s common/nis.pyRbªs   cCs$|jƒrtS|jƒr tStS(s-Is this SMF service configured from SMF data?(RcR6RbR2(R ((s common/nis.pyRj²s   (RkRlRmRnRoRpRQRqRsR2RtRuRwR RCR^R_RbRj(((s common/nis.pyRx€s"     t NisServercBs„eZdZdZdZdZdZdZdgZie d6Z dZ dZ d„Z d „Zd „Zd „Zd „Zd „ZRS(s|Network Information Service (NIS) class. Represents the configuration of the NIS server. See ypserv(1m) for details.ssvc:/network/nis/serverRs/etcRt service_dnstnss_dnss)solaris.smf.value.name-service.nis.servercCstj|ƒdS(N(RR (R ((s common/nis.pyR ÐscCs|jdƒ|jS(s9Do nothing for nis/server. No properties to auto export.ssuccessful export.(RR(R ((s common/nis.pyRCÓs cCs|jdƒ|jS(s9Do nothing for nis/server. No properties to auto import.ssuccessful import.(RR(R ((s common/nis.pyR^Øs cCsZ|jdƒ|jdƒ|j|jƒs3|jS|jƒsF|jS|jdƒ|jS(sUnconfigure SMF. Reset DEFPG.sunconfiguring NIS SERVER...sDelete customizations.ssuccessful unconfigure.(RRPRQR'RRR(R ((s common/nis.pyR_Ýs    cCs2|jƒ}|dkr.|j|kr.tSntS(s/Is SMF populated with this service? True/FalseN(R`RRQR6R2(R Ra((s common/nis.pyRbés   cCs$|jƒrtS|jƒr tStS(s-Is this SMF service configured from SMF data?(RcR6RbR2(R ((s common/nis.pyRjñs   (RkRlRmRnRoRpRQRqRsR2RtRuRwR RCR^R_RbRj(((s common/nis.pyR|¿s"      tNisXfrcBsweZdZdZdZdZdZdZdgZiZ dZ d„Z d„Z d„Z d„Zd „Zd „ZRS( sŽNetwork Information Service (NIS) class. Represents the configuration of the NIS transfer daemon (ypxfrd). See ypxfrd(1m) for details.ssvc:/network/nis/xfrRs/etcRcCstj|ƒdS(N(RR (R ((s common/nis.pyR scCs|jdƒ|jS(s6Do nothing for nis/xfr. No properties to auto export.ssuccessful export.(RR(R ((s common/nis.pyRCs cCs|jdƒ|jS(s6Do nothing for nis/xfr. No properties to auto import.ssuccessful import.(RR(R ((s common/nis.pyR^s cCs|jdƒ|jS(s6Unconfigure SMF. Do nothing. No configuration files.ssuccessful unconfigure.(RR(R ((s common/nis.pyR_s cCstS(s9Is SMF populated with this service? Yes. (no SMF config)(R6(R ((s common/nis.pyRbscCstS(s-Is this SMF service configured from SMF data?(R6(R ((s common/nis.pyRj#s(RkRlRmRnRoRpRQRqRsRtRuR RCR^R_RbRj(((s common/nis.pyRþs      t NisPasswdcBsweZdZdZdZdZdZdZdgZiZ dZ d„Z d„Z d„Z d„Zd „Zd „ZRS( sŠNetwork Information Service (NIS) class. Represents the configuration of the NIS Passwd daemon. See rpc.yppasswdd(1m) for details.ssvc:/network/nis/passwdRs/etcRcCstj|ƒdS(N(RR (R ((s common/nis.pyR :scCs|jdƒ|jS(s9Do nothing for nis/passwd. No properties to auto export.ssuccessful export.(RR(R ((s common/nis.pyRC=s cCs|jdƒ|jS(s9Do nothing for nis/passwd. No properties to auto import.ssuccessful import.(RR(R ((s common/nis.pyR^Bs cCs|jdƒ|jS(s6Unconfigure SMF. Do nothing. No configuration files.ssuccessful unconfigure.(RR(R ((s common/nis.pyR_Gs cCstS(s9Is SMF populated with this service? Yes. (no SMF config)(R6(R ((s common/nis.pyRbLscCstS(s-Is this SMF service configured from SMF data?(R6(R ((s common/nis.pyRjPs(RkRlRmRnRoRpRQRqRsRtRuR RCR^R_RbRj(((s common/nis.pyR€+s      t NisUpdatecBsweZdZdZdZdZdZdZdgZiZ dZ d„Z d„Z d„Z d„Zd „Zd „ZRS( sŠNetwork Information Service (NIS) class. Represents the configuration of the NIS Update daemon. See rpc.ypupdated(1m) for details.ssvc:/network/nis/updateRs/etcRcCstj|ƒdS(N(RR (R ((s common/nis.pyR gscCs|jdƒ|jS(s9Do nothing for nis/update. No properties to auto export.ssuccessful export.(RR(R ((s common/nis.pyRCjs cCs|jdƒ|jS(s9Do nothing for nis/update. No properties to auto import.ssuccessful import.(RR(R ((s common/nis.pyR^os cCs|jdƒ|jS(s6Unconfigure SMF. Do nothing. No configuration files.ssuccessful unconfigure.(RR(R ((s common/nis.pyR_ts cCstS(s9Is SMF populated with this service? Yes. (no SMF config)(R6(R ((s common/nis.pyRbyscCstS(s-Is this SMF service configured from SMF data?(R6(R ((s common/nis.pyRj}s(RkRlRmRnRoRpRQRqRsRtRuR RCR^R_RbRj(((s common/nis.pyRXs      (Rmt __future__RtnssbaseRRR)R,RRxR|RR€R(((s common/nis.pyts$ÿ^??--