403Webshell
Server IP : 167.99.254.82  /  Your IP : 216.73.216.188
Web Server : Apache
System : Linux host.techisquad.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64
User : pawluxera ( 1011)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/cloudinit/config/__pycache__/cc_ntp.cpython-310.pyc
o

��iL�@sNUdZddlZddlZddlZddlmZmZddlmZm	Z	m
Z
mZmZddl
mZddlmZddlmZddlmZe�e�ZeZd	Zd
Zgd�Zdd
dgdddd�dedgdddd�dedgdddd�ddgdddd�ddgdddd�d�Zidddd�d	gdd �d!��d"dd#d$d%�i�d&d'did#d$d%�d(��d)d'did'did*��d+dddd,�i�d-dd.dii�d/d	ddd0�d1dgddd2�d3d4d5gd5d6d7�d8��d9d'did#d$d%�d(��d:d5ii�d;d'did	dd�d<did=��d>d'did	dd�d<d#id=��d?d'didd	d,�d#d$d%�d=��d@dd<d#ii�dAd'did'did*��dBd'did	dd�d<d#id=��dCdd.dii�ZeeefedD<dED]	Z ed>ee <�q8dFD]	Z edAee <�qDdGD]	Z edBee <�qPdHeedgdI�Z!eedJ<e"gdK��Z#dLdM�Z$dNefdOdP�Z%dadQdR�Z&dbdSdT�Z'dUdV�Z(								dcdWdX�Z)dYdZ�Z*d[ed\ed]ed^e+dNdf
d_d`�Z,dS)dzNTP: enable and configure ntp�N)�Dict�Mapping)�subp�
temp_utils�	templater�
type_utils�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCEz
/etc/ntp.conf�)�	almalinux�alpine�aosc�
azurelinux�centos�
cloudlinux�cos�debian�	eurolinux�fedora�freebsd�mariner�miraclelinux�openbsd�	openeuler�OpenCloudOS�openmandriva�opensuse�opensuse-microos�opensuse-tumbleweed�
opensuse-leap�photon�raspberry-pi-os�rhel�rocky�sle_hpc�	sle-micro�sles�	TencentOS�ubuntu�	virtuozzo�chronydz/etc/chrony.conf�chronyzchrony.conf.{distro})�	check_exe�confpath�packages�service_name�
template_name�template�ntpd�ntpsec�ntpzntp.conf.{distro}�ntpdatez/etc/ntpd.confzntpd.conf.{distro}z/lib/systemd/systemd-timesyncdz-/etc/systemd/timesyncd.conf.d/cloud-init.conf�systemd-timesyncdztimesyncd.conf)r.r7r8�openntpdr9rz/etc/chrony/chrony.conf)r0r2)r0r1r2)r.r7rz"/usr/lib/systemd/systemd-timesyncdz/etc/systemd/timesyncd.conf)r/r0rr2)r.r9r)r7r.r)r2r0rr0r)r0r2r3z/usr/local/etc/chrony.conf)r0r1r2r3z/usr/local/sbin/ntpdz/usr/local/etc/ntp.confr:zntpd.conf.openbsd)r/r0r1r2r3)r7r.r:rrrr/)r.r7r9rr#r$r%r)r+�DISTRO_CLIENT_CONFIG)r r!r")rrr&)r'r(�cc_ntp)�id�distros�	frequency�activate_by_schema_keys�meta)r/r0r1r2cCs0t}t�t�}||vrtj|||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)r;�copy�NTP_CLIENT_CONFIGr�
mergemanydict)�distro�dcfg�cfg�rJ�9/usr/lib/python3/dist-packages/cloudinit/config/cc_ntp.py�distro_ntp_client_configss

rL�returncCs�t|j�}|r|dkrt�d|�|�|i�S|�dd�}i}|dkrU|jD]}|�|�}t�|�d��r?t�d|�|}nq&|sS|jd}t�d|�|�|i�}|St�d|�|�|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.
    �autoz4Selected NTP client "%s" via user-data configuration�
ntp_clientr/z+Selected NTP client "%s", already installedrz<Selected distro preferred NTP client "%s", not yet installedz1Selected NTP client "%s" via distro system config)	rL�name�LOG�debug�get�
get_option�preferred_ntp_clientsr�which)rOrG�
distro_cfg�distro_ntp_client�	clientcfg�clientrIrJrJrK�select_ntp_client!s@

�

��
���r[cCst�|�rdS||�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.
    N)rrV)�install_funcr1r/rJrJrK�install_ntp_clientSs
	r]cCs$tj�|�rt�||d�dSdS)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�r0rJrJrK�rename_ntp_confbs�rccCshg}|}|dkrd}n
|dks|dkrd}tt�D]}|�d�dd�t|�g|gd	gD���q|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.
    r)rrr��.cSsg|]}|r|�qSrJrJ)�.0�nrJrJrK�
<listcomp>�sz)generate_server_names.<locals>.<listcomp>zpool.ntp.org)�range�NR_POOL_SERVERS�append�join�str)rG�names�pool_distro�xrJrJrK�generate_server_namesls��rqc	Cs�|sg}|sg}|sg}|sg}|s|s|dkrdS|s2|dkr2|dkr2t|�}t�dd�|��n|sC|sCt|�}t�dd�|��|sItd��|sQ|sQtd	��||||d
�}	|rltjddd
�}
|
d}tj||d�t	�
|||	�|r|t�|�dSdS)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 allow: A list of strings specifying a network/CIDR. Defaults to
    empty list.
    @param peers: A list nodes that should peer with each other. 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.
    rNrr5z%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)�servers�pools�allow�peersztemplate_name-z.tmpl)�prefix�suffix�)�content)rqrQrRrl�
ValueErrorr�mkstempr�
write_filer�render_to_file�del_file)�distro_namer2rsrtrurvr_�template_fnr4�params�tfilerJrJrK�write_ntp_config_template�sF 
���r�cCsBg}t�t|����}|rd�t|��}|�dj|d��nt|�	d�|�	d�g�s/|�d�t|�
��D]\\}}d|}|dkrUt|t|t
�g�sT|�d	j||d
��q5|dkrit|t�sh|�dj||d
��q5|d
vr�|durrq5t|t
�s�|�dj||d
��q5t|t
�s�|�dj||d
��q5|r�tdjd�|�d���dS)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})�keysr4r3zJEither ntp:config:template or ntp:config:template_name values are requiredzntp:config:r0z6Expected a config file path {keypath}. Found ({value}))�keypath�valuer1zHExpected a list of required package names for {keypath}. Found ({value}))r4r3Nz5Expected a string type for {keypath}. Found ({value})z$Invalid ntp configuration:\n{errors}�
)�errors)�REQUIRED_NTP_CONFIG_KEYS�
difference�setr�rl�sortedrk�format�anyrS�items�all�
isinstancerm�listr{)�
ntp_configr��missingr��keyr�r�rJrJrK�supplemental_schema_validation�sn

������
���
���
������r�rPrI�cloud�argscCs�d|vrt�d|�dS|d}|duri}t|t�s&tdjt�|�d���|�dd�}t	�
|�r9t�d|�dSt|�d	�|j�}t	j
||�d
i�gdd�}t|�t|�d�d
�d}|�d�s~|d�d|jj�}|�|�}|s~d|�d�}	t|	��t�d|�d��t�d|�dg��t�d|�dg��t�d|�dg��t�d|�dg��t|jj|�d�|�dg�|�dg�|�dg�|�dg�|�d�||�d�d�	t|jj|d|dd�t	���rF|�d�d k�r%z	|j�d!d �Wntj�y
t�d"�Ynwz	|j�d#d �Wntj�y$t�d$�Ynwz|j�d%|d�Wntj�yE}
zt�d&|
��d}
~
wwz|j�d'|d�WdStj�yg}
zt�d(|
��d}
~
ww))zEnable and configure ntp.r7z8Skipping module named %s, not present or disabled by cfgNzL'ntp' key existed in config, but not a dictionary type, is a {_type} instead)�_type�enabledTz)Skipping module named %s, disabled by cfgrO�configrBr0rbr4r3z{distro}z#No template found, not rendering %szservice_name: %sr2zservers: %srsz	pools: %srtz	allow: %sruz	peers: %srv)r2rsrtrurvr_r�r4r1r/)r1r/r5�stopz Failed to stop base ntpd service�disablez#Failed to disable base ntpd service�enablez Failed to enable ntp service: %s�reloadz&Failed to reload/start ntp service: %s)rQrRr��dict�RuntimeErrorr�r�obj_namerSr�is_falser[rGrFr�rc�replacerP�get_template_filenamer�r]�install_packages�is_BSD�manage_servicer�ProcessExecutionError�warning�	exception)rPrIr�r��ntp_cfgr��ntp_client_configr�r3�msg�erJrJrK�handles��

��
��
�
��



��
�����
���r�)Nr5)N)NNNNNNNN)-�__doc__rD�loggingr^�typingrr�	cloudinitrrrrr�cloudinit.cloudr	�cloudinit.configr
�cloudinit.config.schemar�cloudinit.settingsr�	getLogger�__name__rQr?�NTP_CONFrjr>rEr;rm�__annotations__rGrA�	frozensetr�rLr[r]rcrqr�r�r�r�rJrJrJrK�<module>s�
$�	�	�	�	��,���������������#���)���.�����B����K��N�����Z�����f����p���u����}�����
����	��
2


�M"=

Youez - 2016 - github.com/yon3zu
LinuXploit