404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.21.105.46: ~ $
3

\�me�5�
@s�UdZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
ddlmZddlmZmZddlmZmZdd	lmZd
Zddd
eegeed�ed�ed�gdgd�Zeee�Zdddiiddgdd�Zddgd�ddgd�ddgd�d�Zeje�Zejd�Z ejd�Z!ed �d!d"�Z"d8d#d$�Z#d9d%d&�Z$e%ee%d'�d(d)�Z&d*d+�Z'd:d,d-�Z(Gd.d/�d/�Z)d;d0d1�Z*e
dd2�d3d4�Z+e,ee
e-dd5�d6d7�Z.dS)<z-Rsyslog: Configure system logging via rsyslog�N)�dedent)�log�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�ALL_DISTROS�Distro)�PER_INSTANCEamThis module configures remote system logging using rsyslog.

Configuration for remote servers can be specified in ``configs``, but for
convenience it can be specified as key value pairs in ``remotes``.

This module can install rsyslog if not already present on the system using the
``install_rsyslog``, ``packages``, and ``check_exe`` options. Installation
may not work on systems where this module runs before networking is up.

.. note::
    On BSD cloud-init will attempt to disable and stop the base system syslogd.
    This may fail on a first run.
    We recommend creating images with ``service syslogd disable``.
Z
cc_rsyslogZRsyslogz$Configure system logging via rsyslogz�            rsyslog:
                remotes:
                    maas: 192.168.1.1
                    juju: 10.0.4.1
                service_reload_command: auto
            a7            rsyslog:
                config_dir: /opt/etc/rsyslog.d
                config_filename: 99-late-cloud-config.conf
                configs:
                    - "*.* @@192.158.1.1"
                    - content: "*.*   @@192.0.2.1:10514"
                      filename: 01-example.conf
                    - content: |
                        *.*   @@syslogd.example.com
                remotes:
                    maas: 192.168.1.1
                    juju: 10.0.4.1
                service_reload_command: [your, syslog, restart, command]
            a            # default (no) configuration with package installation on FreeBSD
            rsyslog:
                config_dir: /usr/local/etc/rsyslog.d
                check_exe: "rsyslogd"
                packages: ["rsyslogd"]
                install_rsyslog: True
            �rsyslog)�id�name�title�descriptionZdistrosZ	frequencyZexamplesZactivate_by_schema_keysz/etc/rsyslog.dz20-cloud-config.conf�autoZrsyslogdF)�
config_dir�config_filename�service_reload_command�remotes�configs�	check_exe�packages�install_rsyslogz/usr/local/etc/rsyslog.d)rrzsysutils/rsyslogz/usr/pkg/etc/rsyslog.d)ZfreebsdZopenbsdZnetbsdz[ ]*[#]+[ ]*z_^(?P<proto>[@]{0,2})(([\[](?P<bracket_addr>[^\]]*)[\]])|(?P<addr>[^:]*))([:](?P<port>[0-9]+))?$)�distrocCs4t}tjt�}|j|kr0tj|||jgdd�}|S)z�Construct a distro-specific rsyslog config dictionary by merging
       distro specific changes into base config.

    @param distro: String providing the distro class name.
    @returns: Dict of distro configurations for ntp clients.
    T)�reverse)�DISTRO_OVERRIDES�copy�RSYSLOG_CONFIGZosfamilyrZ
mergemanydictr)rZdcfg�cfg�r!� /usr/lib/python3.6/cc_rsyslog.py�distro_default_rsyslog_config�s


r#cCs(tj|�rdS|dkrdg}||�dS)aiInstall rsyslog package if not already installed.

    @param install_func: function.  This parameter is invoked with the contents
    of the packages parameter.
    @param packages: list.  This parameter defaults to ['rsyslog'].
    @param check_exe: string.  The name of a binary that indicates the package
    the specified package is already installed.
    Nr
)rZwhich)Zinstall_funcrrr!r!r"r�s
	
rcCs.|dkr |jdd�}|jd|�Stj|dd�S)Nr�rsyslog_svcnamer
z
try-reloadT)Zcapture)�
get_option�manage_servicer)r�command�servicer!r!r"�
reload_syslog�sr))r r�returnc
Cs&|jdi�}t|�}t|jd�t�rhtjddd�d|jd�i}d|krT|d|d<d|krh|d|d	<dgtfd	|d	tfd|dtfd
|d
tfd|dttffd|dtfd
|d
tfd|dtff}xT|D]L\}}}||kr�|||<q�t|||�s�t	d|�d|�dt
||�����q�W|S)z�Return an updated config.

    Support converting the old top level format into new format.
    Raise a `ValueError` if some top level entry has an incorrect type.
    r
z)The rsyslog key with value of type 'list'z22.2)Z
deprecatedZdeprecated_versionrZrsyslog_filenamerZrsyslog_dirrrrrrrzInvalid type for key `z`. Expected type(s): z. Current type: )�getr#�
isinstance�listrZ	deprecate�str�dict�bool�
ValueError�type)r r�mycfgZ
distro_configZfillup�key�defaultZvtypesr!r!r"�load_config�s8
$r6c
Cs�g}x�t|�D]�\}}t|t�rPd|kr:tjd|d�q|d}|jd|�}n|}|}|j�}|svtjd|d�qtjj	||�}d}||kr�d}|j
|�y*d}	|jd	�s�d	}	tj
|||	|d
�Wqtk
r�tjtd|�YqXqW|S)N�contentz%No 'content' entry in config entry %s��filenamezEntry %s has an empty filenameZab�wb��
)�omodezFailed to write to %s)�	enumerater,r/�LOG�warningr+�strip�os�path�join�append�endswithrZ
write_file�	ExceptionZlogexc)
r�	def_fname�cfg_dir�filesZcur_posZentr7r9r=Zendlr!r!r"�apply_rsyslog_changes�s8


rKcCsytj|�\}}|j�}Wntk
r8|d}}YnX|j�j�}d}t|�dkr\|}n"t|�dkrr|\}}ntd|��tj|�}|s�td|��|jd�}|jd�p�|jd�}|jd�}	|jd	�r�|j	d
�r�td|��|r�|r�|}t
|||||	d�}
|
j�|
S)
Nr8�zline had multiple spaces: %szInvalid host specification '%s'�proto�addrZbracket_addr�port�[�]z"host spec had invalid brackets: %s)r�matchrMrNrO)�
COMMENT_RE�splitrAr1�len�HOST_PORT_RErR�group�
startswithrF�SyslogRemotesLine�validate)�liner�dataZcommentZtoksrRZ	host_portrMrNrO�tr!r!r"�parse_remotes_line�s4




r^c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)rYNcCs\|sd}||_||_|sd}|dkr*d}n|dkr6d}||_||_|rRt|�|_nd|_dS)Nz*.*�udp�@z@@�tcp)rrRrMrN�intrO)�selfrrRrMrNrOr!r!r"�__init__&szSyslogRemotesLine.__init__cCsZ|jrHyt|j�Wn2tk
rF}ztd|j�|�WYdd}~XnX|jsVtd��dS)Nzport '%s' is not an integerzaddress is required)rOrbr1rN)rc�er!r!r"rZ;s
zSyslogRemotesLine.validatecCsd|j|j|j|j|jfS)Nz.[name=%s match=%s proto=%s address=%s port=%s])rrRrMrNrO)rcr!r!r"�__repr__GszSyslogRemotesLine.__repr__cCs�|jd}|jdkr|d7}n|jdkr0|d7}d|jkrN|d|jd7}n
||j7}|jrl|d	|j7}|jr�|d
|j7}|S)N� r_r`raz@@�:rPrQz:%sz # %s)rRrMrNrOr)rcZbufr!r!r"�__str__Ps





zSyslogRemotesLine.__str__)NNNNN)�__name__�
__module__�__qualname__rdrZrfrir!r!r!r"rY%s
	rYcCs�|sdSg}|dk	r|j|�xh|j�D]\\}}|s6q(y|jtt||d���Wq(tk
r�}ztjd|||�WYdd}~Xq(Xq(W|dk	r�|j|�dj|�dS)N)rz!failed loading remote %s: %s [%s]r<)rE�itemsr.r^r1r?r@rD)r�header�footer�linesrr[rer!r!r"�remotes_to_rsyslog_cfgds
&
rq)�cloudr*cCsvy|jjdd�Wntjk
r(dSX|jjdd�|jj�tjtj��|jjdd�tjd�WdQRXdS)z�
    This helper function bundles the necessary steps to disable BSD base syslog
    ``rc(8)`` reads its configuration on start, so after disabling syslogd, we
    need to tell rc to reload its config
    ZenabledZsyslogdN�disableZonestopzOsyslogd is running before cloud-init! Please report this as bug to the porters!)	rr&r�ProcessExecutionErrorZreload_init�
contextlib�suppressr?�error)rrr!r!r"� disable_and_stop_bsd_base_syslogvs
rx)rr rr�argsr*c
Cs^d|krtjd|�dSt||j�}|d}|drL|jt|dddd��|jjdd�}|d	d
kr�t|jj|d|dd
�t	j
�r�|jjd|�t|�|ds�tjd�dSt
|d|d|dd�}|s�tjd�dSyt|j|dd�}Wn:tjk
�r0}	zd}tjdt|	��WYdd}	~	XnX|�rZtj�tj|j�tjd||�dS)Nr
z;Skipping module named %s, no 'rsyslog' key in configurationrrz# begin remotesz
# end remotes)rnror$rTrr)rr�enablez.Empty config rsyslog['configs'], nothing to dorr)rrHrIz0restart of syslog not necessary, no changes mader)r'FzFailed to reload syslog %sz%s configured %s files)r?�debugr6rrErqr%rZinstall_packagesrZis_BSDr&rxrKr)rrtr@r.rZ
reset_loggingZ
setup_loggingr )
rr rrryr3rr(ZchangesZ	restartedrer!r!r"�handle�sR


"r|)Nr
)r)N)NN)/�__doc__rurZloggingrB�re�textwraprZ	cloudinitrrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarr	Zcloudinit.distrosr
rZcloudinit.settingsrZMODULE_DESCRIPTION�metarrZ	getLoggerrjr?�compilerSrVr#rr)r/r6rKr^rYrqrxr.r-r|r!r!r!r"�<module>sn



/)
&?


Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 128 B 0644
__init__.cpython-36.pyc File 128 B 0644
cc_ansible.cpython-36.opt-1.pyc File 8.63 KB 0644
cc_ansible.cpython-36.pyc File 8.63 KB 0644
cc_apk_configure.cpython-36.opt-1.pyc File 4.51 KB 0644
cc_apk_configure.cpython-36.pyc File 4.51 KB 0644
cc_apt_configure.cpython-36.opt-1.pyc File 30.42 KB 0644
cc_apt_configure.cpython-36.pyc File 30.42 KB 0644
cc_apt_pipelining.cpython-36.opt-1.pyc File 2.44 KB 0644
cc_apt_pipelining.cpython-36.pyc File 2.44 KB 0644
cc_bootcmd.cpython-36.opt-1.pyc File 2.51 KB 0644
cc_bootcmd.cpython-36.pyc File 2.51 KB 0644
cc_byobu.cpython-36.opt-1.pyc File 3.04 KB 0644
cc_byobu.cpython-36.pyc File 3.04 KB 0644
cc_ca_certs.cpython-36.opt-1.pyc File 7.05 KB 0644
cc_ca_certs.cpython-36.pyc File 7.05 KB 0644
cc_chef.cpython-36.opt-1.pyc File 9.13 KB 0644
cc_chef.cpython-36.pyc File 9.13 KB 0644
cc_disable_ec2_metadata.cpython-36.opt-1.pyc File 1.72 KB 0644
cc_disable_ec2_metadata.cpython-36.pyc File 1.72 KB 0644
cc_disk_setup.cpython-36.opt-1.pyc File 23.1 KB 0644
cc_disk_setup.cpython-36.pyc File 23.1 KB 0644
cc_fan.cpython-36.opt-1.pyc File 2.74 KB 0644
cc_fan.cpython-36.pyc File 2.74 KB 0644
cc_final_message.cpython-36.opt-1.pyc File 3.07 KB 0644
cc_final_message.cpython-36.pyc File 3.07 KB 0644
cc_growpart.cpython-36.opt-1.pyc File 15.91 KB 0644
cc_growpart.cpython-36.pyc File 15.91 KB 0644
cc_grub_dpkg.cpython-36.opt-1.pyc File 4.92 KB 0644
cc_grub_dpkg.cpython-36.pyc File 4.92 KB 0644
cc_install_hotplug.cpython-36.opt-1.pyc File 3.25 KB 0644
cc_install_hotplug.cpython-36.pyc File 3.25 KB 0644
cc_keyboard.cpython-36.opt-1.pyc File 1.98 KB 0644
cc_keyboard.cpython-36.pyc File 1.98 KB 0644
cc_keys_to_console.cpython-36.opt-1.pyc File 3.11 KB 0644
cc_keys_to_console.cpython-36.pyc File 3.11 KB 0644
cc_landscape.cpython-36.opt-1.pyc File 4.71 KB 0644
cc_landscape.cpython-36.pyc File 4.71 KB 0644
cc_locale.cpython-36.opt-1.pyc File 1.58 KB 0644
cc_locale.cpython-36.pyc File 1.58 KB 0644
cc_lxd.cpython-36.opt-1.pyc File 13.04 KB 0644
cc_lxd.cpython-36.pyc File 13.04 KB 0644
cc_mcollective.cpython-36.opt-1.pyc File 4.24 KB 0644
cc_mcollective.cpython-36.pyc File 4.24 KB 0644
cc_migrator.cpython-36.opt-1.pyc File 2.92 KB 0644
cc_migrator.cpython-36.pyc File 2.92 KB 0644
cc_mounts.cpython-36.opt-1.pyc File 14.08 KB 0644
cc_mounts.cpython-36.pyc File 14.08 KB 0644
cc_ntp.cpython-36.opt-1.pyc File 13.15 KB 0644
cc_ntp.cpython-36.pyc File 13.15 KB 0644
cc_package_update_upgrade_install.cpython-36.opt-1.pyc File 3.78 KB 0644
cc_package_update_upgrade_install.cpython-36.pyc File 3.78 KB 0644
cc_phone_home.cpython-36.opt-1.pyc File 4.1 KB 0644
cc_phone_home.cpython-36.pyc File 4.1 KB 0644
cc_power_state_change.cpython-36.opt-1.pyc File 6.24 KB 0644
cc_power_state_change.cpython-36.pyc File 6.24 KB 0644
cc_puppet.cpython-36.opt-1.pyc File 9.46 KB 0644
cc_puppet.cpython-36.pyc File 9.46 KB 0644
cc_reset_rmc.cpython-36.opt-1.pyc File 3.59 KB 0644
cc_reset_rmc.cpython-36.pyc File 3.59 KB 0644
cc_resizefs.cpython-36.opt-1.pyc File 7.02 KB 0644
cc_resizefs.cpython-36.pyc File 7.02 KB 0644
cc_resolv_conf.cpython-36.opt-1.pyc File 4.27 KB 0644
cc_resolv_conf.cpython-36.pyc File 4.27 KB 0644
cc_rh_subscription.cpython-36.opt-1.pyc File 12.06 KB 0644
cc_rh_subscription.cpython-36.pyc File 12.06 KB 0644
cc_rightscale_userdata.cpython-36.opt-1.pyc File 2.77 KB 0644
cc_rightscale_userdata.cpython-36.pyc File 2.77 KB 0644
cc_rsyslog.cpython-36.opt-1.pyc File 10.34 KB 0644
cc_rsyslog.cpython-36.pyc File 10.34 KB 0644
cc_runcmd.cpython-36.opt-1.pyc File 2.43 KB 0644
cc_runcmd.cpython-36.pyc File 2.43 KB 0644
cc_salt_minion.cpython-36.opt-1.pyc File 4.36 KB 0644
cc_salt_minion.cpython-36.pyc File 4.36 KB 0644
cc_scripts_per_boot.cpython-36.opt-1.pyc File 1.4 KB 0644
cc_scripts_per_boot.cpython-36.pyc File 1.4 KB 0644
cc_scripts_per_instance.cpython-36.opt-1.pyc File 1.57 KB 0644
cc_scripts_per_instance.cpython-36.pyc File 1.57 KB 0644
cc_scripts_per_once.cpython-36.opt-1.pyc File 1.51 KB 0644
cc_scripts_per_once.cpython-36.pyc File 1.51 KB 0644
cc_scripts_user.cpython-36.opt-1.pyc File 1.58 KB 0644
cc_scripts_user.cpython-36.pyc File 1.58 KB 0644
cc_scripts_vendor.cpython-36.opt-1.pyc File 2.04 KB 0644
cc_scripts_vendor.cpython-36.pyc File 2.04 KB 0644
cc_seed_random.cpython-36.opt-1.pyc File 4.07 KB 0644
cc_seed_random.cpython-36.pyc File 4.07 KB 0644
cc_set_hostname.cpython-36.opt-1.pyc File 4 KB 0644
cc_set_hostname.cpython-36.pyc File 4 KB 0644
cc_set_passwords.cpython-36.opt-1.pyc File 8.4 KB 0644
cc_set_passwords.cpython-36.pyc File 8.4 KB 0644
cc_snap.cpython-36.opt-1.pyc File 5.94 KB 0644
cc_snap.cpython-36.pyc File 5.94 KB 0644
cc_spacewalk.cpython-36.opt-1.pyc File 2.87 KB 0644
cc_spacewalk.cpython-36.pyc File 2.87 KB 0644
cc_ssh.cpython-36.opt-1.pyc File 11.02 KB 0644
cc_ssh.cpython-36.pyc File 11.02 KB 0644
cc_ssh_authkey_fingerprints.cpython-36.opt-1.pyc File 3.54 KB 0644
cc_ssh_authkey_fingerprints.cpython-36.pyc File 3.54 KB 0644
cc_ssh_import_id.cpython-36.opt-1.pyc File 3.85 KB 0644
cc_ssh_import_id.cpython-36.pyc File 3.85 KB 0644
cc_timezone.cpython-36.opt-1.pyc File 1.24 KB 0644
cc_timezone.cpython-36.pyc File 1.24 KB 0644
cc_ubuntu_advantage.cpython-36.opt-1.pyc File 12.42 KB 0644
cc_ubuntu_advantage.cpython-36.pyc File 12.42 KB 0644
cc_ubuntu_autoinstall.cpython-36.opt-1.pyc File 3.89 KB 0644
cc_ubuntu_autoinstall.cpython-36.pyc File 3.89 KB 0644
cc_ubuntu_drivers.cpython-36.opt-1.pyc File 3.63 KB 0644
cc_ubuntu_drivers.cpython-36.pyc File 3.63 KB 0644
cc_update_etc_hosts.cpython-36.opt-1.pyc File 4.3 KB 0644
cc_update_etc_hosts.cpython-36.pyc File 4.3 KB 0644
cc_update_hostname.cpython-36.opt-1.pyc File 3.01 KB 0644
cc_update_hostname.cpython-36.pyc File 3.01 KB 0644
cc_users_groups.cpython-36.opt-1.pyc File 7.58 KB 0644
cc_users_groups.cpython-36.pyc File 7.58 KB 0644
cc_wireguard.cpython-36.opt-1.pyc File 8.39 KB 0644
cc_wireguard.cpython-36.pyc File 8.39 KB 0644
cc_write_files.cpython-36.opt-1.pyc File 5.61 KB 0644
cc_write_files.cpython-36.pyc File 5.61 KB 0644
cc_write_files_deferred.cpython-36.opt-1.pyc File 1.73 KB 0644
cc_write_files_deferred.cpython-36.pyc File 1.73 KB 0644
cc_yum_add_repo.cpython-36.opt-1.pyc File 6.03 KB 0644
cc_yum_add_repo.cpython-36.pyc File 6.03 KB 0644
cc_zypper_add_repo.cpython-36.opt-1.pyc File 5.66 KB 0644
cc_zypper_add_repo.cpython-36.pyc File 5.66 KB 0644
modules.cpython-36.opt-1.pyc File 7.31 KB 0644
modules.cpython-36.pyc File 7.31 KB 0644
schema.cpython-36.opt-1.pyc File 39.45 KB 0644
schema.cpython-36.pyc File 39.45 KB 0644