
    b2                         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 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)	b64encode)blake2b)NamedTemporaryFilea
  
### autogenerated by samba
#
# This file is generated by the gp_scripts_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_scripts_extc                     dS )NzUnix Settings/Scripts )selfs    9/usr/lib/python3/dist-packages/samba/gp/gp_scripts_ext.py__str__zgp_scripts_ext.__str__'   s    &&    Nc           	         |D ]\  }}| j                             |           t          |           |v r|t          |                                                    D ]`\  }}t          j                            |          rt	          j        |           | j                             t          |           |           a| j         	                                 |D ]}|j
        rd}	d|	z  dd|	z  dd|	z  dd|	z  d	i}
| j                             |j                   d
}t          j                            |j
        |          }|                     |          }|s|j        D ]n}|j        |
                                v rO|j                                        r5|s|
|j                 n|}|j        dt'          |j                                                                                  }| j                             t          |           |          }|st/          ddd|          5 }dt0          z  }|d|j        z  z  }|                    |           t	          j        |j        d           | j                             t          |           ||j                   d d d            n# 1 swxY w Y   | j         	                                 pd S )N%Software\Policies\Samba\Unix Settings%s\Daily Scriptsz/etc/cron.daily%s\Monthly Scriptsz/etc/cron.monthly%s\Weekly Scriptsz/etc/cron.weekly%s\Hourly Scriptsz/etc/cron.hourlyzMACHINE/Registry.pol:gp_zw+F)prefixmodedeletedirz#!/bin/sh
%sz%s
i  )gp_dbset_guidstritemsospathexistsunlinkr   commitfile_sys_pathnamejoinparseentrieskeynamekeysdatastripr   encodedecoderetriever	   introwritechmodstore)r   deleted_gpo_listchanged_gpo_listcdirguidsettings	attributescriptgporeg_keysectionspol_filer#   pol_confecron_dirold_valfcontentss                      r   process_group_policyz#gp_scripts_ext.process_group_policy*   s   . 	  	 ND(J%%%4yyH$$)1#d)))<)B)B)D)D < <%Ivw~~f-- *	&)))J%%c$ii;;;;J# 	, 	,C  ,D07:=N2W<?R1G;>P1G;>PS 
##CH---1w||C$5x@@::d++ !) , ,AyHMMOO333>B#L8AI#6#6/0yyy )!&--// : : A A C C C%E	"&*"5"5c$ii"K"K& O!35t+0h"@ "@ "@ OCD+:U+B (FQVO ; ! 1 1 1 " 7 7 7 $
 0 0TIqv N N NO O O O O O O O O O O O O O O 
))+++7	, 	,s   (A5J))J-0J-MACHINEc                    i }d|z  }|j         rt          j                            |j         |          }|                     |          }|s|S |j        D ]}|j                            d          d         }|                    d          rT|j	        
                                r;||                                vrg ||<   ||                             |j	                   |S )Nz%s/Registry.pol\Scripts)r'   r"   r#   r)   r*   r+   r,   splitendswithr.   r/   r-   append)	r   r>   targetoutputrA   r#   rB   rC   keys	            r   rsopzgp_scripts_ext.rsopQ   s    $v- 
	/7<< 18<<Dzz$''H % / /iood++B/<<	** /qv||~~ /&++--//&(s3K&&qv...r   )N)rI   )__name__
__module____qualname__r   rH   rT   r   r   r   r   r   &   sL        ' ' '%, %, %, %,N     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(.*)   
z.*c                 6    g | ]}|                                 S r   )r/   ).0ls     r   
<listcomp>z!fetch_crontab.<locals>.<listcomp>m   s     444!AGGII444r   )r   r   communicate
returncodeRuntimeErrorrefindallr3   endr1   DOTALLlenr/   rN   r)   )usernamepouterrmr+   otherss          r   fetch_crontabrr   a   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 )NrY   rZ   r[   r   zFailed to install crontab: %s)r   r   rd   re   rf   )fnamerl   rm   _ro   s        r   install_crontabrv   r   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_scripts_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 ]j}
|
j        r_d}d|z  dd|z  dd|z  d	d
|z  di}| j                             |
j                   d}t(          j                            |
j        |          }t-          d| j        |          }|s|j        D ]}|j        |                                v r|j                                        r||j                 }|j        dt;          |j                                                                                  }| j                             t          |           |          }|d|j        }t          | j                  \  }}|r||vr|                     |           t                      5 }	|	
                    d                    |t          d                    |          t          g                                                     |	                                 t!          |	j        | j                   d d d            n# 1 swxY w Y   | j         !                    t          |           ||           | j                                          ld S )Nr   r_   r   r   z@dailyr   z@monthlyr   z@weeklyr   z@hourlyzUSER/Registry.polrootr    )"r   r   r    rr   rl   r!   remover   r	   rk   r4   r)   r3   ri   r0   flushrv   r(   r&   r'   r"   r#   r   r*   r+   r,   r-   r.   r/   r   	hexdigestr2   rP   r6   )r   r7   r8   r:   r;   rq   r+   r<   entryrF   r>   r?   r@   rA   r#   rB   rC   	cron_freqrE   s                      r   rH   z(gp_user_scripts_ext.process_group_policyy   sq   . 	  	 ND(J%%%4yyH$$"/">">(0T(;(A(A(C(C < <$Iu''u---J%%c$ii;;;;')) ;Q7||a''		65#'99W#5#5s+< != !==CVXXG G G G 000GGIII#AFDM:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; J# 	, 	,C  ,D07:X2W<z1G;i1G;iJ 
##CH---.w||C$5x@@*64:tDD !) , ,AyHMMOO333$,QY$7	/0yyy ' 8 8 B B D D D%F	"&*"5"5c$ii"K"K+499aff =*7*F*F& J%w*>*>#NN5111!3!5!5 G !		65+/99W+=+=s3D )E )EEKVXX!O !O !O !			 / F F F	G G G G G G G G G G G G G G G
 !J,,SYY	5III
))+++;	, 	,s&   CFF	 F	B
OO #O c                 J    t                                          |d          S )NUSER)rQ   )superrT   )r   r>   	__class__s     r   rT   zgp_user_scripts_ext.rsop   s    ww||C|///r   )rU   rV   rW   rH   rT   __classcell__)r   s   @r   rx   rx   x   sH        0, 0, 0,d0 0 0 0 0 0 0 0 0r   rx   )r"   rg   
subprocessr   r   samba.gp.gpclassr   r   base64r   hashlibr   tempfiler	   r3   ri   r   rr   rv   rx   r   r   r   <module>r      s  "  " " " " " " " " 8 8 8 8 8 8 8 8             ' ' ' ' ' '		9 9 9 9 9Z 9 9 9v  "B B B40 40 40 40 40. 40 40 40 40 40r   