%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2582/usr/share/subiquity/console_conf/controllers/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2582/usr/share/subiquity/console_conf/controllers/__pycache__/identity.cpython-38.pyc

U

K��^m�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZmZddlmZmZe�d�Zdd	�Zd
d�Zdd
�Zdd�ZdZdZdd�Zdd�ZGdd�de�ZdS)�N)�BaseController)�
host_key_info�get_ips_standalone)�SnapdConnection)�disable_console_conf�run_command)�IdentityView�	LoginViewz!console_conf.controllers.identityc	Cs�d}z"t|d��}|��}W5QRXWntk
r<YdSXd}t�|�D]:}|�d�\}}}|dkrv|dkrvdS|dkrL|}q�qL|S)z6 For a ubuntu-core system, return its version or None z/usr/lib/os-release�rN�=ZIDzubuntu-coreZ
VERSION_ID)�open�read�FileNotFoundError�shlex�split�	partition)�path�fpZcontent�version�line�key�_�value�r�9/usr/share/subiquity/console_conf/controllers/identity.py�get_core_version srcCs tdd�}|�d���ddS)z Check if device is managed ��/run/snapd.socketzv2/system-info�resultZmanaged)r�get�json)�conrrr�get_managed6s
r"cCs8zt�|�}Wntk
r$YdSX|j�dd�dS)Nr�,�r)�pwd�getpwnam�KeyErrorZpw_gecosr)�username�inforrr�get_realname<s
r*cCs`tdd�}|�d���dD]>}d|kr*q|d}d|}tj�|�r|t|�|d�SqdS)	z Get device owner, if any rrzv2/usersrr(z/home/)r(�realname�homedirN)rrr �osr�isdirr*)r!�userr(r,rrr�get_device_ownerDs
�r0z�Ubuntu Core {version} on {first_ip} ({tty_name})
{host_key_info}

To login:
{sshcommands}
Personalize your account at https://login.ubuntu.com.
z�Ubuntu Core {version} on <no ip address> ({tty_name})

You cannot log in until the system has an IP address. (Is there
supposed to be a DHCP server running on your network?)

Personalize your account at https://login.ubuntu.com.
c	Cs�d}|D]}|d||f7}qt�d�dd�}t�p8d}t|�dkr^|�tj|||d��n$|d}|�tj|t�|||d��dS)N�
z    ssh %s@%s
r��16)�sshcommands�tty_namer)r4rr5�first_ipr)	r-�ttynamer�len�write�login_details_tmpl_no_ip�format�login_details_tmplr)rr(�ipsr4Zipr5rr6rrr�write_login_detailsis$
�

�r>cCs�t�}t�}t|�dkr^|dkr,td�dSt�d�dd�}t�pFd}ttj||d��dS|dkr|td�d�	|���nt
tj|d	|�dS)
Nrzdevice managed without user�r2r3)r5rz device managed without user @ {}z, r()
r0rr8�printr-r7rr:r;�joinr>�sys�stdout)�ownerr=r5rrrr�write_login_details_standalone{s"
�rEcsDeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)
�IdentityControllercst��|�|jj|_dS�N)�super�__init__�
base_modelZidentity�model)�self�app��	__class__rrrI�szIdentityController.__init__cCst|j�t|j|��t�rpt�}|rh|j�|�tj�	|dd�}t
dd|g�}|j�dd��
�|jj_|��dS)Nr,z.ssh/authorized_keysz
ssh-keygenz-lf�
r)�ui�set_bodyrrKr"r0�add_userr-rrArrC�replace�
splitlinesr/Zfingerprints�login)rLZdevice_ownerZkey_file�cprrr�start_ui�s��zIdentityController.start_uic
	Cs|jjr$||d�}|j�|�d}n�|jj��tdddd|g�}|jdkrpt	|j
jt�rl|j
j�
d|j�dSt�|j�}||d	d�}tjd
dd�d
}|j�|�g}|jjj}|��D]}|�|j�q�t|d��}	t|	|d	|�W5QRX|��dS)N)r+r(z.subiquity/login-details.txtZsnapzcreate-userz--sudoerz--jsonrzCreating user failed:r(z/run/console-confT)�exist_okz#/run/console-conf/login-details.txt�w)�opts�dry_runrKrSrMZ
urwid_loopZdraw_screenr�
returncode�
isinstancerQZbodyrZsnap_create_user_failed�stderrr �loadsrCr-�makedirsrJ�network�get_all_netdevs�extendZactual_global_ip_addressesrr>rV)
rLZemailrZlogin_details_pathrW�datar=�	net_modelZdevrrrr�
identity_done�s>��
��
z IdentityController.identity_donecCs|jjdkr|j��dSrG)rKr/rMZprev_screen�rLrrr�cancel�szIdentityController.cancelcCsLd}|j�|�|jjj}|��}t|j|j||�}d|j	_
|j�|�dS)NzConfiguration Completer?)rQZ
set_headerrMrJrbrcr	r[rKZ_wZfocus_positionrR)rL�titlerfZifacesZ
login_viewrrrrV�s
zIdentityController.logincCs|jjst�|j��dSrG)r[r\rrM�exitrhrrr�
login_done�szIdentityController.login_done)
�__name__�
__module__�__qualname__rIrXrgrirVrl�
__classcell__rrrNrrF�s
"rF)r Zloggingr-r%rrBZsubiquitycore.controllerrZsubiquitycore.sshrrZsubiquitycore.snapdrZsubiquitycore.utilsrrZconsole_conf.ui.viewsrr	Z	getLogger�logrr"r*r0r<r:r>rErFrrrr�<module>s(




Zerion Mini Shell 1.0