Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/softwareproperties/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/softwareproperties/__pycache__/SoftwareProperties.cpython-310.pyc
o

U�7e�}�@s�ddlmZmZddlZddlZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
zddlmZWneyFejZYnwddlZzddlZWn
ey^ddlZYnwddl
mZddlmZzddlmZWney�ddlmZYnwddlmZddlZddlZddlZd	d
lmZddl m!Z!m"Z"ddl#m$Z$dd
l%m&Z&ddl'm(Z(Gdd�de)�Z*e+dkr�e*�Z,e-e,�.��e,�/d�dSdS)�)�absolute_import�print_functionN)�md5)�	maketrans)�NamedTemporaryFile)�escape)�ConfigParser)�gettext�)�AptAuth)�SourcesList�SourceEntry)�InvalidShortcutException)�shortcut_handler)�Gioc@s�eZdZdZdZeed��\ZZZ	edede	diZ
dud	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dGdH�Z*dIdJ�Z+dKdL�Z,dMdN�Z-dOdP�Z.dQdR�Z/dSdT�Z0dUdV�Z1dWdX�Z2dYdZ�Z3d[d\�Z4d]d^�Z5d_d`�Z6dvdbdc�Z7dvddde�Z8dwdgdh�Z9didj�Z:dkdl�Z;dmdn�Z<dodp�Z=dqdr�Z>e?dxdsdt��Z@dS)y�SoftwarePropertiesz /usr/share/app-install/channels/z$/etc/update-manager/release-upgrades��normal�lts�neverN�/cCs�|d|_||_|dkrtj�d|�|dkrd}||_||_t�|_t	j
��|_
g|_d|_
|��|��|��g|_t��|_t|d�|_t��|_t�|j�dS)z� Provides the core functionality to configure the used software 
        repositories, the corresponding authentication keys and 
        update automation z/etc/popularity-contest.confr�DirNz/usr/share/software-properties/F)�rootdir)�
popconfiler�apt_pkg�config�set�options�datadirr�sourceslist�
aptsources�distro�
get_distro�seen_server�modified_sourceslist�reload_sourceslist�backup_sourceslist�backup_apt_conf�custom_mirrors�queue�Queue�myqueuer�apt_keyr�Cancellable�cancellable�atexit�register�wait_for_threads)�selfrrr�r3�G/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py�__init__Xs(


zSoftwareProperties.__init__cCs*t��D]}|jt��jkr|��qdS)z9 wait for all running threads (PPA key fetchers) to exit N)�	threading�	enumerate�ident�current_thread�join)r2�tr3r3r4r1�s
��z#SoftwareProperties.wait_for_threadscCs6i|_tj��D]}tj�tj|�}||j|<qdS)z$Backup all apt configuration optionsN)�apt_conf_backup�softwareproperties�CONF_MAP�keysrr�find_i)r2�option�valuer3r3r4r'�s
�z"SoftwareProperties.backup_apt_confcCs:|j��D]}tj�tj|t|j|��q|��dS)z$Restore the stored apt configurationN)	r<r?rrrr=r>�str�write_config)r2rAr3r3r4�restore_apt_conf�s
�z#SoftwareProperties.restore_apt_confcCs�tj�tjd�dkrStj�tjd�dkrtj�d�rtjStj�tjd�dkr8tj�tjd�dkr8tj	Stj�tjd�dkrQtj�tjd�dkrQtj
SdStj�tjd�dkrltj�tjd�dkrltjSdS)z� Parse the apt cron configuration. Try to fit a predefined use case 
        and return it. Special case: if the user made a custom 
        configurtation, that we cannot represent it will return None �
autoupdater�
unattendedr
z/usr/bin/unattended-upgrade�autodownloadN)rrr@r=r>�os�path�exists�UPDATE_INST_SEC�UPDATE_DOWNLOAD�
UPDATE_NOTIFY�
UPDATE_MANUAL�r2r3r3r4�get_update_automation_level�s 
�z.SoftwareProperties.get_update_automation_levelcCs|tjkrtj�tjdtd��tj�tjdtd��n`|tjkr<tj�tjdtd��tj�tjdtd��nB|tjkrZtj�tjdtd��tj�tjdtd��n$tj�tjdtd��tj�tjdtd��tj�tjdtd��|�	�dS)z� Set the apt periodic configurtation to the selected 
        update automation level. To synchronize the cache update and the 
        actual upgrading function, the upgrade function, e.g. unattended, 
        will run every day, if enabled. rGr
rHrrFN)
r=rLrrrr>rCrMrN�set_modified_config)r2�stater3r3r4�set_update_automation_level�s


z.SoftwareProperties.set_update_automation_levelcCs>|tj�tjd�kstj�tjdt|��|��dSdS)z8Set the interval in which we check for available updatesrFN)rrr@r=r>rrCrR)r2�daysr3r3r4�set_update_interval�s�z&SoftwareProperties.set_update_intervalcCstj�tjd�S)z3 Returns the interval of the apt periodic cron job rF)rrr@r=r>rPr3r3r4�get_update_interval�sz&SoftwareProperties.get_update_intervalcCsltj�|j�s
|jSt�}|�|j�|�dd�r3|�dd��	�}|j
��D]\}}||kr2|Sq&|jS)z�
    return the release upgrade policy:
     RELEASE_UPGRADES_NORMAL,
     RELEASE_UPGRADES_LTS,
     RELEASE_UPGRADES_NEVER
    �DEFAULT�Prompt)rIrJrK�RELEASE_UPGRADES_CONF�RELEASE_UPGRADES_NORMALr�read�
has_option�get�lower�release_upgrades_policy_map�items)r2�parser�type�k�vr3r3r4�get_release_upgrades_policy�s�z.SoftwareProperties.get_release_upgrades_policyc	Cs,tj�|j�s*t|jd��}|�d|j|�Wd�dS1s#wYdSt|jd��\}tdd��>}|D]}|��}|�	��
d�rQ|�d	|j|�q9|�|d
�q9|��t�
|j|j�t�|j|j�Wd�n1swwYWd�dSWd�dS1s�wYdS)z
    set the release upgrade policy:
     RELEASE_UPGRADES_NORMAL,
     RELEASE_UPGRADES_LTS,
     RELEASE_UPGRADES_NEVER
     �wz[DEFAULT]
Prompt=%s
NT�rzw+)�mode�promptz
Prompt=%s
�
)rIrJrKrZ�open�writer`r�stripr_�
startswith�flush�shutil�copymode�name�copy)r2�i�f�out�liner3r3r4�set_release_upgrades_policy�s,
��(�
�
�
z.SoftwareProperties.set_release_upgrades_policyc	Cs�tj�|j�rKt|j��}|���d�}Wd�n1swY|D]%}z|�d�\}}|dkr@|�d���dkr@WdSWq%t	yJYq%wdS)	z� Will return True if the user wants to participate in the popularity 
        contest. Otherwise it will return False. Special case: if no 
        popcon is installed it will return False rkN�=�PARTICIPATE�"�yesTF)
rIrJrKrrlr\�splitrnr_�
ValueError)r2rv�linesrx�keyrBr3r3r4�get_popcon_participation�s���z+SoftwareProperties.get_popcon_participationcs|dkrd�nd�tj�|j�r0t|jd��}�fdd�|D�}Wd�n1s*wYn;t�}tdd	��}|�|�d
��Wd�n1sKwY|��}g}|�	d|�|�	dt
���|�	d
�t|jd��}|�|�Wd�dS1s�wYdS)z? Enable or disable the participation in the popularity contest Tr}�norhcsg|]}t�dd�|��qS)z^(PARTICIPATE=)(".+?")z\1"%s")�re�sub)�.0rx�rBr3r4�
<listcomp>s�z@SoftwareProperties.set_popcon_pariticipation.<locals>.<listcomp>Nz/dev/urandom�rbizMY_HOSTID="%s"
zPARTICIPATE="%s"
zUSE_HTTP="yes"
rg)rIrJrKrrlr�updater\�	hexdigest�appendrC�
writelines)r2�
is_helpfulrr��mrv�idr3r�r4�set_popcon_pariticipations,
����
"�z,SoftwareProperties.set_popcon_pariticipationcCst|jj�dkrd|j_dSd|j_i}g}|�|jj�|�|jj�|D]}|j|vr<|jD]
}||j�	|�q0q&t
|j�||j<q&t|jj�dkrU|jj||jj
<|jjD]0}|j|vs�|j|vr�tt
||j�t
|j�A�dks�tt
|j�|jjA�dks�d|j_dSqYdS)z�Return True if all distro componets are also available as 
       source code. Otherwise return Flase. Special case: If the
       configuration cannot be represented return Noner
FTrN)�lenr!�source_code_sources�get_source_code�extend�main_sources�
child_sources�template�comps�addr�
cdrom_sources�cdrom_comps�source_template�
enabled_comps)r2�	templates�sources�source�compr3r3r4�get_source_code_states2

�

 �z(SoftwareProperties.get_source_code_statecCs�d|jfd|jfd|jfd|jffD]\}}td||f�q|jr=d|jjfd|jjffD]\}}td||f�q0td�d	S)
z4Print the data of a source entry to the command linezURI:zComps:zEnabled:zValid:z %s %sz	MatchURI:zBaseURI:rkN)�urir��disabled�invalid�printr��	match_uri�base_uri)r2r��labelrBr3r3r4�print_source_entryFs

�

�z%SoftwareProperties.print_source_entrycCs,td�|jD]}t|���qtd�dS)zPrint the complete sources.listzSTART SOURCES.LIST:zEND SOURCES.LIST
N)r�rrC�r2r�r3r3r4�massive_debug_outputSs
z'SoftwareProperties.massive_debug_outputcCs ||j_|j�|�}|��|S)z! change the main download server )r!�default_server�
change_server�set_modified_sourceslist)r2�server�resr3r3r4�change_main_download_serverZsz.SoftwareProperties.change_main_download_servercC�|j�|�|��dS)z Enable a component of the distroN)r!�enable_componentr��r2r�r3r3r4r�a�z#SoftwareProperties.enable_componentcCr�)z!Disable a component of the distroN)r!�disable_componentr�r�r3r3r4r�fr�z$SoftwareProperties.disable_componentcCs&|jjjD]}|j|kr|SqdS�N)r!r��childrenrs)r2rsr�r3r3r4�_find_template_from_stringks

��z-SoftwareProperties._find_template_from_stringcCsht|t�r
|�|�}|jjD]
}|j|kr|j�|�q|jjD]
}|j|kr-|j�|�q |�	�dS)�7Enable a child repo of the distribution main repositoryN)
�
isinstancerCr�r!r�r�r�remover�r�)r2r�r�r3r3r4�disable_child_sourceps


�
�z'SoftwareProperties.disable_child_sourcecCsLt|t�r
|�|�}|jdkr|jj}n|j}|jj||jd�|��dS)r�N)r��dist)	r�rCr�r�r!r��
add_sourcersr�)r2r��	child_urir3r3r4�enable_child_source}s



z&SoftwareProperties.enable_child_sourcecCsFg}|�|jj�|�|jj�|jjD]}|j�|�q|��dS)z%Remove all distro source code sourcesN)r�r!r�r�r�rr�r��r2r�r�r3r3r4�disable_source_code_sources�sz.SoftwareProperties.disable_source_code_sourcescCs�g}|�|jj�|�|jj�|jjD]}|j�|�q|D]}|j�d|j|j	|j
d|jj�|�d|j
�q|jjD]}|j�d|jjj|jjj|j
d|jj�|�d|j
�q=|��dS)z0Enable source code source for all distro sources�deb-srczAdded by software-propertiesr
N)r�r!r�r�r�rr�r�r�r�r��list�index�filer�r�r�rsr�r�r3r3r4�enable_source_code_sources�s0��z-SoftwareProperties.enable_source_code_sourcescCs4g|_|jjD]}t|j|jd�}|j�|�qdS)z+Store a backup of the source.list in memory�rxr�N)�sourceslist_backuprr�r
rxr�r�)r2r��
source_bkpr3r3r4r&�s
�z%SoftwareProperties.backup_sourceslistcCs.|��|jjD]}t|�|kr|SqdSr�)r%rr�rC)r2rxr�r3r3r4�_find_source_from_string�s�z+SoftwareProperties._find_source_from_stringcCs*t|t�r
|�|�}|j|_|��dS)z&Enable or disable the selected channelN)r�rCr�r�r�r�r3r3r4�toggle_source_use�s


z$SoftwareProperties.toggle_source_usecCsTt|jj�D]!\}}t|�|kr'|jj|j}t||�|jj|<|��dSqdS)NTF)r7rr�rCr�r
r�)r2�	old_entry�	new_entryr��entryr�r3r3r4�replace_source_entry�s�z'SoftwareProperties.replace_source_entrycCs|��|��dS)zNRevert all settings to the state when software-properties 
       was launchedN)rE�revert_sourceslistrPr3r3r4�revert�szSoftwareProperties.revertcCsFg|j_|jD]}t|j|jd�}|jj�|�q|��|��dS)z6Restore the source list from the startup of the dialogr�N)	rr�r�r
rxr�r��save_sourceslistr%)r2r��source_resetr3r3r4r��s
z%SoftwareProperties.revert_sourceslistcCs0d|_|jr|jjr|��|��|��dS)zCThe sources list was changed and now needs to be saved and reloadedTN)r$r�
massive_debugr�r�r%rPr3r3r4r��s
z+SoftwareProperties.set_modified_sourceslistcCs|��dS)z+Write the changed apt configuration to fileN)rDrPr3r3r4rR�sz&SoftwareProperties.set_modified_configcCsV|jdkr`|jr=dt|j���|jf}t|j�dkr'|jD]}|d|7}q|jdvr4|dtd�7}|d|j	7}|Sd|j	|jf}|jD]}|d|7}qH|jdvr^|dtd�7}|Sd	|jj
}|jdvrs|d
td�7}|jr}|d|j7}|jjdkr�|jD]"}|j�|�r�|jj
D]}|j|kr�|d|j
7}q�q�|d|7}q�|S)
z5Render a nice output to show the source in a treeviewNz<b>%s</b> %sr
z %s)r�zrpm-srcz
(Source Code)z
%sz<b>%s %s</b>z	<b>%s</b>z (%s)zSource CodeF)r��commentrrnr�r�r�rc�_r��description�child�
has_component�
componentsrs)r2r��contents�cr�r3r3r4�
render_source�sB
�

�




��z SoftwareProperties.render_sourcecCs�d}d}d}d}tdd�}|jr d}|jj}|jj|jkrd}nd|j|j|jf}|jr/d}|j	�
d�r7d}|||||�|�fS)z&extract attributes to sort the sourcesr
�
0123456789�
9876543210rz%s %s %s�src)rr�r��distributionr!r�r�r�r�rc�find�	translate)r2r��cur_sys�has_template�has_comment�	is_source�revert_numbers�descr3r3r4�get_comparables&
��z!SoftwareProperties.get_comparablecCsbg}|jjD](}|js.||jjvr.||jjvr.||jjvr.||jjvr.||jjvr.|�	|�q|S)z>Return a list of sources that are not part of the distribution)
rr�r�r!r�r�r��disabled_sourcesr�r�)r2�isv_sourcesr�r3r3r4�get_isv_sources,s
�z"SoftwareProperties.get_isv_sourcescCs|jjS)z-Return the list of CDROM based distro sources)r!r�rPr3r3r4�get_cdrom_sources9sz$SoftwareProperties.get_cdrom_sourcescCs|j|jjvdfS)z�Return a tuple: the first value describes if a component is enabled
       in the Internet repositories. The second value describes if the
       first value is inconsistent.F)rsr!�download_compsr�r3r3r4�get_comp_download_state=sz*SoftwareProperties.get_comp_download_statecCs|g}|jjD]
}|j|kr|�|j�qt|�dkr(t|jjt|�A�dkr(dSt|�dkr<t|jjt|�A�dkr<dSdS)z�Return a tuple: the first value describes if a component is enabled
       in one of the child source that matcth the given template. 
       The second value describes if the first value is inconsistent.r)TF)FT)FF)r!r�r�r�r�r�r�r)r2r�r�r�r3r3r4�get_comp_child_stateDs
�z'SoftwareProperties.get_comp_child_statecCs"|j��g|_|j�|j�dSr�)r�refresh�sourceslist_visibler!�get_sourcesrPr3r3r4r%Ys
z%SoftwareProperties.reload_sourceslistc
Cs�|jd|jd|jdg}|D]
}tj�|�rn!qtd�t|dd��
}|�d�Wd�n1s6wYd	}tj�|�r\t�|�tj	}|tj
@s\td
|�t�|d�|D]m}g}tj�|�r�t|d��}|��}Wd�n1s|wYt
j�d
�}t|d��7}|D]}|��D]
}	|�d|	�dkr�nq�|�|�q�|��D]}
|�d|
|�|
�f�q�Wd�n1s�wYq^dS)z+Write the current apt configuration to filez/etc/apt/apt.conf.d/10periodicz#/etc/apt/apt.conf.d/20auto-upgradesz+/etc/apt/apt.conf.d/15adept-periodic-updatezNo config found, creating onerrg�Nz/etc/cron.daily/aptz file '%s' not executable, fixingi�rhz
APT::PeriodiczAPT::Periodic::%szAPT::Periodic::%s "%s";
)rrIrJ�isfiler�rlrmrK�stat�ST_MODE�S_IXUSR�chmod�	readlinesrr�subtreer�r�r@)r2�	conffilesrv�ac�perm�periodic�content�cnfrxr�rur3r3r4rD^sN���

��
�����zSoftwareProperties.write_configcCs|j�d�|j��dS)zRBackup the existing sources.list files and write the current 
       configurationz.saveN)r�backup�saverPr3r3r4r��sz#SoftwareProperties.save_sourceslistc	Cs�t|�}tj�|j�rTt�d|j�D]@}t|��2}|D]'}|���d�r&q|t|�krCtj�	tj�
|��dWd�SqWd�n1sNwYqdS)zs
    helper that checks if a given line is in the source list
    return the channel name or None if not found
    z	%s/*.list�#rN)r
rIrJrK�CHANNEL_PATH�globrlrnro�splitext�basename)r2�srcline�srcentry�filenamervrxr3r3r4�_is_line_in_whitelisted_channel�s
����z2SoftwareProperties._is_line_in_whitelisted_channelcCs8|��j}|�|�}|rd|j|f}|�|�dSdS)z�
    helper that adds the gpg key of the channel to the apt
    keyring *if* the channel is in the whitelist
    /usr/share/app-install/channels
    z	%s/%s.keyTF)r
rxrr
�add_key)r2�shortcutr�channel�keypr3r3r4�*check_and_add_key_for_whitelisted_shortcut�s


z=SoftwareProperties.check_and_add_key_for_whitelisted_shortcutcCsdS)z) abstract interface to keep the UI alive Nr3rPr3r3r4�update_interface�sz#SoftwareProperties.update_interfacecCs\|�d�s|S|��d}z
|�dd�d}Wnty"d}Ynwd||jj|f}|S)z�
    short cut - this:
      apt-add-repository http://packages.medibuntu.org free non-free
    same as
      apt-add-repository 'deb http://packages.medibuntu.org/ '$(lsb_release -cs)' free non-free'
    �httpr� r
�mainzdeb %s %s %s)ror~�
IndexErrorr!�codename)r2rx�repo�areasr3r3r4�expand_http_line�s
�z#SoftwareProperties.expand_http_lineFcCs2zt|���}Wn
tyYdSw|�||�S)z*
    Add a source for the given line.
    F)rrnr�add_source_from_shortcut)r2rx�enable_source_coderr3r3r4�add_source_from_line�s�z'SoftwareProperties.add_source_from_linec	Cs�|��j}|j}|�|�}|rdnd}||dd�}t||�}t||�}|js+|jr-dS|�|�s6|��|jj|j	|j
|j|j|j
|j|jd�|jj||j
|j|j|j
|j|jd�|��|jrw|jjrwddl}	|	��}
|
j|jd�d	S)
z�
    Add a source with the given shortcut and add the signing key if the
    site is in whitelist or the shortcut implementer adds it.
    r�z	# deb-srcrNF)r�r��
architecturesr)�sources_listT)r
rx�sourceparts_filerr�rrrr�rcr�r�r�r�r�r#r�rr��apt�Cache)r2rr!�deb_liner��debsrc_entry_type�debsrc_line�
new_deb_entry�new_debsrc_entryr&�cacher3r3r4r �sB





��z+SoftwareProperties.add_source_from_shortcutTcCs�|r:t|t�r|�|�}|�|d�dS|dur8|�|d�t�|�}d|_d|_|�|d�d|_|�|d�dSt|t�rD|�|�}|durJdS|jtj	�
d�kr_|jj�
td|jd��z|j�|�Wn	typYnw|��dS)zRemove the given sourceTNFr�zDir::Etc::sourcelistr�)r�)r�rCr��
remove_sourcertrcr�r�rr�	find_filerr�r�r
r�rr�)r2r��remove_source_coder3r3r4r.�s4

�


�z SoftwareProperties.remove_sourcecCs0tj�|�sdSz	|j�|�}|WSYdS)z7Add a gnupg key to the list of trusted software vendorsF)rIrJrKr,r�)r2rJr�r3r3r4rszSoftwareProperties.add_keycCs,t��}|�|�d��|��|�|j�S)z<Add a gnupg key from a utf-8 data string (e.g. copy-n-paste)zutf-8)�tempfilerrm�encoderprrs)r2�keydata�tmpr3r3r4�add_key_from_data'sz$SoftwareProperties.add_key_from_datacCs z	|j�|�WdSYdS)z<Remove a gnupg key from the list of trusted software vendorsTF)r,�rm)r2�keyidr3r3r4�
remove_key.s
zSoftwareProperties.remove_keycCsz|j��WdSYdS)z Run apt-key update TF)r,r�rPr3r3r4�update_keys6s

zSoftwareProperties.update_keyscCsXt|tj�sJ�|j}|r|j}|j}nt�|�}|�|�}|j}|j}d|j||fS)z" Return the PackageKit package id z	%s;%s;%s;)	r�r�Package�current_ver�ver_str�arch�DepCache�get_candidate_verrs)r2�	apt_cache�pkg�cur_ver�verr=�depcache�	candidater3r3r4�get_package_id>s

z!SoftwareProperties.get_package_idc
	Csxt�|�}|�|�}g}z"|j�d�D]}|D]\}}}	|�|�dkr*|�||�qqW|Sttfy;gYSw)zF Get the package dependencies, which can be filtered out by a pattern �Depends���)	rr>r?�depends_list_strr^r�r��KeyError�	TypeError)
r@�package�patternrDrE�dependencies�dep_list�dep_name�dep_ver�dep_opr3r3r4�get_dependenciesLs

�����z#SoftwareProperties.get_dependencies)NNr)F)Tr�)A�__name__�
__module__�__qualname__r
rZr��ranger[�RELEASE_UPGRADES_LTS�RELEASE_UPGRADES_NEVERr`r5r1r'rErQrTrVrWrfryr�r�r�r�r�r�r�r�r�r�r�r�r�r&r�r�r�r�r�r�rRr�r�r�r�r�r�r%rDr�rrrrr"r r.rr5r8r9rF�staticmethodrSr3r3r3r4rEs�
��
)'




	'
.


&(
r�__main__)0�
__future__rrrrt�hashlibrr�rIrrqr6r/r1�stringr�ImportErrorrCr�r)r*r�xml.sax.saxutilsr�configparserrr	r�r �aptsources.distror=r�aptsources.sourceslistrr
�"softwareproperties.shortcuthandlerr�softwareproperties.shortcutsr�
gi.repositoryr�objectrrT�spr�rfryr3r3r3r4�<module>sd
����

Spamworldpro Mini