404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.145.163.26: ~ $
3

\�me-$�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZdZ
dZeje�ZGdd�dejd�ZGd	d
�d
e�ZegZddd�Zd
d�Zddd�Zdd�Zdd�Zdd�Zddd�ZdS)�N)�util)�get_devicelist�read_sys_net_safez#/run/initramfs/open-iscsi.interface�disabledc@s8eZdZdZejed�dd��Zejed�dd��Z	dS)�InitramfsNetworkConfigSourcezBABC for net config sources that read config written by initramfses)�returncCsdS)zAIs this initramfs config source applicable to the current system?N�)�selfrr�/usr/lib/python3.6/cmdline.py�
is_applicablesz*InitramfsNetworkConfigSource.is_applicablecCsdS)z;Render a v1 network config from the initramfs configurationNr)r	rrr
�
render_config"sz*InitramfsNetworkConfigSource.render_configN)
�__name__�
__module__�__qualname__�__doc__�abc�abstractmethod�boolr�dictrrrrr
rs
r)�	metaclassc@s6eZdZdZd
dd�Zed�dd�Zed�dd	�ZdS)�KlibcNetworkConfigSourcez�InitramfsNetworkConfigSource for klibc initramfs (i.e. Debian/Ubuntu)

    Has three parameters, but they are intended to make testing simpler, _not_
    for use in production code.  (This is indicated by the prepended
    underscores.)
    NcCst||_||_||_|jdkr$t�|_|jdkr8tj�|_|jdkrpi|_x&t�D]}t|d�}|rP||j|<qPWdS)N�address)�_files�
_mac_addrs�_cmdline�_get_klibc_net_cfg_filesr�get_cmdlinerr)r	rrr�kZmac_addrrrr
�__init__/s




z!KlibcNetworkConfigSource.__init__)rcCs>|jr:x"tj|j�D]}|jd�rdSqWtjjt�r:dSdS)aD
        Return whether this system has klibc initramfs network config or not

        Will return True if:
            (a) klibc files exist in /run, AND
            (b) either:
                (i) ip= or ip6= are on the kernel cmdline, OR
                (ii) an open-iscsi interface file is present in the system
        �ip=�ip6=TF)rr )	r�shlex�splitr�
startswith�os�path�exists�_OPEN_ISCSI_INTERFACE_FILE)r	�itemrrr
rAs

z&KlibcNetworkConfigSource.is_applicablecCst|j|jd�S)N)�files�	mac_addrs)�config_from_klibc_net_cfgrr)r	rrr
rTsz&KlibcNetworkConfigSource.render_config)NNN)	r
rrrrrrrrrrrr
r's
rcCs�|dkri}tj|�}yd|kr(|dn|d}Wn,tk
r^}ztd�|�WYdd}~XnX|jd|jd��}|s�|jd�r�d}nd	}|d!kr�td|��d|gd
�}||kr�|||d<�x,d"D�]"}|d|kr�q�|j|d|�}|d	k�r�d}|dd�}	|dk�r||d|	d<x0d#D](}
||
|k�r"|||
|	|
j�<�q"Wg}xDd$D]<}|j||�}
|
�rXt|
jd���rX|j|||��qXW|�r�||	d<|jd�}|�r�d|k�r�|j	d�|	d<n|j	�|	d<|d j|	�q�W||fS)%a�Convert a klibc written shell content file to a 'config' entry
    When ip= is seen on the kernel command line in debian initramfs
    and networking is brought up, ipconfig will populate
    /run/net-<name>.cfg.

    The files are shell style syntax, and examples are in the tests
    provided here.  There is no good documentation on this unfortunately.

    DEVICE=<name> is expected/required and PROTO should indicate if
    this is 'none' (static) or 'dhcp' or 'dhcp6' (LP: #1621507).
    note that IPV6PROTO is also written by newer code to address the
    possibility of both ipv4 and ipv6 getting addresses.

    Full syntax is documented at:
    https://git.kernel.org/pub/scm/libs/klibc/klibc.git/plain/usr/kinit/ipconfig/README.ipconfig
    NZDEVICEZDEVICE6z&no 'DEVICE' or 'DEVICE6' entry in dataZPROTOZ	IPV6PROTO�filename�dhcp�none�dhcp6zUnexpected value for PROTO: %sZphysical)�type�name�subnets�mac_address�IPV4�IPV6ZADDRZstaticZmanual)r0Zcontrolr�NETMASK�	BROADCAST�GATEWAY�DNS0�DNS1z:.0Zdns_nameserversZDOMAINSEARCH�,Z
dns_searchr2)r.r-r/)r4r5)r6r7r8)r9r:)
rZload_shell_content�KeyError�
ValueError�get�lower�len�strip�appendr")Zcontentr*�datar1�e�protoZifaceZpreZ	cur_protoZsubnet�keyZdnsZnskey�ns�searchrrr
�_klibc_to_config_entry^sZ








rIcCstjd�tjd�S)Nz/run/net-*.confz/run/net6-*.conf)�globrrrr
r�srcCs�|dkrt�}g}i}x�|D]�}ttj|�|d�\}}||kr�||d}|jd�|jd�kr�tdj|dj||d�|jd�|jd�d���|dj|d�||dj	|�q|g|d	�||<|j	|�qW|d
d�S)N)r*�entryr3zedevice '{name}' was defined multiple times ({files}) but had differing mac addresses: {old} -> {new}.� r))r1r)�old�newr2)r)rK�)�config�version)
rrIrZ	load_filer>r=�format�join�extendrB)r)r*Zentries�namesZcfg_filer1rK�prevrrr
r+�s*
r+cCs(x"tD]}|�}|j�sq|j�SWdS)a
    Return v1 network config for initramfs-configured networking (or None)

    This will consider each _INITRAMFS_CONFIG_SOURCES entry in turn, and return
    v1 network configuration for the first one that is applicable.  If none are
    applicable, return None.
    N)�_INITRAMFS_CONFIG_SOURCESrr)Zsrc_clsZ
cfg_sourcerrr
�read_initramfs_config�s

rXcCs^tj|��J}d}z0ytjd|d�}|j�Stk
r<|SXWd|rN|j�XWdQRXdS)N�rb)�modeZfileobj)�io�BytesIO�gzipZGzipFile�read�IOError�close)�blobZiobufZgzfprrr
�_decomp_gzip�s
rbcCs<ytj|�}Wn$ttfk
r2tjd|�dSXt|�S)z�Decode a string base64 encoding, if gzipped, uncompress as well

    :return: decompressed unencoded string of the data or empty string on
       unencoded data.
    z`Expected base64 encoded kernel commandline parameter network-config. Ignoring network-config=%s.�)�base64Z	b64decode�	TypeErrorr=�LOG�errorrb)rCrarrr
�_b64dgz�srhcCsn|dkrtj�}d|krjd}x*|j�D]}|jd�r&|jdd�d}q&W|rj|tkr\ddiStjt|��SdS)Nznetwork-config=�=rOrPr)rrr"r#�&KERNEL_CMDLINE_NETWORK_CONFIG_DISABLEDZ	load_yamlrh)ZcmdlineZdata64�tokrrr
�read_kernel_cmdline_configs
rl)N)NN)N)rrdrJr]r[Zloggingr$r!Z	cloudinitrZ
cloudinit.netrrr'rjZ	getLoggerr
rf�ABCMetarrrWrIrr+rXrbrhrlrrrr
�<module>s,
4
]


Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 33.43 KB 0644
__init__.cpython-36.pyc File 33.43 KB 0644
activators.cpython-36.opt-1.pyc File 9.52 KB 0644
activators.cpython-36.pyc File 9.52 KB 0644
bsd.cpython-36.opt-1.pyc File 5.74 KB 0644
bsd.cpython-36.pyc File 5.74 KB 0644
cmdline.cpython-36.opt-1.pyc File 7.2 KB 0644
cmdline.cpython-36.pyc File 7.2 KB 0644
dhcp.cpython-36.opt-1.pyc File 15.98 KB 0644
dhcp.cpython-36.pyc File 15.98 KB 0644
eni.cpython-36.opt-1.pyc File 12.89 KB 0644
eni.cpython-36.pyc File 12.89 KB 0644
ephemeral.cpython-36.opt-1.pyc File 10.51 KB 0644
ephemeral.cpython-36.pyc File 10.51 KB 0644
freebsd.cpython-36.opt-1.pyc File 2.54 KB 0644
freebsd.cpython-36.pyc File 2.54 KB 0644
netbsd.cpython-36.opt-1.pyc File 1.69 KB 0644
netbsd.cpython-36.pyc File 1.69 KB 0644
netplan.cpython-36.opt-1.pyc File 11.91 KB 0644
netplan.cpython-36.pyc File 11.91 KB 0644
network_manager.cpython-36.opt-1.pyc File 12.83 KB 0644
network_manager.cpython-36.pyc File 12.83 KB 0644
network_state.cpython-36.opt-1.pyc File 27.57 KB 0644
network_state.cpython-36.pyc File 27.57 KB 0644
networkd.cpython-36.opt-1.pyc File 8.21 KB 0644
networkd.cpython-36.pyc File 8.21 KB 0644
openbsd.cpython-36.opt-1.pyc File 2.18 KB 0644
openbsd.cpython-36.pyc File 2.18 KB 0644
renderer.cpython-36.opt-1.pyc File 1.82 KB 0644
renderer.cpython-36.pyc File 1.82 KB 0644
renderers.cpython-36.opt-1.pyc File 1.53 KB 0644
renderers.cpython-36.pyc File 1.53 KB 0644
sysconfig.cpython-36.opt-1.pyc File 23.07 KB 0644
sysconfig.cpython-36.pyc File 23.07 KB 0644
udev.cpython-36.opt-1.pyc File 1.22 KB 0644
udev.cpython-36.pyc File 1.31 KB 0644