403Webshell
Server IP : 61.19.30.66  /  Your IP : 216.73.216.15
Web Server : Apache/2.2.22 (Ubuntu)
System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64
User : www-data ( 33)
PHP Version : 5.3.10-1ubuntu3.48
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/python2.7/dist-packages/landscape/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/landscape/configuration.pyc

}9Rc@s-dZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z
ddlmZddlm
Z
ddlmZmZddlmZddlmZdd	lmZmZmZdd
lmZmZddlmZddlmZdd
l m!Z!ddl"m#Z#de$fdYZ%de%fdYZ&de'dZ(dZ)de!fdYZ*de+fdYZ,dZ-dZ.dZ/dZ0dZ1dZ2e(e(d Z3d!Z4d"Z5d#Z6e(ej7e8d$d%Z9d&Z:dS('sInteractive configuration support for Landscape.

This module, and specifically L{LandscapeSetupScript}, implements the support
for the C{landscape-config} script.
iN(tConfigParsertError(tStringIO(tis_valid_tag(t
SysVConfigtProcessError(tMethodCallError(tgather_results(tfetcht
FetchErrort
HTTPCodeError(t
BootstrapListtBootstrapDirectory(tLandscapeReactor(tInvalidCredentialsError(tBrokerConfiguration(tRemoteBrokerConnectortConfigurationErrorcBseZdZRS(s6Raised when required configuration values are missing.(t__name__t
__module__t__doc__(((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyRstImportOptionErrorcBseZdZRS(s?Raised when there are issues with handling the --import option.(RRR(((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyR"ss
cCs:|rtj}n	tj}|j|||jdS(N(tsyststderrtstdouttwritetflush(ttexttendterrortstream((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt
print_text&s
	cCs|dk	rg|jdD]}|j^q}d|krqt|dkratdn|jdng}x@|D]8}ytj|Wq~tk
r|j	|q~Xq~W|SdS(s
    Process a string with a list of comma separated usernames, this returns
    any usernames not known to the underlying user database.
    t,tALLis$Extra users specified with ALL usersN(
tNonetsplittstriptlenRtremovetpwdtgetpwnamtKeyErrortappend(tuserstusert	user_listt
invalid_users((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytget_invalid_users/s(

tLandscapeSetupConfigurationcBs)eZdZdZdZdZRS(	tno_starttdisabletsilenttok_no_registertimport_fromcCs~|jrzt}yd|jkr|jr@|jtjd<n|jr\|jtjd<n|j|j}|jt|nbtj	j
|jstd|jn7|j|j}|j|krtd|jnWn%t
k
r}tt|nXd}|j|jrBt|j|j}n|s^td|jn|j|j||_ndS(sHandle the --import parameter.

        Imported options behave as if they were passed in the
        command line, with precedence being given to real command
        line options.
        s://t
http_proxythttps_proxysFile %s doesn't exist.s$Couldn't read configuration from %s.sNothing to import at %s.N(R5RR6tostenvironR7tfetch_import_urltreadfpRtpathtisfileRtreadtConfigParserErrortstrR"thas_sectiontconfig_sectiontdicttitemstupdatet_command_line_options(tselftparsertcontenttsuccesfully_read_filesRtoptions((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt_load_external_optionsIs8				cCsotd|d}yt|}Wntk
rE}t|}nX|dk	rktd||fn|S(s(Handle fetching of URLs passed to --url.s!Fetching configuration from %s...s+Couldn't download configuration from %s: %sN(RR"RR	R@R(RGturlt
error_messageRIR((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyR:rscCstt|j}|jddddddd|jddd	dd
|jdddd
ddd|jdddddd|jddddd|jdddd
tdd|jdddd
tdd|jdddd
tdd|S(sK
        Specialize the parser, adding configure-specific options.
        s--importtdestR5tmetavartFILENAME_OR_URLthelpsFilename or URL to import configuration from. Imported options behave as if they were passed in the command line, with precedence being given to real command line options.s--script-userstUSERSslA comma-separated list of users to allow scripts to run.  To allow scripts to be run by any user, enter: ALLs--include-manager-pluginstPLUGINStdefaultts2A comma-separated list of manager plugins to load.s-ns
--no-starttactiont
store_trues%Don't start the client automatically.s--ok-no-registersBReturn exit code 0 instead of 2 if the client can't be registered.s--silentsRun without manual interaction.s	--disables/Stop running clients and disable start at boot.s--inits1Set up the client directories structure and exit.(tsuperR0tmake_parsert
add_optiontFalse(RGRH((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyRZs((sno_startsdisablessilentsok_no_registersimport_from(RRtunsaved_optionsRLR:RZ(((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyR0Ds
	)	tLandscapeSetupScriptcBseZdZdZdZdZedZedZe	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZRS(s2
    An interactive procedure which manages the prompting and temporary storage
    of configuration parameters.

    Various attributes on this object will be set on C{config} after L{run} is
    called.

    @ivar config: The L{BrokerConfiguration} object to read and set values from
        and to.
    cCs
||_dS(N(tconfig(RGR_((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt__init__scCsJ|jj}tddjg|D]}|jd^q%dS(Ns
RV(R$t
splitlinesRtjoin(RGRtlinestline((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt	show_helpscCs>x7tr9t|}|r|S|s)Pn|jdqWdS(sPrompt the user on the terminal for a value

        @param msg: Message to prompt user with
        @param required: True if value must be entered
        s/This option is required to configure Landscape.N(tTruet	raw_inputRe(RGtmsgtrequiredtvalue((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytprompt_get_inputs	cCs{t|j|d}|r,|d|7}n
|d7}|oFt|}|j||}|rwt|j||ndS(stPrompt the user on the terminal for a value.

        @param option: The attribute of C{self.config} that contains the
            default and which the value will be assigned to.
        @param msg: The message to prompt the user with (via C{raw_input}).
        @param required: If True, the user will be required to enter a value
            before continuing.
        s [%s]: s: N(tgetattrR_R"tboolRktsetattr(RGtoptionRhRiRUtresult((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytprompts	
cCst|j|d}|d7}xtrtj|}|rOtjd}n|r||krq|jdqt|j||Pq"|s|rPq"|jdq"WdS(sPrompt the user on the terminal for a password and mask the value.

        This also prompts the user twice and errors if both values don't match.

        @param option: The attribute of C{self.config} that contains the
            default and which the value will be assigned to.
        @param msg: The message to prompt the user with (via C{raw_input}).
        @param required: If True, the user will be required to enter a value
            before continuing.
        s: sPlease confirm: sKeys must match.s/This option is required to configure Landscape.N(RlR_R"RftgetpassReRn(RGRoRhRiRURjtvalue2((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytpassword_prompts
	
cCs||rd}nd}x`trwt||j}|rp|jdrMtS|jdr`tS|jdq|SqWdS(Ns [Y/n]s [y/N]tntysInvalid input.(RfRgtlowert
startswithR\Re(RGtmessageRUtdefault_msgRj((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt
prompt_yes_nos		cCs=d|jjkrdS|jd|jddtdS(Ntcomputer_titles%
            The computer title you provide will be used to represent this
            computer in the Landscape user interface. It's important to use
            a title that will allow the system to be easily recognized when
            it appears on the pending computers page.
            sThis computer's title(R_tget_command_line_optionsReRqRf(RG((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytquery_computer_titles
cCs=d|jjkrdS|jd|jddtdS(Ntaccount_names
            You must now specify the name of the Landscape account you
            want to register this computer with.  You can verify the
            names of the accounts you manage on your dashboard at
            https://landscape.canonical.com/dashboard
            sAccount name(R_R}ReRqRf(RG((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytquery_account_names
cCsJ|jj}d|krdS|jd|jj|jdddS(Ntregistration_keys
            A registration key may be associated with your Landscape
            account to prevent unauthorized registration attempts.  This
            is not your personal login password.  It is optional, and unless
            explicitly set on the server, it may be skipped here.

            If you don't remember the registration key you can find it
            at https://landscape.canonical.com/account/%s
            sAccount registration key(R_R}ReRRt(RGtcommand_line_options((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytquery_registration_key"s		cCsz|jj}d|kr+d|kr+dS|jdd|krW|jddnd|krv|jddndS(NR6R7s>
            The Landscape client communicates with the server over HTTP and
            HTTPS.  If your network requires you to use a proxy to access HTTP
            and/or HTTPS web sites, please provide the address of these
            proxies now.  If you don't use a proxy, leave these fields empty.
            sHTTP proxy URLsHTTPS proxy URL(R_R}ReRq(RGRK((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt
query_proxies5scCs|jj}d|kr]d|kr]t|d}|rYtddj|ndS|jdd}g|jjjdD]}|j^q}|dgkrg}nd	|k}|j	|d
|rbd	|kr|j
d	n|jdx{tr^|jddt|jj
}|s5Pq|jddj|d|j_
qWnd	|kr~|jd	ndj||j_dS(
Ntinclude_manager_pluginstscript_userssUnknown system users: %ss, sb
            Landscape has a feature which enables administrators to run
            arbitrary scripts on machines under their control. By default this
            feature is disabled in the client, disallowing any arbitrary script
            execution. If enabled, the set of users that scripts may run as is
            also configurable.
            sEnable script execution?R RVtScriptExecutionRUs!
                By default, scripts are restricted to the 'landscape' and
                'nobody' users. Please enter a comma-delimited list of users
                that scripts will be restricted to. To allow scripts to be run
                by any user, enter "ALL".
                sScript users(R_R}R/RRbReRR#R$R{R*RfRqRR"R&(RGRKR.Rhtptincluded_pluginsRU((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytquery_script_pluginGs>.			cCs`g}|r\g|jdD]}|j^q}g|D]}t|s;|^q;}n|S(sm
        Splits a string on , and checks the validity of each tag, returns any
        invalid tags.
        R (R#R$R(RGttagnamestinvalid_tagsttagttags((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt_get_invalid_tagsvs
((cCs|jj}d|krT|j|d}|rPtddj|ndS|jdxOtr|jddt|j|jj	r|jdd|j_	qdPqdWdS(sQuery tags from the user.RsInvalid tags: %ss, Ns;You may provide tags for this computer e.g. server,precise.tTagss3Tag names may only contain alphanumeric characters.(R_R}RRRbReRfRqR\RR"(RGRKR((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt
query_tagss
	
cCs|jddS(Ns
            This script will interactively set up the Landscape client. It will
            ask you a few questions about this computer and your Landscape
            account, and will submit that information to the Landscape server.
            After this computer is registered it will need to be approved by an
            account administrator on the pending computers page.

            Please see https://landscape.canonical.com for more information.
            (Re(RG((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytshow_headers	cCsJ|j|j|j|j|j|j|jdS(syKick off the interactive process which prompts the user for data.

        Data will be saved to C{self.config}.
        N(RR~RRRRR(RG((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytruns





(RRRR`ReRkR\RqRtRfR{R~RRRRRRRR(((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyR^s 
								/			cCst}|jtdS(s6Configure the init script to start the client on boot.N(Rtset_start_on_bootRf(t
sysvconfig((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt"setup_init_script_and_start_clients	cCs$t}|j|jtdS(sj
    Stop landscape-client and change configuration to prevent starting
    landscape-client on boot.
    N(Rtstop_landscapeRR\(R((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt#stop_client_and_disable_init_scripts	
cCsl|jdkr4tjjdr4tjd|_n|jdkrhtjjdrhtjd|_ndS(s
    If a http_proxy and a https_proxy value are not set then copy the values,
    if any, from the environment variables L{http_proxy} and L{https_proxy}.
    R6R7N(R6R"R8R9tgetR7(R_((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytsetup_http_proxys!!cCs_|jr[|jr[|jdpF|jpF|jdoF|jds[tdq[ndS(s
    Ensure that silent configurations which plan to start landscape-client are
    either configured for OTP or have both an account_name and computer title.
    totpRR|s0An account name and computer title are required.N(R3R1Rtprovisioning_otpR(R_((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytcheck_account_name_and_passwordscCsb|jdr^t|jd}|rFtddj|n|js^d|_q^ndS(s{
    If the configuration allows for script execution ensure that the configured
    users are valid for that purpose.
    RsUnknown system users: %ss, RN(RR/RRbR(R_R.((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytcheck_script_userss	cCsJ|jrF|jjdrFtj|jd}t|||_ndS(sg
    Decode base64 encoded SSL certificate and push that back into place in the
    config object.
    sbase64:iN(tssl_public_keyRxtbase64tdecodestringtstore_public_key_data(R_tdecoded_cert((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt$decode_base64_ssl_public_certificatescCs|d|d}d}d|}yt|dt}WnOtk
r^}|d||Stk
r}|d|t|f|SX|rtj|}y8|djdr|d}n|d	||fWqtk
r|d
|qXn|d||S(sx
    Fetch base64 encoded SSL CA certificate from the discovered landscape
    server and return that decoded info.
    s/Fetching CA certificate from %s if available...RVshttp://%s/get-ca-certtinsecuresjUnable to fetch CA certificate from discovered server %s: Server does not support client auto-registation.s*Unable to fetch CA certificate from %s: %stcustom_ca_certsbase64:s5Auto-registration URL %s returns invalid CA JSON: %s.s*No custom CA certificate available for %s.scUnable to fetch CA certificate from discovered server %s.  Proceding without custom CA certificate.(	RRfR
R	R@tjsontloadsRxR)(thostnameton_infoton_errorRItencoded_certtca_urlRtca_dict((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt#fetch_base64_ssl_public_certificates4


cCsOt|t}|jsy|jr/tqy|jsytd}|jjdsftqvt	j
dqynt|t||jrt
|nt|}|jt||j|jrK|jrKy|jWqKtk
rGtddttddtd}|jr7d}nt	j
|qKXnd	S(
s
    Perform steps to ensure that landscape-client is correctly configured
    before we attempt to register it with a landscape server.

    If we are not configured to be silent then interrogate the user to provide
    necessary details for registration.
    sl
The Landscape client must be started on boot to operate correctly.

Start Landscape client on boot? (Y/n): tNs Aborting Landscape configurations&Couldn't restart the Landscape client.RsOThis machine will be registered with the provided details when the client runs.iiN(tbootstrap_treeRR1R3Rtis_configured_to_runRgtupperRxRtexitRRRR^RRRRtrestart_landscapeRRRfR4(R_Rtanswertscriptt	exit_code((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytsetups:
			



	




			cCsPtddddtddddg}t|jd|jd|jdS(	s#Create the client directories tree.s
$data_patht	landscapetrootis$annotations_patht	data_pathtannotations_pathN(RRt	bootstrapRR(R_tbootstrap_list((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyRHs
cCsftjj|jtjj|jd}td|t|d}|j||j	|S(s
    Write out the data from the SSL certificate provided to us, either from a
    bootstrap.conf file, or from EC2-style user-data.

    @param config:  The L{BrokerConfiguration} object in use.
    @param certificate_data: a string of data that represents the contents of
    the file to be written.
    @return the L{BrokerConfiguration} object that was passed in, updated to
    reflect the path of the ssl_public_key file.
    s.ssl_public_keys#Writing SSL CA certificate to %s...tw(
R8R<RbRtbasenametget_config_filenameRtopenRtclose(R_tcertificate_datatkey_filenametkey_file((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyRRs

ics1dkrtng
fdfdfdfdfd	fdddtjd		fd
}fd}t
jd|d
t}|j||j|j	r-|dn|S(sInstruct the Landscape Broker to register the client.

    The broker will be instructed to reload its configuration and then to
    attempt a registration.

    @param reactor: The reactor to use.  Please only pass reactor when you
        have totally mangled everything with mocker.  Otherwise bad things
        will happen.
    @param max_retries: The number of times to retry connecting to the
        landscape client service.  The delay between retries is calculated
        by Twisted and increases geometrically.  The default of 14 results in
        a total wait time of about 70 seconds.

        initialDelay = 0.05
        factor =  1.62
        maxDelay = 30
        max_retries = 14

        0.05 * (1 - 1.62 ** 14) / (1 - 1.62) = 69 seconds
   csQjs9x-|D]"}|dk	rj|qqWnjjdS(N(R4R"R*t
disconnecttstop(terrorsR(treactortexit_with_errort	connectorR_(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyRs	

csddtdS(Ns)Invalid account name or registration key.Ri(Rf((t
on_message(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytfailures	csddS(NsSystem successfully registered.(((R(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytsuccessscsddtdS(NsWe were unable to contact the server. Your internet connection may be down. The landscape client will continue to try and contact the server periodically.Ri(Rf((R(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytexchange_failures	cs|jttjdS(N(ttrapRRR(R(R(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pythandle_registration_errorsscs-|jdtddtdgS(NRsUnknown error occurred.i(tgetTracebackRf(R(R(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt	catch_allssPlease wait... RVicsxid6d6d6}|j|j||jjg}t|dt}|j|jdS(Nsregistration-donesregistration-failedsexchange-failedtconsume_errors(treload_configurationt
call_on_eventtregistert
addErrbackRRftaddCallback(tremotethandlerst	deferredstresults(RRRRRR(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytgot_connections

	
cs1ddtddtdgdS(Ns;There was an error communicating with the Landscape client.RsOThis machine will be registered with the provided details when the client runs.i(Rf(R(RR(s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt	got_errors
		tmax_retriestquietiN(
R"R
ttimetsleepRtconnectRfRRR(R_RRRRRRRp((RRRRRRRRRRR_s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyRfs*




cCs5t}y|j|Wn6tk
rR}tt|dttjdnXtj	dkrutjdn|j
rt|tjdn|jrt
dSyt|Wn0tk
r}tt|tjdnX|jrt|n.td}|jjds1t|ndS(NRiis%landscape-config must be run as root.s Aborting Landscape configurations:
Request a new registration for this computer now? (Y/n): R(R0tloadRRR@RfRRR8tgetuidtinitRR2RRt	ExceptionR3RRgRRx(targsR_RteR((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pytmains0		
		
(;RRRRRR8RrR'RRR?Rtlandscape.lib.tagRtlandscape.sysvconfigRRtlandscape.lib.ampRtlandscape.lib.twisted_utilRtlandscape.lib.fetchRR	R
tlandscape.lib.bootstrapRRtlandscape.reactorR
tlandscape.broker.registrationRtlandscape.broker.configRtlandscape.broker.ampRRRRR\RR/R0tobjectR^RRRRRRRRRRRR"RR(((s;/usr/lib/python2.7/dist-packages/landscape/configuration.pyt<module>sP		a		
				
&	.	
	a

Youez - 2016 - github.com/yon3zu
LinuXploit