
    b                         d dl Z d dlZd dlmZmZ d dlmZmZ d dlm	Z	 d dl
mZ dZdZ G d d	e          Zd
 Zd Z G d de          ZdS )    N)PopenPIPE)
gp_pol_extdrop_privileges)blake2b)NamedTemporaryFilea  
### autogenerated by samba
#
# This file is generated by the gp_centrify_crontab_ext Group Policy
# Client Side Extension. To modify the contents of this file,
# modify the appropriate Group Policy objects which apply
# to this machine. DO NOT MODIFY THIS FILE DIRECTLY.
#

z 
### autogenerated by samba ###
c                   &    e Zd Zd Z	 ddZddZdS )gp_centrify_crontab_extc                     dS )NzCentrify/CrontabEntries )selfs    B/usr/lib/python3/dist-packages/samba/gp/gp_centrify_crontab_ext.py__str__zgp_centrify_crontab_ext.__str__&   s    ((    Nc                     |D ]\  }}| j                             |           t          |           |v r|t          |                                                    D ]`\  }}t          j                            |          rt	          j        |           | j                             t          |           |           a| j         	                                 |D ]}|j
        rd}	| j                             |j                   d}
t          j                            |j
        |
          }|                     |          }|sk|j        D ]1}|j        |	k    r"|j                                        r|sdn|}t%          |j                                                                                  }| j                             t          |           |          }|st-          ddd|          5 }t.          d|j        dt0          }|                    |           | j                             t          |           ||j                   d d d            n# 1 swxY w Y   | j         	                                 3d S )	N6Software\Policies\Centrify\UnixSettings\CrontabEntrieszMACHINE/Registry.polz/etc/cron.dgp_zw+F)prefixmodedeletedir
)gp_dbset_guidstritemsospathexistsunlinkr   commitfile_sys_pathnamejoinparseentrieskeynamedatastripr   encode	hexdigestretriever   introendwritestore)r   deleted_gpo_listchanged_gpo_listcdirguidsettings	attributescriptgposectionpol_filer   pol_confecron_dirold_valfcontentss                     r   process_group_policyz,gp_centrify_crontab_ext.process_group_policy)   s   . 	  	 ND(J%%%4yyH$$)1#d)))<)B)B)D)D < <%Ivw~~f-- *	&)))J%%c$ii;;;;J# 	, 	,C  ,P 
##CH---1w||C$5x@@::d++ !) , ,AyG+++8<#F==$$+AFMMOO$<$<$F$F$H$H	"&*"5"5c$ii"K"K& O!35t+0h"@ "@ "@ OCD;@55!&&&##+N ! 1 1 1 $
 0 0TIqv N N N	O O O O O O O O O O O O O O O
 
))++++	, 	,s   -AIIIMACHINEc                    i }d}d|z  }|j         rt          j                            |j         |          }|                     |          }|s|S |j        D ]}|j        |k    r{|j                                        rbt          |           |
                                vrg |t          |           <   |t          |                                        |j                   |S )Nr   z%s/Registry.pol)r"   r   r   r$   r%   r&   r'   r(   r)   r   keysappend)	r   r8   targetoutputr9   r:   r   r;   r<   s	            r   rsopzgp_centrify_crontab_ext.rsopK   s    N$v- 		57<< 18<<Dzz$''H % 5 59''AFLLNN'4yy55,.s4yy)3t99%,,QV444r   )N)rB   )__name__
__module____qualname__r   rA   rH   r   r   r   r
   r
   %   sQ        ) ) ) #' ,  ,  ,  ,D     r   r
   c                    t          ddd| gt          t                    }|                                \  }}|j        dk    rt	          d|z            t          j        t          dt          |	                                t
          j
                  }t          |          dk    r.|d                                                             d	          }ng }t          j        dt          d
t          d|	                                t
          j
                  }t          |          dk    r&d	                    d |d         D                       }n|	                                }||fS )Ncrontabz-l-ustdoutstderrr   zFailed to read the crontab: %sz(.*)   r   z.*c                 6    g | ]}|                                 S r   )r)   ).0ls     r   
<listcomp>z!fetch_crontab.<locals>.<listcomp>g   s     444!AGGII444r   )r   r   communicate
returncodeRuntimeErrorrefindallr-   r.   decodeDOTALLlenr)   splitr$   )usernamepouterrmr&   otherss          r   fetch_crontabrf   [   s&   y$h/TJJJA}}HC|q;cABBB

,cjjllBIFFA
1vv{{A$**,,$$T**


uuuccc2CJJLL")LLA
1vv{{44qt444557?r   c                     t          d| d|gt          t                    }|                                \  }}|j        dk    rt	          d|z            d S )NrM   rN   rO   r   zFailed to install crontab: %s)r   r   rW   rX   rY   )fnamer`   ra   _rc   s        r   install_crontabrj   l   sY    y%x0dKKKA]]__FAs|q:S@AAA r   c                   $     e Zd Zd Z fdZ xZS )gp_user_centrify_crontab_extc                    |D ]\  }}| j                             |           t          |           |v rot          | j                  \  }}|t          |                                                    D ]F\  }}||v r|                    |           | j                             t          |           |           Gt                      5 }	t          |          dk    r\|	
                    d                    |t          d                    |          t          g                                                     n'|	
                    |                                           |	                                 t!          |	j        | j                   d d d            n# 1 swxY w Y   | j                                          |D ]0}
|
j        r%d}| j                             |
j                   d}t(          j                            |
j        |          }t-          d| j        |          }|sl|j        D ]}|j        |k    r|j                                        rt9          |j                                                                                  }| j                             t          |           |          }t          | j                  \  }}|r	|j        |vr|                    |j                   t                      5 }	|	
                    d                    |t          d                    |          t          g                                                     |	                                 t!          |	j        | j                   d d d            n# 1 swxY w Y   | j                              t          |           ||j                   | j                                          2d S )Nr   r   r   zUSER/Registry.polroot)!r   r   r   rf   r`   r   remover   r   r^   r/   r$   r-   r.   r*   flushrj   r#   r!   r"   r   r   r   r%   r&   r'   r(   r)   r   r+   r,   rE   r0   )r   r1   r2   r4   r5   re   r&   r6   entryr?   r8   r9   r:   r   r;   r<   r>   s                    r   rA   z1gp_user_centrify_crontab_ext.process_group_policys   s   . 	  	 ND(J%%%4yyH$$"/">">(0T(;(A(A(C(C < <$Iu''u---J%%c$ii;;;;')) ;Q7||a''		65 $		' 2 2C+9 !: !::@&((D D D D 000GGIII#AFDM:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; J# 	, 	,C  ,P 
##CH---.w||C$5x@@*64:tDD !) , ,AyG+++$+AFMMOO$<$<$F$F$H$H	"&*"5"5c$ii"K"K*7*F*F& K!&*?*?#NN16222!3!5!5 G !		65(,		'(:(:C3A )B )BBH&((!L !L !L !			 / F F F	G G G G G G G G G G G G G G G
 !J,,SYY	16JJJ
))+++/	, 	,s&   CFF	 F	B
NN!$N!c                 J    t                                          |d          S )NUSER)rF   )superrH   )r   r8   	__class__s     r   rH   z!gp_user_centrify_crontab_ext.rsop   s    ww||C|///r   )rI   rJ   rK   rA   rH   __classcell__)ru   s   @r   rl   rl   r   sH        *, *, *,X0 0 0 0 0 0 0 0 0r   rl   )r   rZ   
subprocessr   r   samba.gp.gpclassr   r   hashlibr   tempfiler   r-   r.   r
   rf   rj   rl   r   r   r   <module>r{      s   "  " " " " " " " " 8 8 8 8 8 8 8 8       ' ' ' ' ' '		4 4 4 4 4j 4 4 4l  "B B B.0 .0 .0 .0 .0#: .0 .0 .0 .0 .0r   