Ñò  fâNc @sáddkZddkZddkZddkZddkZddkZddkZddkZddki Z de fd„ƒYZ de fd„ƒYZ de fd„ƒYZ de fd „ƒYZd e fd „ƒYZdS( iÿÿÿÿNtCfgFilecBs’eZdZded„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„ZRS(s~ Solaris configuration file editor... make it easier to modify Solaris line-oriented configuration files from actions t#c Cs=||_||_||_t|_g}|iƒD]*}||dd|dd|dfq5~} | iƒg} | D]} | | dq}~ |_td„| Dƒƒ|_ t i |ƒ|_ td„|iDƒƒ|_ t|tƒo|g|_n ||_h|_t|iƒt|iƒjpt‚dS(Niiicss'x |]}|d|dfVqWdS(iiN((t.0te((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys 8s cssx|]}|dfVqWdS(iN((Rtn((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys ;s (tfilenamet separatortcontinuation_linestFalset needswritingtitemstsortt column_namestdicttdefault_valuestretcompiletcomment_regexpt max_lengthst isinstancetstrtkeystindextsettAssertionError( tselfRRR Rt comment_matchRt_[1]tvtlt_[2]R((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt__init__-s    D (  cCs d|i|i|i|ifS(NsCfgFile(%s):%s:%s:%s(RRR R(R((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt__str__FscCs|iS(N(R (R((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytgetcolumnnamesJscCs|ii|ƒS(N(Rtmatch(Rtline((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt iscommentlineMscCs|i|iƒS(N(tsplitR(RR#((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt splitlinePscCsmg}|iD])}||i|d|i|dgq~}|iƒg}|D]}||dqU~S(sm given self, return list of lines to be printed. default impl preserves orignal + insertion orderiii(RR (RRRtlinesR((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt getfilelinesSs@ csitii|iƒoOt|iƒ}d}x |D]}d}x:|io/|ddjo|d7}||iƒ7}qAW|idƒ}|i|ƒo|d|f|i |ns (tostpathtexistsRtopenRtnexttrstripR$tNoneRR&tlenR R tzipttupleRtcloseRR (RtfiletlinenoR#tlinecnttcols((R*s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytreadfile[s* 3 csF|iit‡fd†|iDƒƒdƒ}|o |dShSdS(Nc3sx|]}ˆ|VqWdS(N((RR)(ttemplate(s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys ws i(RtgetR4RR1(RR;tval((R;s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytgetvaluevs. cst‡fd†ˆiDƒƒS(sK returns dictionary of default string values - ignores other types c3sAx:|]3}tˆi|tƒo|ˆi|fVqqWdS(N(RRR(Rti(R(s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys €s (R R(R((Rs2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytgetdefaultvalues}scsp|it‡fd†|iDƒƒiƒ}x0|iD]%}|ˆjoˆ|||‡s N(RR4RtcopyR tsetvalue(RR;torigtname((R;s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt updatevalue„s ,  c sox„ˆiD]y}|ˆjofˆi|d jotd|‚qƒtˆi|ƒoˆi|ƒˆ|›s ic3s!x|]}ˆd|VqWdS(iN((RR)(RC(s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys Ÿs c3s$x|]}ˆi|dVqWdS(iN(R(RR)(R(s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys ¡s iic3sx|]}ˆ|VqWdS(N((RR)(R;(s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys ¥s N( R RR1t RuntimeErrortcallableRR<R4Rtmaxt valuetostrtTrueR (RR;tfieldR7R#((RR;RCs2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyRBs&  . ' '/cs0|it‡fd†|iDƒƒ=t|_dS(Nc3sx|]}ˆ|VqWdS(N((RR)(R;(s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pys ªs (RR4RRJR (RR;((R;s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt removevalue©s#cCs:d|iig}|iD]}|d||q~ƒS(s! print out values in file format s%s(RtjoinR (RR;Rtkey((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyRI­s cCsÐ|ipdSti|iƒ}tidtii|iƒƒ}ti|ddƒ}|d}ti ||i ƒti ||i |i ƒx|iƒD]}||IJq›W|iƒti||iƒdS(Ntdiritwi(R R+tstatRttempfiletmkstempR,tdirnametfdopentchmodtst_modetchowntst_uidtst_gidR(R5trename(RtstttempdataR6RDR((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt writefile´s !   (t__name__t __module__t__doc__RRR R!R$R&R(R:R>R@RERBRLRIR^(((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR)s           t PasswordFilecBseZdZed„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„ZRS(shManage the passwd and shadow together. Note that insertion/deletion of +/- fields isn't supportedcCsQttii|dƒdhd$d6d%d6d&d 6d'd 6d(d6d)d6d*d6dddƒ|_tidtiƒƒi }ttii|dƒdh d+d6d,d6d|fd6d-d6d.d6d/d6d0d6d1d 6d2d"6dddƒ|_ ||_ t i tii|i d#ƒƒ|_ |o|iƒn|iƒ|iƒ|iid RAtupdateRw(RR;tc((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR>óscCsK|iƒ}d|jod|d|iiiƒD]*}|do|i|ddƒqqWx,tdƒD]}t|ƒ|jo|SqTWtd‚dS(s#returns next free system (<=99) uidiRgidsNo free system uidsN(RrRt itervaluestappendtrangeRRF(RtuidsttR?((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR| s   cCs)|iiiƒ}|i|iiƒ|S(N(RrR RAR}Rw(Rtnames((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR!scCs|iiƒ|iiƒdS(N(RrR:Rw(R((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR:s cCs|iiƒ|iiƒdS(N(RrR^Rw(R((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR^ s cCs|ih|d6ƒS(NRd(R>(RRd((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytgetuser$scCs)|iiƒ}|i|iiƒƒ|S(N(RrR@R}Rw(Rta((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR@'scCs|iiƒdS(N(RyR{(R((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR{,scCs|iiƒdS(N(Rytunlock(R((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR‡/s(R_R`RaRRR R>RERBRLR|R!R:R^R…R@R{R‡(((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyRbÉs $           t GroupFilecBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(s manage the group filecCsz||_ti|tii|iƒdƒdhdd6dd6dd 6dd 6dd d ƒ|iƒ|i ƒ|i d RŠt _groupsbynameR<RtreplaceR%taddRMRB(RR‰Rdtgrouptusers((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytadduserMs" cCs¥|ih|d6ƒ}|ptd|‚nt|diddƒiƒƒ}||jotd||f‚n|i|ƒdi|ƒ|d<|i|ƒdS(s remove named user from group R‰ssubuser: No such group %ss user-listRRsUser %s not in group %sN(R>RFRR’R%tremoveRMRB(RR‰RdR”R•((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytsubuser^s"  cCsitg}|iiƒD]H}|ddj o1||ddidƒjo||ddqq~ƒS(s2 return list of additional groups user belongs to is user-listRR‰N(tsortedRtvaluesR1R%(RRdRRƒ((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt getgroupskscCs|i|ƒ}t|ƒt|ƒ}t|ƒt|ƒ}x|D]}|i||ƒqBWx|D]}|i||ƒqcWdS(N(R›RR˜R–(RRdtgroupstcurrenttremovalst additionstg((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt setgroupssscCs.x'|i|ƒD]}|i||ƒqWdS(N(R›R˜(RRdR ((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyt removeuser}s( R_R`RaRRŒR–R˜R›R¡R¢(((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyRˆ2s    t FtpusersFilecBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sV If a username is present in this file, it denies that user the ability to use ftpcCs=ti|tii|dƒdhdd6dƒ|iƒdS(Nsetc/ftpd/ftpusersRiRd(iN(RRR+R,RMR1R:(RRx((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR…s  cCsd|ih|d6ƒjS(s? returns true if user is allowed to use FTP - ie is NOT in fileRd(R>(RRd((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR…ŽscCs|ih|d6ƒdS(s8 add specified user to file, removing ability to use ftpRdN(RB(RRd((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR–“scCs|ih|d6ƒdS(s! remove specified user from file RdN(RL(RRd((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR˜—scCsV| o!|i|ƒo|i|ƒn*|o"|i|ƒ o|i|ƒndS(sAdd or remove 'username' from the file to turn off or on the user's ability to ftp into the system. If 'value' is True, allow the user, and if False, deny the user. If the value matches what is already encoded, don't do anything. N(R…R–R˜(RRdtvalue((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pytsetuser›s(R_R`RaRR…R–R˜R¥(((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR£s    t UserattrFilecBs2eZdZd„Zd„Zd„Zd„ZRS(s manage the userattr file cCsYti|tii|dƒdhdd6dd6dd 6dd 6dd 6dƒ|iƒdS(Ns etc/user_attrRciRdiRjt qualifierit reserved1it reserved2it attributes(iN(iRj(iRj(iRj(iRj(RRR+R,RMR1R:(RRx((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR©s cCs#t|ƒdjp|ii|ƒS(Ni(R2RR"(RR#((s2/usr/lib/python2.6/vendor-packages/pkg/cfgfiles.pyR$µscCs›tid|ƒ}t|ƒt|iƒjo|Stid|dƒ}h}x;|D]3}tid|ƒ}|didƒ||ds         iO&