Mini Shell

Direktori : /proc/self/root/lib64/python3.6/site-packages/pyanaconda/__pycache__/
Upload File :
Current File : //proc/self/root/lib64/python3.6/site-packages/pyanaconda/__pycache__/vnc.cpython-36.opt-1.pyc

3

C��e�-�@s�ddlZddlZddlZddlmZmZddlmZmZddl	Z	ddl
Z
ddlZddlm
Z
mZddlmZddlmZddlmZddlmZdd	lmZe�Zdd
lmZee�ZdZdd
�ZGdd�de�Z dS)�N)�network�product)�util�	constants)�_�P_)�tui_quit_callback)�VNCPassSpoke)�App)�
ScreenHandler)�get_stdout_logger)�get_module_loggerZXvnccCsPytjdtg�tjd�Wn.tk
rJ}ztjd|�WYdd}~XnXdS)a@Try to shutdown any running XVNC server

    Why is this function on the module level and not in the VncServer class ?

    As the server needs to be killed from the exit handler, it would have
    to somehow get to the VncServer instance. Like this, it can just kill
    it by calling a function of the vnc module.
    Zkillallz#The XVNC server has been shut down.z5Shutdown of the XVNC server failed with exception:
%sN)rZexecWithCapture�XVNC_BINARY_NAME�log�info�OSError�error)�e�r�/usr/lib64/python3.6/vnc.py�shutdownServer,s
	rc	@sjeZdZddddddddejf	dd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�	VncServer�/N�z/tmp/vncserver.logz/tmp/vncpasswordc

Csf||_||_||_||_||_||_||_||_|	|_d|_	d|_
t�|_t
d�tjtjd�|_dS)Nz/%(productName)s %(productVersion)s installation)�productName�productVersion)�root�ip�name�password�vncconnecthost�vncconnectport�log_file�pw_file�timeout�	connxinfo�anacondarrrrrr�desktop)
�selfrrrrr r!r"r#r$rrr�__init__>szVncServer.__init__c	Cs�d|j}tjddgtjtjtjd�}|j|jd��\}}|jdkrbtj	d|j|j
d��td��t|j
d	��}|j|�Wd
QRXd
S)z-Set the vnc server password. Output to file. z%s
Z	vncpasswdz-f)�stdin�stdout�stderrzutf-8rz vncpasswd has failed with %d: %szUnable to set the VNC password.�wbN)rr�startProgram�
subprocess�PIPE�communicate�encode�
returncoderr�decoder�openr#�write)r(Zpassword_string�proc�out�errr#rrr�setVNCPasswordSs


zVncServer.setVNCPasswordcCsZd}x,|r0tj�|_|jrPtjd�|d8}qW|js<dS|jjd�dkrZd|jf}n|j}y6tj|j�}t|�dkr�t|d�dkr�|d|_	Wn2tj
k
r�}ztjd	||�WYdd}~XnX|j	dk	o�|j	j
d
��rdtj|j	d�tj|tjf|_|j	}n*|dk	�r,d
|tjf|_|}n
d|_d}|�rVtd�tjtj|d�|_dS)z4Here is were all the relative vars get initialized. ��N�:z[%s]��rz2Exception caught trying to get host name of %s: %sZ	localhostz
%s:%s (%s:%s))rz%s:%srz@%(productName)s %(productVersion)s installation on host %(name)s)rrr���)rZget_first_ip_addressr�time�sleep�find�socketZ
gethostbyaddr�lenr�herrorr�debug�
startswithZgetfqdnr�X_DISPLAY_NUMBERr%rrrrr')r(ZtriesZipstrZhinfor�hostrrr�
initializehsF

 
zVncServer.initializecCsZytj|jtjtjB�}Wn:tk
rT}ztjjd|j|f�d}WYdd}~XnX|S)Nzerror opening %s: %s
)	�osr5r"�O_RDWR�O_CREATr�sysr,r6)r(�fdrrrr�openlogfile�szVncServer.openlogfilecCsd}|jjtd�|j�|jdkr4|jd|j}n|j}|jdddtjd|g}x�t|�D]�}t	j
|tjtjd	�}|j
�d
jd�}|dkr�|jjtd��d
S|jd�r�|jd�r�|jjtd��tjd�q^q^tj|�t	j|jjjd�tjd
�q^W|jjtdd|�|�dS)z)Attempt to connect to self.vncconnecthost�
z1Attempting to connect to vnc client on host %s...rr=z/usr/bin/vncconfigz-displayz:%sz-connect)r+r,r<zutf-8z
Connected!TZ
connectingzfailed
z*Will try to connect again in 15 seconds...�)�scriptsz.Giving up attempting to connect after %d try!
z0Giving up attempting to connect after %d tries!
F)rrrr r!rrrI�rangerr.r/r0r1r4rH�endswithrArB�critical�
ipmi_abortr&�ksdatarTrO�exitrr)r(ZmaxTriesZhostarg�vncconfigcommandZ_iZvncconfpr9rrr�
connectToView�s.




zVncServer.connectToViewcCsB|jjtd��|jddddtjg}tj||j�t	j
d�dS)zAttempt to start vncconfigzAttempting to start vncconfigz/usr/bin/vncconfigz-nowinz-displayz:%s)r+r,N)rrrrrrIrr.rQr/ZSTDOUT)r(r[rrr�startVncConfig�szVncServer.startVncConfigcCs8|jdk	r |jjtd�|j�n|jjtd�tj�dS)zrPut the server in listening mode.

        We dont really have to do anything for the server to listen :)
        NzCPlease manually connect your vnc client to %s to begin the install.z�Please manually connect your vnc client to IP-ADDRESS:%s to begin the install. Switch to the shell (Ctrl-B 2) and run 'ip addr' to find the IP-ADDRESS.)r%rrrrrI)r(rrr�	VNCListen�s
zVncServer.VNCListencCs |jjtd��tj�y|j�WnTtjtj	t
fk
rx}z.tjd|�t
j|jjjd�tjd�WYdd}~XnX|jr�t|j�dks�t|j�dkr�|j�|js�d}d}nd	}|j}|j�td
tjddd
dddddd|jfd|d|g
}yt
j||j�|jd�Wn<t k
�rPtjd�t
j|jjjd�tjd�YnX|jjtd��|j!dk�r�|jj"td��nh|jdk�r�|jj"td��nJ|jdk�r�|jj"td��n,|jj"td��t
j|jjjd�tjd�|j!dk�r|j#�}|�s|j$�n|j$�|j%�dS)NzStarting VNC...z'Could not initialize the VNC server: %s)rTr<���None�0ZVncAuthz:%sz-depthZ16z-brz
IdleTimeout=0z-authz	/dev/nullz-oncezDisconnectClients=falsez
desktop=%szSecurityTypes=%sz
rfbauth=%s)Zoutput_redirectr$z*Could not start the VNC server.  Aborting.zThe VNC server is now running.rz�

You chose to connect to a listening vncviewer. 
This does not require a password to be set.  If you 
set a password, it will be used in case the connection 
to the vncviewer is unsuccessful

z�

WARNING!!! VNC server running with NO PASSWORD!
You can use the inst.vncpassword=PASSWORD boot option
if you would like to secure the server.

z.

You chose to execute vnc with a password. 

z

Unknown Error.  Aborting. 

)&rrrrZwait_for_connectivityrKrDrF�dbusZ
DBusException�
ValueError�	stdoutLogrWrrXr&rYrTrOrZrrE�changeVNCPasswdWindowr#r:rrrIr'ZstartXrQr$rr Zwarningr\r^r])r(rZ
SecurityTypesZrfbauthZxvnccommandZ	connectedrrr�startServer�sV"



zVncServer.startServercCsXtd�}tj�tj�}|jt�t|jjdd|�}t	j
|�tj�|jjjj
|_
dS)z� Change the password to a sane parameter.

        We ask user to input a password that (len(password) > 6
        and len(password) <= 8) or password == ''.
        zjVNC password must be six to eight characters long.
Please enter a new one, or leave blank for no password.N)rr
rKZget_event_loopZset_quit_callbackrr	r&rYrZschedule_screenZrunZvncr)r(�messageZloopZspokerrrrfs

zVncServer.changeVNCPasswdWindow)�__name__�
__module__�__qualname__rZ	X_TIMEOUTr)r:rKrQr\r]r^rgrfrrrrr<s2	!
Dr)!rLrOrAZ
pyanacondarrZpyanaconda.corerrrDr/rcZpyanaconda.core.i18nrrZpyanaconda.ui.tuirZpyanaconda.ui.tui.spokes.askvncr	Z
simpleliner
Z simpleline.render.screen_handlerrZpyanaconda.anaconda_loggersrrer
rirrr�objectrrrrr�<module>s$