Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.145.2.158
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : update-crypto-policies.cpython-36.pyc
3

."�d$!�@spddlZddlZddlZddlZddlmZddlZddlZddlZddl	Zddl
Z
dd�e_dZdZ
dZdZd	d
�ZyejdZeej_Wnek
r�eZYnXyejdZeej_Wnek
r�e
ZYnXejjed
�Zejjed�Zejjed�Zejjee�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$Gdd�d�Z%d d!�Z&e'd"k�rle&�dS)#�N)�mkstempcOs|j�dt|�j��d�S)Nz: �
)�__name__�str�
capitalize)�msg�category�aZkwa�r
�<./usr/share/crypto-policies/python/update-crypto-policies.py�<lambda>srz/usr/share/crypto-policiesz/etc/crypto-policieszreload-cmds.shz/proc/sys/crypto/fips_enabledcOst|dtji|��dS)N�file)�print�sys�stderr)�args�kwargsr
r
r�eprint sr�profile_dir�base_dirzlocal.dz	back-ends�statecCsrtjdd�}|j�}|jdddddd�|jd	d
dd�|jd
d
dd�|jdd
tjd�|jdd
dd�|j�S)zParse the command lineF)Zallow_abbrevz--set�?�ZPOLICYzset the policy POLICY)�nargs�default�metavar�helpz--show�
store_truez.show the current policy from the configuration)�actionrz--is-appliedz+check whether the current policy is appliedz
--no-checkz--no-reloadz3do not run the reload scripts when setting a policy)�argparse�ArgumentParserZadd_mutually_exclusive_group�add_argumentZSUPPRESS�
parse_args)�parser�groupr
r
rr"8s
r"cCs�y0tjtjjtd��j}tjtjjtd��j}Wntk
rNtj	d�YnX||krjt
d�tj	d�t
d�tj	d�dS)N�current�config�Mz The configured policy is appliedrz$The configured policy is NOT applied�)�os�stat�path�join�	state_dir�st_mtimer�OSErrorr�exitr)Ztime1Ztime2r
r
r�
is_appliedIs
r1cCs2ytjt�tjt�Wntk
r,YnXdS)N)r)�makedirs�backend_config_dirr-r/r
r
r
r�setup_directoriesWs

r4cCs>y$tt��}t|j��dkSQRXWntk
r8dSXdS)NrF)�open�FIPS_MODE_FLAG�int�readr/)�fr
r
r�	fips_mode_s

r:cCs�t||d�\}}tj|t|d��tj|�tj|d�zZytj|tjj||��Wn:t	k
r�}ztj
|�tj|�|�WYdd}~XnXWdtj|�XdS)N)�prefix�dirzutf-8i�)rr)�write�bytes�fsync�fchmod�renamer+r,r/�unlink�close)�	directory�filename�contents�fdr+�er
r
r�
safe_writegs


rIcCs�t||d�\}}tj|�tj|�tj||�ytj|tjj||��Wn0tk
rz}ztj|�|�WYdd}~XnXdS)N)r;r<)	rr)rCrB�symlinkrAr+r,r/)rDrE�targetrGr+rHr
r
r�safe_symlinkvs


rLc$Cs|tjj||d�}ttj|��}d}	x|D]}
tjj|
�r*d}	q*Wtjj|t|�|d�}tj|tj�}|	r�|r�t	||d|�dS|r�|j
r�|r�t|��}
|
j�}WdQRXt
||d|�|	�rxtjj||d�}x�|D]�}
y"t|
d��}|j�}WdQRXWn$tk
�r*td|�w�YnXy$t|d��}|j|�WdQRXWq�tk
�rrtd	|�Yq�Xq�WdS)
Nz	-*.configFTz.txtz.config�rzCannot read local policy file r	z&Error applying local configuration to )r)r+r,�sorted�glob�existsr�access�R_OKrL�subpoliciesr5r8rIr/rr=)�pconfigZcfgnameZcfgdataZcfgdirZlocaldirZ
profiledir�policy_was_emptyZlocal_cfg_pathZ
local_cfgsZlocal_cfg_presentZlcfgZprofilepathZprofilepath_existsZf_preZcfgfileZlfZ
local_dataZcfr
r
r�save_config�s:



rVc@s>eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�
ProfileConfigcCsd|_g|_dS)Nr)�policyrS)�selfr
r
r�__init__�szProfileConfig.__init__Fcs`|j�jd���dr2|r2�d|_�dd���fdd��D��|rV|jj��n�|_dS)N�:rr(csg|]}�r|�qSr
r
)�.0�i)�lr
r�
<listcomp>�sz.ProfileConfig.parse_string.<locals>.<listcomp>)�upper�splitrXrS�append)rY�s�	subpolicyr
)r^r�parse_string�s
zProfileConfig.parse_stringcCsVd}t|��@}x8|D]0}|jdd�d}|j�}|r|j||�d}qWWdQRXdS)NF�#r(rT)r5ra�stripre)rYrErdr9�liner
r
r�
parse_file�s

zProfileConfig.parse_filecs(|j�jd���fdd�|jD�|_dS)Nr[csg|]}|�kr|�qSr
r
)r\r])r^r
rr_�sz4ProfileConfig.remove_subpolicies.<locals>.<listcomp>)r`rarS)rYrcr
)r^r�remove_subpolicies�sz ProfileConfig.remove_subpoliciescCs&|j}dj|j�}|r"|d|}|S)Nr[)rXr,rS)rYrcZsubsr
r
r�__str__�s
zProfileConfig.__str__cCstt|��dS)N)rr)rYr
r
r�show�szProfileConfig.showN)F)	r�
__module__�__qualname__rZrerirjrkrlr
r
r
rrW�s

rWc)Cs�t�}|jrt�tjd�d}t�t�}d}tjjt	d�}tj
|tj�rX|j|�n&t
�rj|jd�n|jtjjtd��|jr�|j�tjd�|j}|�r|j}|j|�d}|j|k�r|jdkr�td�td�td	�n(t
��rtd
�td�td�td
�t	tk�r8tj�dk�s8td�tjd�ytj|jf|j��}Wnxtjjk
�r�}zt|�tjd�WYdd}~Xn@tjjk
�r�}ztd|���tjd�WYdd}~XnXtdt|��dd�tt�D�}	x�|	D]�}
tj |
}|�}y|j!|j"|j#��}
Wn0t$k
�rLtd|j%�td�d}YnXy t&||j%|
t't(t|j)�d�Wn0t*k
�r�td|j%�td�d}YnX�q�W|�r�yt+t	dt|�d�Wn"t*k
�r�td�d}YnXyt+t,dt|�d�Wn"t*k
�r"td�d}YnXyt+t,dt|��Wn"t*k
�rZtd �d}YnXtd!�td"�td#�|j-�s�t.j/d$t0g�tj|�dS)%z!The actual command implementationrFr&ZFIPSzdefault-configTzHWarning: Using 'update-crypto-policies --set FIPS' is not sufficient forz         FIPS compliance.z8         Use 'fips-mode-setup --enable' command instead.zOWarning: Using 'update-crypto-policies --set' in FIPS mode will make the systemz!         non-compliant with FIPS.z8         It can also break the ssh access to the system.zI         Use 'fips-mode-setup --disable' to disable the system FIPS mode.z/You must be root to run update-crypto-policies.r(Nz%Errors found in policy, first one:  
zSetting system policy to cSsg|]}d|kr|�qS)�	Generatorr
)r\�gr
r
rr_szmain.<locals>.<listcomp>zError generating config for zKeeping original configuration)rUzError saving config for rz.Error setting the current policy configuration�r%z$Error updating current policy marker�zCURRENT.polz"Error updating current policy dumpzFNote: System-wide crypto policies are applied on application start-up.zBIt is recommended to restart the system for the change of policieszto fully take place.z	/bin/bash)1r"r1rr0r4rWr)r+r,rrQrRrir:rerrl�setrXr�DEFAULT_BASE_DIR�geteuid�cryptopolicies�UnscopedCryptoPolicyrSZ
validationZPolicyFileNotFoundErrorZPolicySyntaxErrorrrr<�policygenerators�__dict__Zgenerate_configZscopedZSCOPES�LookupErrorZCONFIG_NAMErVr3�	local_dirZis_emptyr/rIr-Z	no_reload�
subprocessZcall�reload_cmd_path)Zcmdline�errrTZ
set_configZ
configfileZprofileZ	oldpolicyZcp�exZ
generatorsrp�cls�genr&r
r
r�main�s�














r��__main__)(rrr)r|ZtempfilerrO�warningsrvZcryptopolicies.validationrx�
formatwarningZDEFAULT_PROFILE_DIRrtZRELOAD_CMD_NAMEr6r�environrrwZ	SHARE_DIR�KeyErrorrZ
CONFIG_DIRr+r,r{r3r-r}r"r1r4r:rIrLrVrWr�rr
r
r
r�<module>sP




+)s

© 2025 GrazzMean