Ñò ºµiVc @sdZddkZddkZddkZddkZddklZlZlZddk l Z de fd„ƒYZ d„Z e djo e ƒndS( s auth.conf parser and generator iÿÿÿÿN(tBootmgmtArgumentErrortBootmgmtConfigReadErrortBootmgmtConfigWriteError(t LoggerMixintAuthConfigParsercBs˜eZdZdZdZdZdZeidƒZ de d„Z e d„ƒZ e id „ƒZ d „Zd „Zd „Zd „Zde d„ZRS(sbThe AuthConfigParser class provides an interface to the auth.conf file. The auth.conf file contains 3 sections. The sections and properties include: [menulock] menulock= [superusers] superusers= [users] Zero or More of: = s·# # This file is modified without notice. # DO NOT EDIT THIS FILE DIRECTLY. CHANGES MAY NOT BE PRESERVED. # Changes to this file can be made indirectly via bootadm(1M) subcommands. # t superuserstuserstmenulocks'^([\.A-Za-z0-9_-]+\s)*[\.A-Za-z0-9_-]+$s/rpool/boot/grub/auth.confcCsttt|ƒiƒ||_d|_t|_ti ƒ|_ h|_ h|_ h|_ |p|i|ƒndS(N(tsuperRt__init__t _filenametNonetlast_written_pathtFalset_dirtyt ConfigParsertRawConfigParsert _cfgparserRRRt_load(tselftfilenametnew_conf((s0../../common/bootmgmt/backend/loader/authconf.pyR Cs      cCs|iS(s:Returns the state of the internal dirty variable. (R(R((s0../../common/bootmgmt/backend/loader/authconf.pytdirtyOscCs1|i|jo|id|ƒ||_ndS(s‹Sets the state of the internal dirty variable. Emits a debug message if the state of the internal dirty variable changed. s dirty => %sN(Rt_debug(Rtval((s0../../common/bootmgmt/backend/loader/authconf.pyRUscCsÊ|p|idƒdS|id|ƒyt|dƒ}Wn|id|ƒnqXy|ii|ƒWnOtj oC}|itijo|id|ƒndStd|ƒ‚n X|iƒdS(sïAttempt to load the file specified. If new_conf is True, the file's contents are not loaded. The following Exceptions may be generated: BootmgmtConfigReadError -- If there's a problem reading config file. s7No filename specified -- not loading auth configurationNsLoading auth.conf from %strsCould not open %ss[IGNORED] %s not founds1Error trying to read the auth configuration file ( RtopenRtreadfptIOErrorterrnotENOENTRt_load_sections(RRtftioerr((s0../../common/bootmgmt/backend/loader/authconf.pyR^s" cCs´x­|iiƒD]œ}|tijo"t|iitiƒƒ|_q|tijo"t|iitiƒƒ|_q|ti jo"t|iiti ƒƒ|_ qqWdS(s*Load sections from auth.conf file N( RtsectionsRtSUPERUSERS_SECTtdicttitemsRt USERS_SECTRt MENULOCK_SECTR(Rtsect((s0../../common/bootmgmt/backend/loader/authconf.pyR}s   cCst|iidƒ}g}|oQtii|ƒo:|idƒ}g}|D]}||iƒqL~}qpn|S(s$Return the superusers list. Rt (RtgetRtSUPERUSERS_STR_MATCHINGtmatchtsplittstrip(Rt stringlisttlist_of_stringst_[1]tx((s0../../common/bootmgmt/backend/loader/authconf.pytget_superusersŽs/c Cs tiƒ}|ioJ|itiƒx7|iiƒD]"\}}|iti||ƒq6Wn|ioJ|iti ƒx7|iiƒD]"\}}|iti ||ƒqŠWn|i oJ|iti ƒx7|i iƒD]"\}}|iti ||ƒqÞWn|S(s_Generate a new ConfigParser using the data from superuser, users, and menulock ( RtSafeConfigParserRt add_sectionRR#R%tsetRR&RR'(Rt new_parsertkeytvalue((s0../../common/bootmgmt/backend/loader/authconf.pyt_synch_to_config_parser™s"       cCs |i o| o|idƒdS|i o|o|idƒn|iƒ|_|p|i}|ptdƒ‚nyatidƒ}t|dƒ}ti|ƒ|i t i ƒ|ii |ƒ||_ t |_Wn$tj o}td|ƒ‚nXdS(sWrites the auth data to auth.conf. If no changes have been made since the configuration was loaded, write() will return without writing the file (unless force is True). If alt_file is not None, the auth configuration will be written there. Exceptions that may be generated: BootmgmtArgumentError -- If no filename is available. BootmgmtConfigWriteError -- If the auth config file cannot be created or if there's a problem writing to it. savoiding writeNs forcing writes)auth configuration filename not specifieditws&Error writing auth configuration file (RRR:RR RtostumaskRtwriteRtAUTH_CONF_PREAMBLER R RRR(Rtalt_filetforcet write_filetoldumasktoutfileR!((s0../../common/bootmgmt/backend/loader/authconf.pyR>­s(     N(t__name__t __module__t__doc__R?R#R&R'tretcompileR+R R tpropertyRtsetterRRR3R:R R>(((s0../../common/bootmgmt/backend/loader/authconf.pyR's     cCsOtdddtƒ}dt|iƒGHdt|iƒGHdt|iƒGHdS(NRs/root/temp_auth.confRsThe superuser is sThe usernm pw dict is sThe menu password is (RR tstrRRR(ttest_auth_conf((s0../../common/bootmgmt/backend/loader/authconf.pytmain×s t__main__(RGR<RRRHtbootmgmtRRRtbootmgmt.bootutilRRRNRE(((s0../../common/bootmgmt/backend/loader/authconf.pyts    °