+
    $iA  c                   s    ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RItRtR ]n        R t	R t
R tRR ltR tR	 t]R
8X  d
   ]! 4        R# R# )    Nzreload-cmds.shc                 s    VP                    R \        V 4      R,          P                  4       \        V 4      R,          ,            R2# )z: :N   N:r   NN
)__name__strupper)ZmsgZcategoryZ	_unused_aZ_unused_kwas   &&*,:/usr/share/crypto-policies/python/build-crypto-policies.py<lambda>r      s8    CHRL..03s8B<?@C    c                  s<    \        V R \        P                  /VB  R# )ZfileN)printsysstderr)ZargsZkwargss   *,r   eprintr      s    	4+cjj+F+r   c                 sn   \         P                  ! RR7      p V P                  RRRR7       V P                  RRRR7       V P                  R	\        R
RR7       V P                  RRRR7       V P                  RRRR7       V P                  RRR7       V P                  RRR7       V P	                  4       # )zParse the command lineF)Zallow_abbrevz--flatZ
store_truez1put all the generated files in a single directory)Zactionhelpz--testz7compare the generated config file with the existing onez--policyZPOLICYz"generate the specified policy only)ZtypeZmetavarr   z--reloadcmdszDalso save reload cmds into reload-cmds.sh script in output directoryz--strictzfail on warnings	policydirz5a directory with base policy definition files (*.pol))r   	outputdirz.a target directory with generated config files)argparseZArgumentParserZadd_argumentr   
parse_args)Zparsers    r   r   r      s    $$%8F
5  6 5  6 
hA  C
|N  O 
</  1
'  ( M  Or   c                 sx   V P                   '       d2   \        P                  P                  V P                  V R V R24      pM\        P                  P                  V P                  V4      p\        P                  P                  V4      '       g    \        P                  ! V4       \        P                  P                  WRR,           4      pV P                  '       d    \        VRR7      ;_uu_ 4       pVP                  4       pRRR4       XV8w  dd   \        RV RV R	24       R
 p\        P                  ! V! V4      V! V4      VVR,           R7      p	\        P                  P!                  V	4       R# R# \%        RV RV 24       \        VRRR7      ;_uu_ 4       pVP'                  V4       RRR4       \%        4        R#   \         d    \        RT 24        R# i ; i  + '       g   i     L; i  \"         d     L\         d    \        RT 24        R# i ; i  + '       g   i     L{; i)Z-z.txtz#Cannot create directory for policy Futf-8)encodingNzConfig for z for policy z differs from the existing one:c                 sZ    V P                  R 4       Uu. uF  qR ,           NK  	  up# u upi )r   )split)ZsZls   & r   linesZsave_config.<locals>.linesJ   s&    ./ggdm<mHHm<<<s   (z.new)ZfromfileZtofileTzError reading generated file zSaving config for wZmoder   )Zflatospathjoinr   ZisdirZmkdirOSErrorr   ZtestopenZreaddifflibZunified_diffr
   r   Z
writelinesZFileNotFoundErrorr	   write)
cmdlinepolicy_nameZconfig_nameconfigr   ZdirpathfZ
old_configr   Zdiffs
   &&&&      r   save_configr#   4   s   |||ww||G--*m1[M>@ '',,w00+>ww}}W%%! ww||G6%9:|||	dW--VVX
 .V#[Mk] K8 8 9=++E*,=uV}5937&=B 

%%d+ 
{m<}
EF	dw	/	/1	 
0	G?  <[MJK .- ! 	 	24&9:	
 
0	/sU   G
 #G= 8G*	A0G= $H)
G'&G'*G:	5G= =H&
H&H&%H&)H9	c                 s   ^ pVf   . p \         P                  ! V.VO5RV P                  / p\        \        4       Uu. uF  pRT9   g   K  TNK  	  ppT F  p\        P                  T,          pT! 4       p	T	P                  T4      p
TR	9   g   T	P                  T
4      '       d9    RP                  T.TO4      p\        YT	P                  T
4      '       g   ^pK  K  \	        RT	P                  ,           4       ^pK  	  T#   \         d'   p\	        R\        T4      ,           4        Rp?^# Rp?ii ; iu upi   \         d/    \	        RT	P                  ,           4       \	        R4       ^p EK  i ; i)
r    Nr   zError: 	Generator:zError saving config for zKeeping original configurationzError testing config for >   ZEMPTYz	GOST-ONLY)cryptopoliciesZUnscopedCryptoPolicyr   Z
ValueErrorr   r   dirpolicygenerators__dict__Zgenerate_configZtest_configr   r#   ZCONFIG_NAMEr   )r   r    subpolicy_nameserrZucpZeg
generatorsclsZgenr!   names   &&&         r   build_policyr0   _   sf   
C11+ O3BO<C<M<MO !!12G2kQ6F!!2JG''*e$$S)00COOF4K4Kxx ? ?@"7#//6JJC K .@AC! " J/  y3q6!" H  1COOCD78s4   $D 	D7D7(3D<D4D//D4<4E54E5c                 s   ^ p\        \        4       Uu. uF  pRV9   g   K  VNK  	  pp\        P                  P	                  V P
                  \        4      p \        VRRR7      ;_uu_ 4       pV F5  p\        P                  V,          pVP                  VP                  4       K7  	  RRR4       V# u upi   + '       g   i     T# ; i  \         d    \        R4       ^p T# i ; i)r    r$   r   r   r   NzError saving reload cmds)r'   r(   r   r   r   r   RELOAD_CMD_NAMEr   r)   r   Z
RELOAD_CMDr   r   )r   r+   r,   r-   r   r"   r.   s   &      r   save_reload_cmdsr2      s    
C !12G2kQ6F!!2JG77<<))?;D$S733q&//2'   4 J H 43 J  )*Js:   	B5B5C /<B:+C :C	C C C*)C*c                 sZ   \        4       p ^ pV P                  '       d   \        P                  ! R4       V P                  '       dR   V P                  P                  4       P                  R4       Uu. uF  q"'       g   K  VNK  	  ppVvrE\        WV4      pM\        P                  ! V P                  4      ;_uu_ 4       pV F  pVP                  P                  R4      '       d   K&  VP                  RR7      '       g   K@  \        P                  P                  VP                  4      w  rHVR8X  g   Kt  \        W4      pV'       g   K   M	  RRR4       V'       g   V P                   '       d   \#        V 4      p\$        P&                  ! V4       R# u upi   + '       g   i     LR; i)z!The actual command implementationZerrorr%   Z.F)Zfollow_symlinksz.polN)r   ZstrictwarningsZfilterwarningsZpolicyr   r   r0   r   Zscandirr   r/   Z
startswithZis_filer   ZsplitextZ
reloadcmdsr2   r
   Zexit)	r   r+   ZnZnamesr    r*   ZsdZiZexts	            r   mainr4      s(   lG
C~~~(~~~#NN00288=C=q=C(-%7AZZ))**bvv((--yyy77+-77+;+;AFF+C(&=".w"DC"s %  + 7%%%w'HHSM# D +*s0   2	F F $F)F/F7FFF*	Z__main__)N)r   r   r   r
   r3   r&   r(   r1   Zformatwarningr   r   r#   r0   r2   r4   r   ) r   r   <module>r5      s`      	 
   "D ,0(V F"< zF r   