403Webshell
Server IP : 159.69.118.108  /  Your IP : 216.73.216.231
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu-4gb-fsn1-1 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 13:53:54 UTC 2025 aarch64
User : root ( 0)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/cloudinit/cmd/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/cloudinit/cmd/__pycache__/clean.cpython-312.pyc
�

��i���8�dZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZmZmZdd
lmZmZmZmZmZej<e�Z dZ!edd
dddgZ"dgZ#de$de%fd�Z&dd�Z'dd�Z(d�Z)d�Z*edk(re*�yy)zFDefine 'clean' utility and handler as part of cloud-init command line.�N)�settings�sources)�	cc_mounts)�uses_systemd)�log_util)�CLOUDINIT_NETPLAN_FILE)�Init)�ProcessExecutionError�runparts�subp)�del_dir�del_file�get_config_logfiles�is_link�
write_filez/etc/machine-idz-/etc/NetworkManager/conf.d/99-cloud-init.confz?/etc/NetworkManager/conf.d/30-cloud-init-ip6-addr-gen-mode.confz@/etc/NetworkManager/system-connections/cloud-init-*.nmconnectionz,/etc/systemd/network/10-cloud-init-*.networkz+/etc/network/interfaces.d/50-cloud-init.cfgz)/etc/ssh/sshd_config.d/50-cloud-init.conf�log_file�returnc���	tj|�}tj|j�stj|j�ry	y#t
$rYywxYw)z�Check if a log file should be removed.

    Avoid tracebacks from attempting to remove device files.

    @param log_file: Path to the log file to check.
    @returns: True if the file should be removed, False otherwise.
    FT)�os�stat�S_ISBLK�st_mode�S_ISCHR�OSError)r�	file_stats  �5/usr/lib/python3/dist-packages/cloudinit/cmd/clean.py�should_remove_log_filer.sZ����G�G�H�%�	��<�<�	�)�)�*�d�l�l�9�;L�;L�.M��/N�������s�AA�	A$�#A$c	��|stjdd��}|jdddddd	�
�|jdddd�
�|jddddd�
�|jdddddd�
�|jddgd�gddd��|S)a#Build or extend an arg parser for clean utility.

    @param parser: Optional existing ArgumentParser instance representing the
        clean subcommand which will be extended to support the args of
        this utility.

    @returns: ArgumentParser with proper argument configuration.
    �cleanzJRemove logs, configs and artifacts so cloud-init re-runs on a clean system)�prog�descriptionz-lz--logs�
store_trueF�remove_logszRemove cloud-init logs.)�action�default�dest�helpz--machine-idz�Set /etc/machine-id to 'uninitialized\n' for golden image creation. On next boot, systemd generates a new machine-id. Remove /etc/machine-id on non-systemd environments.)r$r%r'z-rz--rebootz;Reboot system after logs are cleaned so cloud-init re-runs.z-sz--seed�remove_seedz5Remove cloud-init seed directory /var/lib/cloud/seed.z-cz	--configs)�all�
ssh_config�network�
datasource�fstab�+�
remove_configzbRemove cloud-init generated config files of a certain type. Config types: all, ssh_config, network)�choicesr%�nargsr&r')�argparse�ArgumentParser�add_argument��parsers r�
get_parserr7?s�����(�(��$�
���������
�
&�
��������
C��	��������
J����������
�
D�
�������
���
�2��� �M�c
�R�|j�|r1t|j�D]}t|�s�t	|��|rLt|�j
ddg�r0tD]'}tj|�D]
}t	|���)|r2t|�j
ddg�rtD]
}t	|��|r0t|�j
ddg�rtj�|xrt|�j
ddg�}tjj|jj �s+t#j$dt&t(j*��y|r	|j-�j/�tjj5|jj d
�}tjd|jj z�D]L}||k(r|s�	tjj|�rt7|�st9|�nt	|��N	tCtDjF�y#t0j2$r.t#j$d	t&t(j*��Y��
wxYw#t:$r9}	t#j<dj?|tA|	���Yd
}	~	yd
}	~	wwxYw#tH$r3}	t#j<dtDjF�d|	���Yd
}	~	yd
}	~	wwxYw)a�Helper which removes artifacts dir and optionally log files.

    @param: init: Init object to use
    @param: remove_logs: Boolean. Set True to delete the cloud_dir path. False
        preserves them.
    @param: remove_seed: Boolean. Set True to also delete seed subdir in
        paths.cloud_dir.
    @param: remove_config: List of strings.
        Can be any of: all, network, ssh_config, datasource, fstab.
    @returns: 0 on success, 1 otherwise.
    r)r+r*r-r,zArtifacts already cleaned.)�log�	log_levelrz%No datasource found, nothing cleaned.�seedz%s/*zCould not remove {0}: {1}N�zFailure during run-parts of z: )%�read_cfgr�cfgrr�set�intersection�GEN_NET_CONFIG_FILES�glob�GEN_SSH_CONFIG_FILESr�
cleanup_fstabr�path�isdir�paths�	cloud_dirr�	multi_log�LOG�logging�INFO�fetchrr�DataSourceNotFoundException�joinrr
r�error�format�strrr�CLEAN_RUNPARTS_DIR�	Exception)
�initr#r(r/rrF�conf�clean_datasource�	seed_path�es
          r�remove_artifactsr[�s���	�M�M�O��+�D�H�H�5�	#�H�%�h�/���"�	#���]�+�8�8�%��9K�L�(�	�D��	�	�$��
�����
�	���]�+�8�8�	����)�	�D��T�N�	���]�+�8�8�%��9I�J����!�$���]�);�)H�)H�	���*���7�7�=�=����-�-�.����(���l�l�	
�
��	��J�J�L��� ������T�Z�Z�1�1�6�:�I��	�	�&�4�:�:�#7�#7�7�8�
���9��[��	��w�w�}�}�T�"�7�4�=���
�����
����,�,�-�
��5�2�2�	����7��!�,�,�
�
�	�� �	��N�N�6�=�=�d�C��F�K�L���	��
�����*�8�+F�+F�*G�r�!��M�	
���	�sC�9I!�AJ%�K*�!=J"�!J"�%	K'�..K"�"K'�*	L&�3)L!�!L&c	���tg��}t||j|j|j�}|j
r,t
�rttdd��ntt�|dk(r:|jr.|jjddd�	�}	t|d
��|S|S#t$r;}tj dj#|t%|���d
}Yd}~|Sd}~wwxYw)z3Handle calls to 'cloud-init clean' as a subcommand.)�ds_depszuninitialized
i$)�moder�reboot�nowN)r^�delay�messageF)�capturez-Could not reboot this system using "{0}": {1}r=)r	r[r#r(r/�
machine_idrr�ETC_MACHINE_IDrr_�distro�shutdown_commandrr
rrQrRrS)�name�argsrV�	exit_code�cmdrZs      r�handle_clean_argsrl�s������D� ��d���� 0� 0�$�2D�2D��I�����>��~�'8�u�E�
�^�$��A�~�$�+�+��k�k�*�*����+�
��	���e�$���9���%�	��N�N�?�F�F���Q���
�
�I����	�s�!
B2�2	C6�;0C1�1C6c�r�t�}tjtd|j	���y)z4Tool to collect and tar all cloud-init related logs.rN)r7�sys�exitrl�
parse_argsr5s r�mainrq�s&��
�\�F��H�H�
�w��(9�(9�(;�
<�=r8�__main__)N)FN)+�__doc__r2rCrLrrrn�	cloudinitrr�cloudinit.configr�cloudinit.distrosr�
cloudinit.logr�cloudinit.net.netplanr�cloudinit.stagesr	�cloudinit.subpr
rr�cloudinit.utilr
rrrr�	getLogger�__name__rKrerBrDrS�boolrr7r[rlrq�r8r�<module>r�s���M����	��
�'�&�*�"�8�!�@�@����g����!��"���3�E�F�2�1�
��0���
�S��T��"B�JF
�R�:>��z���F�r8

Youez - 2016 - github.com/yon3zu
LinuXploit