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 :  /usr/lib/python3.6/site-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_ntp.cpython-36.pyc
3

?q,d�X�@s�UdZddlZddlZddlmZddlmZddlmZm	Z	m
Z
mZmZddl
mZmZmZddlmZeje�ZeZdZd	Zd
ddd
ddddddddddddgZdddgdddd�ded gd d!dd�d"ed"gd"d!dd�d#d$gd%d&dd�d'�Zd(did(did)�d*dd+�dgdd,�d-�dd.d*iid(diddd+�d/d0id1�d(diddd2�d0d3d4�d1�d(did(did)�d(diddd+�d/d0id1�dd.d*iid5�Zd6d7d8ed9�eed:�ed;�ged<�Zed=d d=d>gd?d@dAdB�dCedD�dE�d?d@dAdB�dCedF�dE�d@dGedH�dI�dJdCedK�dI�edL�d=gd@edM�dN�d@edO�dN�d?dPd@idCedQ�dE�d@edR�dN�d@edS�dN�dT�dUdVdW�dX�dVdY�idZ�Zed/d.d[d(g�Zeee�Zd\d]�Z d^d_�Z!dld`da�Z"dmdbdc�Z#ddde�Z$dndfdg�Z%dhdi�Z&djdk�Z'dS)ozNTP: enable and configure ntp�N)�dedent)�log)�subp�
temp_utils�	templater�
type_utils�util)�
MetaSchema�get_meta_doc�validate_cloudconfig_schema)�PER_INSTANCEz
/etc/ntp.conf��	almalinux�alpineZcentosZ
cloudlinux�debian�	eurolinuxZfedoraZmiraclelinuxZ	openEuler�opensuse�photon�rhelZrocky�sles�ubuntuZ	virtuozzoZchronydz/etc/chrony.conf�chronyzchrony.conf.{distro})�	check_exe�confpath�packages�service_name�
template_name�template�ntpd�ntpzntp.conf.{distro}�ntpdatez/lib/systemd/systemd-timesyncdz-/etc/systemd/timesyncd.conf.d/cloud-init.confzsystemd-timesyncdztimesyncd.conf)rrr zsystemd-timesyncdr)rrz/etc/chrony/chrony.conf)rr)rrr)rrrrz"/usr/lib/systemd/systemd-timesyncd)rrzsystemd-timesyncd)rrz/etc/systemd/timesyncd.conf)rr)rrrrrrrrZcc_ntpZNTPzenable and configure ntpaD        Handle ntp configuration. If ntp is not installed on the system and
        ntp configuration is specified, ntp will be installed. If there is a
        default ntp config file in the image or one is present in the
        distro's ntp package, it will be copied to a file with ``.dist``
        appended to the filename before any changes are made. A list of ntp
        pools and ntp servers can be provided under the ``ntp`` config key.
        If no ntp ``servers`` or ``pools`` are provided, 4 pools will be used
        in the format ``{0-3}.{distro}.pool.ntp.org``.z�        # Override ntp with chrony configuration on Ubuntu
        ntp:
          enabled: true
          ntp_client: chrony  # Uses cloud-init default chrony configuration
        a�        # Provide a custom ntp client configuration
        ntp:
          enabled: true
          ntp_client: myntpclient
          config:
             confpath: /etc/myntpclient/myntpclient.conf
             check_exe: myntpclientd
             packages:
               - myntpclient
             service_name: myntpclient
             template: |
                 ## template:jinja
                 # My NTP Client config
                 {% if pools -%}# pools{% endif %}
                 {% for pool in pools -%}
                 pool {{pool}} iburst
                 {% endfor %}
                 {%- if servers %}# servers
                 {% endif %}
                 {% for server in servers -%}
                 server {{server}} iburst
                 {% endfor %}
          pools: [0.int.pool.ntp.org, 1.int.pool.ntp.org, ntp.myorg.org]
          servers:
            - ntp.server.local
            - ntp.ubuntu.com
            - 192.168.23.2)�id�name�title�description�distrosZexamples�	frequency�objectZnullZarray�stringZhostname)�type�formatTa�                        List of ntp pools. If both pools and servers are
                        empty, 4 default pool servers will be provided of
                        the format ``{0-3}.{distro}.pool.ntp.org``. NOTE:
                        for Alpine Linux when using the Busybox NTP client
                        this setting will be ignored due to the limited
                        functionality of Busybox's ntpd.)r)�itemsZuniqueItemsr$z�                        List of ntp servers. If both pools and servers are
                        empty, 4 default pool servers will be provided with
                        the format ``{0-3}.{distro}.pool.ntp.org``.�autoa�                        Name of an NTP client to use to configure system NTP.
                        When unprovided or 'auto' the default client preferred
                        by the distribution will be used. The following
                        built-in client names can be used to override existing
                        configuration defaults: chrony, ntp, ntpdate,
                        systemd-timesyncd.)r)�defaultr$Zbooleanz�                        Attempt to enable ntp clients if set to True.  If set
                        to False, ntp client will not be configured or
                        installedzu                        Configuration settings or overrides for the
                        ``ntp_client`` specified.z~                                The path to where the ``ntp_client``
                                configuration is written.)r)r$z�                                The executable name for the ``ntp_client``.
                                For example, ntp service ``check_exe`` is
                                'ntpd' because it runs the ntpd binary.r)z�                                List of packages needed to be installed for the
                                selected ``ntp_client``.z�                                The systemd or sysvinit service name used to
                                start and stop the ``ntp_client``
                                service.aM                                Inline template allowing users to define their
                                own ``ntp_client`` configuration template.
                                The value must start with '## template:jinja'
                                to enable use of templating support.
                                )rrrrr�F)r$r)�
propertiesZ
minProperties�additionalProperties)�pools�servers�
ntp_client�enabled�config)r)r/r0)r)r/rcCs0t}tjt�}||kr,tj|||gdd�}|S)z�Construct a distro-specific ntp client 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_CLIENT_CONFIG�copy�NTP_CLIENT_CONFIGr�
mergemanydict)�distroZdcfg�cfg�r=�/usr/lib/python3.6/cc_ntp.py�distro_ntp_client_configs`s

r?cCs�t|j�}|r.|dkr.tjd|�|j|i�S|jdd�}i}|dkr�x:|jD]0}|j|�}tj|jd��rNtjd|�|}PqNW|s�|jd}tjd|�|j|�}ntjd|�|j|i�}|S)	a
Determine which ntp client is to be used, consulting the distro
       for its preference.

    @param ntp_client: String name of the ntp client to use.
    @param distro: Distro class instance.
    @returns: Dict of the selected ntp client or {} if none selected.
    r,z4Selected NTP client "%s" via user-data configurationr3rz+Selected NTP client "%s", already installedrz<Selected distro preferred NTP client "%s", not yet installedz1Selected NTP client "%s" via distro system config)	r?r"�LOG�debug�getZ
get_optionZpreferred_ntp_clientsr�which)r3r;Z
distro_cfgZdistro_ntp_clientZ	clientcfgZclientr<r=r=r>�select_ntp_clientns4



rDcCs(tj|�rdS|dkrdg}||�dS)ahInstall ntp client 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 ['ntp'].
    @param check_exe: string.  The name of a binary that indicates the package
    the specified package is already installed.
    Nr)rrC)Zinstall_funcrrr=r=r>�install_ntp_client�s
	
rEcCs tjj|�rtj||d�dS)z�Rename any existing ntp client config file

    @param confpath: string. Specify a path to an existing ntp client
    configuration file.
    z.distN)�os�path�existsr�rename)rr=r=r>�rename_ntp_conf�srJcCsng}|}|dkrd}n|dks&|dkr*d}x>tdt�D]0}|jdjdd	�t|�g|gd
gD���q6W|S)z�Generate a list of server names to populate an ntp client configuration
    file.

    @param distro: string.  Specify the distro name
    @returns: list: A list of strings representing ntp servers for this distro.
    rrrr�r�.cSsg|]}|r|�qSr=r=)�.0�nr=r=r>�
<listcomp>�sz)generate_server_names.<locals>.<listcomp>zpool.ntp.org)�range�NR_POOL_SERVERS�append�join�str)r;�namesZpool_distro�xr=r=r>�generate_server_names�s(rWc	Cs�|sg}|sg}t|�dkrH|dkrH|dkrHt|�}tjddj|��n2t|�dkrzt|�dkrzt|�}tjddj|��|s�td��|r�|r�td��||d	�}|r�tjd
dd�}|d
}tj	||d�t
j|||�|r�tj|�dS)a&Render a ntp client configuration for the specified client.

    @param distro_name: string.  The distro class name.
    @param service_name: string. The name of the NTP client service.
    @param servers: A list of strings specifying ntp servers. Defaults to empty
    list.
    @param pools: A list of strings specifying ntp pools. Defaults to empty
    list.
    @param path: A string to specify where to write the rendered template.
    @param template_fn: A string to specify the template source file.
    @param template: A string specifying the contents of the template. This
    content will be written to a temporary file before being used to render
    the configuration file.

    @raises: ValueError when path is None.
    @raises: ValueError when template_fn is None and template is None.
    rrrz%Adding distro default ntp servers: %s�,z*Adding distro default ntp pool servers: %sz Invalid value for path parameterz$Not template_fn or template provided)r2r1ztemplate_name-z.tmpl)�prefix�suffixr.)ZcontentN)
�lenrWr@rArS�
ValueErrorrZmkstemprZ
write_filerZrender_to_fileZdel_file)	Zdistro_namerr2r1rG�template_fnrZparamsZtfiler=r=r>�write_ntp_config_template�s2
r^cCsLg}tjt|j���}|r<djt|��}|jdj|d��n"t|j	d�|j	d�g�s^|jd�x�t|j
��D]�\}}d|}|dkr�t|t|t
�g�s�|jd	j||d
��ql|dkr�t|t�s�|jdj||d
��ql|dk�r
|d
kr�qlt|t
��s(|jdj||d
��qlt|t
�sl|jdj||d
��qlW|�rHtdjdj|�d���d
S)aOValidate user-provided ntp:config option values.

    This function supplements flexible jsonschema validation with specific
    value checks to aid in triage of invalid user-provided configuration.

    @param ntp_config: Dictionary of configuration value under 'ntp'.

    @raises: ValueError describing invalid values provided.
    z, z(Missing required ntp:config keys: {keys})�keysrrzJEither ntp:config:template or ntp:config:template_name values are requiredzntp:config:rz6Expected a config file path {keypath}. Found ({value}))�keypath�valuerzHExpected a list of required package names for {keypath}. Found ({value})Nz5Expected a string type for {keypath}. Found ({value})z$Invalid ntp configuration:\n{errors}�
)�errors)rr)�REQUIRED_NTP_CONFIG_KEYS�
difference�setr_rS�sortedrRr*�anyrBr+�all�
isinstancerT�listr\)Z
ntp_configrcZmissingr_�keyrar`r=r=r>�supplemental_schema_validationsJ



rmcCs�d|krtjd|�dS|d}|dkr,i}t|t�sLtdjtj|�d���t|t	�|j
dd�}tj|�r|tjd|�dSt
|j
d	�|j�}tj||j
d
i�gdd�}t|�t|j
d�d
�d}|j
d��s|j
d�jd|jj�}	|j|	�}|�sd|j
d�}
t|
��t|jj|j
d�|j
dg�|j
dg�|j
d�||j
d�d�t|jj|d|dd�y|jjd|j
d��Wn4tjk
�r�}ztjd|��WYdd}~XnXdS)zEnable and configure ntp.rz8Skipping module named %s, not present or disabled by cfgNzL'ntp' key existed in config, but not a dictionary type, is a {_type} instead)Z_typer4Tz)Skipping module named %s, disabled by cfgr3r5)r6r)rrrz{distro}z#No template found, not rendering %srr2r1)rr2r1rGr]rrr)rr�reloadz&Failed to reload/start ntp service: %s)r@rArj�dict�RuntimeErrorr*rZobj_namer�schemarBrZis_falserDr;r:rmrJ�replacer"Zget_template_filenamer^rEZinstall_packagesZmanage_servicerZProcessExecutionErrorZ	exception)r"r<ZcloudrZ_argsZntp_cfgr4Zntp_client_configr]r�msg�er=r=r>�handleUsb






ru)Nr)N)NNNNNN)(�__doc__r8rF�textwraprZ	cloudinitrZloggingrrrrrZcloudinit.config.schemar	r
rZcloudinit.settingsrZ	getLogger�__name__r@r&ZNTP_CONFrQr%r9r7�metarq�	frozensetrdr?rDrErJrWr^rmrur=r=r=r>�<module>s&







	

2



9=

Youez - 2016 - github.com/yon3zu
LinuXploit