HEX
Server: nginx/1.24.0
System: Linux webserver 6.8.0-87-generic #88-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 09:28:41 UTC 2025 x86_64
User: wpuser (1002)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sos/upload/__pycache__/__init__.cpython-312.pyc
�

([Qhn3��^�ddlZddlZddlZddlZddlmZddlmZddlm	Z	Gd�de�Z
y)�N)�SoSComponent)�_sos)�__version__c���eZdZdZdZidd�dd�dd�dd	�d
d	�dd	�dd	�d
d�dd�dd�dd�dd	�dd	�dd	�dd	�dd	�dd	�Z		d&�fd�	Zed��Zed��Z	d�Z
d�Zd�Zd�Z
d �Zed!��Zed"��Zed#��Zd$�Zd%�Z�xZS)'�	SoSUploadz�
    This class is designed to upload files to a distribution
    defined location. These files can be either sos reports,
    sos collections, or other kind of files like: vmcores,
    application cores, logs, etc.

    z9Upload a file to a user or policy defined remote location�upload_file��case_id�low_priorityF�
upload_urlN�upload_directory�upload_user�upload_pass�
upload_method�auto�upload_no_ssl_verify�upload_protocol�upload_s3_endpointzhttps://s3.amazonaws.com�upload_s3_region�upload_s3_bucket�upload_s3_access_key�upload_s3_secret_key�upload_s3_object_prefix�
upload_targetc�8��|st�|�|||�d|_nb|d|_|d|_|d|_||_||_||_||_	tjd�|_d|_||_
|j�|_d|_y)NT�options�policy�manifest�sos_uiF)�super�__init__�from_cmdline�optsrr�parser�cmdline�args�_upload_file�logging�	getLogger�ui_log�archive�load_upload_targets�upload_targetsr)�selfr$r&r%�in_place�hook_commonsr+�	__class__s       ��5/usr/lib/python3/dist-packages/sos/upload/__init__.pyr!zSoSUpload.__init__4s������G��V�T�7�3� $�D��
%�Y�/�D�I�&�x�0�D�K�(��4�D�M� �D�K�"�D�L��D�I� '�D��!�+�+�H�5�D�K� %�D��"�D�L�"�6�6�8���!���c���d|_|jdd�}|jddd��|jdd	d
d��|jd
dd��|jddd��|jddd��|jdd	dd��|jddd��|jddd��|jddd��|jddd��|jddd ��|jd!dd"��|jd#d$gd%�d&�'�|jd(d$gd)�d*�'�|jd+d,d-d.�/�|jd0d1gd2�d3�'�y)4Nzsos upload FILE [options]zUpload Optionsz.These options control how upload manages filesr�FILEzThe file or archive to upload)�metavar�helpz	--case-id�storer
zspecify case identifier)�action�destr7z--upload-urlz&Upload the archive to specified server)�defaultr7z
--upload-userzUsername to authenticate withz
--upload-passzPassword to authenticate withz--upload-directoryr
z$Specify upload directory for archivez--upload-s3-endpointz#Endpoint to upload to for S3 bucketz--upload-s3-regionz!Region to upload to for S3 bucketz--upload-s3-bucketz"Name of the S3 bucket to upload toz--upload-s3-access-keyzAccess key for the S3 bucketz--upload-s3-secret-keyzSecret key for the S3 bucketz--upload-s3-object-prefixzPrefix for the S3 object/keyz--upload-methodr)r�put�postz HTTP method to use for uploading)r;�choicesr7z--upload-protocol)r�https�ftp�sftp�s3z$Manually specify the upload protocolz--upload-no-ssl-verifyF�
store_truez'Disable SSL verification for upload url)r;r9r7z--upload-target�local)�redhat�	canonical�genericrDzmManually specify vendor-specific target for uploads. Supported options are:
redhat, canonical, generic, local)�usage�add_argument_group�add_argument)�clsr$�
upload_grps   r2�add_parser_optionszSoSUpload.add_parser_optionsLs���2����.�.��<��
�	���
�v�%D�	 �	F�����G�)�%>�	 �	@������%M�	 �	O������%D�	 �	F������%D�	 �	F���� 4�W�%7�%K�	 �	M�	��� 6��%J�	 �	L���� 4�d�%H�	 �	J���� 4�d�%I�	 �	K���� 8�$�%C�	 �	E���� 8�$�%C�	 �	E���� ;�T�%C�	 �	E���� 1�6�(?�%G�	 �	I�	��� 3�V�(N�%K�	 �	M�	��� 8�%�'3�%N�	 �	P�	��� 1�7�)-�
'7�
	 �
	9r3c�H�|jd�|jd�y)NzSoS Upload Detailed Helpz�The upload command is designed to upload already existing sos reports, as well as other files like logs and vmcores to a distribution specific location.)�	set_title�add_text)rK�sections  r2�display_helpzSoSUpload.display_help�s$�����4�5����
3�	
r3c��d}|jjdt�d��|j|�}|jj|�d}|jj
s(	t
|�|jjd�y	y	#t$r|jdd�Yy	t$r}|j|d�Yd	}~y	d	}~wwxYw)
zmPrint the intro message and prompts for a case ID if one is not
        provided on the command line
        a}This utility is used to upload files to a target location based either on a command line option or detecting the local distribution.

The archive to be uploaded may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.

No configuration changes will be made to the system running this utility.
z
sos upload (version �)z,
Press ENTER to continue, or CTRL-C to quit
r	zExiting on user cancel��N)
r*�infor�_fmt_msgr#�batch�input�KeyboardInterrupt�_exit�	Exception)r.�
disclaimer�	intro_msg�prompt�es     r2�introzSoSUpload.intro�s����
�	
�����1�+��a�@�A��M�M�*�-�	�������#�A���y�y���
!��f�
���� � ��$���%�
:��
�
�3�S�9��
!��
�
�1�a� � ��
!�s�+&B�C�0C�8C�Cc��|j|j|jj|jjd�S)N)�cmdlineoptsrr
r
)r#rr
r
)r.s r2�get_commonszSoSUpload.get_commons�s4���9�9��k�k��y�y�(�(� $�	�	� :� :�	
�	
r3c��||_y)zMSet common host data for the Upload targets
            to reference
        N)�commons)r.rgs  r2�set_commonszSoSUpload.set_commons�s����r3c�<�t|jj��}|jj�D]u}|j|�|j	�s�%|j
j}|jjd|�d��||_	|j�|_�w|js3|jd|_	|jj�|_|jjd|j���y)aThis sets the upload target and loads that target's options.

        If no upload target is matched and no target is provided by
        the user, then we abort.

        If an upload target is provided in the command line,
        this will not run.
        zInstallation matches z, checking for upload targetsrGzUpload target set to N)
�listr-�values�remove�check_distributionr1�__name__r*�debugr�name�upload_namerW)r.�checksr�cnames    r2�determine_upload_targetz!SoSUpload.determine_upload_target�s����d�)�)�0�0�2�3��!�0�0�7�7�9�	8�M��M�M�-�(��/�/�1�%�/�/�8�8�����!�!�$9�%��A4�#4�5�%2��"�#0�#5�#5�#7�� �	8��!�!�!%�!4�!4�Y�!?�D��#�1�1�6�6�8�D�������+�D�,<�,<�+=�>�	@r3c�$�ddl}i}|j|jjd�D]`}|d|j|j
|j��}|j|j��|||j�<�b|S)zELoads all upload targets supported by the local installation
        rN�targetsrV)r$r&r%)
�sos.upload.targets�
_load_modules�uploadrvr$r&r%rhre�
get_target_id)r.�sos�supported_upload_tgtsr�target_classs     r2r,zSoSUpload.load_upload_targets�s���	"� "��!�/�/��
�
�0B�0B�I�N�	O�M�+�=��+�#'�;�;�!%���$(�L�L��L�

�$�$�T�%5�%5�%7�8�BN�!�,�"<�"<�">�?�	O�%�$r3c��g}|jD]C}tjj|�s�#|j	|j||���E|S)zHelper to import upload targets)�__path__�os�path�isdir�extend�_find_modules_in_path)rK�package�submod�modulesr�s     r2rxzSoSUpload._load_modules�sP�����$�$�	H�D��w�w�}�}�T�"����s�8�8��v�F�G�	H��r3c�P�g}tjj|�r�ttj|��D]c}|jd�s�d|vr�tjj
|�\}}d|�d|��}|j|j|���e|S)aUGiven a path and a module name, find everything that can be imported
        and then import it

            path - the filesystem path of the package
            modulename - the name of the module in the package

        E.G. a path of 'targets', and a modulename of 'redhat' equates to
        importing sos.upload.targets.redhat
        z.py�__zsos.upload.�.)	r�r��exists�sorted�listdir�endswith�splitextr��_import_modules)rKr��
modulenamer��pyfile�fname�_�modnames        r2r�zSoSUpload._find_modules_in_path�s�����
�7�7�>�>�$�� ����D�!1�2�
=�����u�-���6�>���7�7�+�+�F�3���q�'�
�|�1�U�G�<�����s�2�2�7�;�<�
=��r3c�8�|jd�d}	t|t�t�|g�}tj|t
j�}|j�D]}|ddvs�|j|��|S#t$r}|�d}~wwxYw)z/Import and return all found classes in a moduler��Nr)�DeviceAuthorizationClass�Upload�
RHELPolicy�UbuntuPolicy)
�split�
__import__�globals�locals�ImportError�inspect�
getmembers�isclass�copyrl)rKr��mod_short_name�modulerar��mods       r2r�zSoSUpload._import_modules�s���!���s�+�A�.��	�����F�H�~�>N�O�F��$�$�V�W�_�_�=���<�<�>�	$�C��1�v�$�$�
���s�#�
	$�����	��G��	�s�B	�		B�B�Bc��|j�|_|jd}|jr|jj	�yy)Nrd)rergrr�_configure_low_priority)r.�cmdline_optss  r2�pre_workzSoSUpload.pre_works>���'�'�)����|�|�M�2���$�$��K�K�/�/�1�%r3c
��|j�|jrV|j�|jj|_|jj|j��|_|jj}|r|dk7r|j||_	n|j�|js0|jjd�tjd�|jj|j!��	t#j$|j
�j&dkDr�t"j(j+|j
�rY	|jj-|j
�|jj/t1d|j
�d���y|jjt1|j
�d	���y|jjt1d|j
�d
���y#t2$rF}|jjt1d|����tjd�Yd}~yd}~wwxYw#t2$r?}|jjt1d|j
�d|�d
���Yd}~yd}~wwxYw)N)r�rDz|No upload target set via command line options or autodetected.
Please specify one using the option --upload-target.
Exiting.rVrzFile z uploaded successfullyzUpload attempt failed: z is not a file.z
 is empty.zCannot upload z: � )r�r"rbr#rr+r�prompt_for_case_id�caseidrr-rtr*�error�sys�exitrer��stat�st_sizer��isfile�upload_archiverWr�r])r.�cmdline_target�errras    r2�executezSoSUpload.executes���
�
������J�J�L��9�9�0�0�D�L��+�+�8�8�!�Y�Y�9��D�K����0�0���n��7�!%�!4�!4�^�!D�D���(�(�*��!�!�
�K�K����
�
�H�H�Q�K����#�#�D�$4�$4�$6�7�	H��w�w�t�|�|�$�,�,�q�0��7�7�>�>�$�,�,�/�$��*�*�9�9�$�,�,�G����(�(���d�l�l�^�3I�J�K���K�K�%�%�a�4�<�<�.��(H�&I�J����!�!�!�e�D�L�L�>��$D�"E�F��
%�$����)�)�!�.E�c�U�,K�*L�M��������$���	H��K�K���a�.�����b���1� E�F�G�G��	H�sJ�AJ�1AH.�	1J�;2J�.	I=�7<I8�3J�8I=�=J�	K�	5K�K)NNNFNN)rn�
__module__�__qualname__�__doc__�desc�arg_defaultsr!�classmethodrMrRrbrerhrtr,rxr�r�r�r��
__classcell__)r1s@r2rrsy����K�D���r���2��	���	�d�	�
	�D��	�t�
�	�t��	���	���	�6��	�8��	�D��	�D��	���	��� 	"�4�!�"	��#�L�(GL�,0�"�0�29��29�h�
��
�!�<
��@�0
%���������,����"2�(Hr3r)r�r�r(r��
sos.componentrr{rr�rr�r3r2�<module>r�s,��
�
���&���kH��kHr3