
    Id                          d dl Z d dlZd dlmZmZ d dlmZ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e      Zd Zd Z G d de      Zy)    N)PopenPIPE)
gp_pol_extdrop_privilegesgp_file_applier)blake2b)NamedTemporaryFile)loga
  
### 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y)gp_scripts_extc                      y)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 s|t        |          j                         D ]  \  }}| j                  |||        L |D ]r  }|j                  sd}	d|	z  dd|	z  dd|	z  dd|	z  d	id
}
t        j
                  j                  |j                  |
      }| j                  |      }|sii }|j                  D ]  }|j                  j                         v s |j                  j                         s;|j                  |vrg ||j                  <   ||j                     j                  |j                          fd}|j                         D ]6  \  }}|} | j                  | }| j                  |j                   |||||       8 | j#                  |j                   |j                                u y )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.polc                 .   g }s|    n}|D ]w  }t        ddd|      5 }dt        z  }|d|z  z  }|j                  |       t        j                  |j
                  d       |j                  |j
                         d d d        y |S # 1 sw Y   xY w)Ngp_zw+F)prefixmodedeletedirz#!/bin/sh
%sz%s
i  )r	   introwriteoschmodnameappend)	keynameentriesretcron_dirdatafcontentscdirsectionss	          r   applier_funcz9gp_scripts_ext.process_group_policy.<locals>.applier_funcB   s    C8<x0$H ' //u47<(L /OP'6'>H$5HGGH-HHQVVU3JJqvv./ // J/ /s   ABB	)keep)stritemsunapplyfile_sys_pathr!   pathjoinparser&   r%   keysr)   stripr$   generate_value_hashapplyr#   clean)r   deleted_gpo_listchanged_gpo_listr,   guidsettings	attributescriptgporeg_keypol_filer4   pol_confpolicieser.   r%   r&   
value_hashr-   s      `               @r   process_group_policyz#gp_scripts_ext.process_group_policy*   s   . 	:ND(4yH$)1#d))<)B)B)D :%IvLLy&9:	:
 $ *	;C  D07:=N2W<?R1G;>P1G;>PS 2ww||C$5$5x@::d+!)) ;AyyHMMO399H424HQYY/ +22166:	;
 )1(8 	1$GW !(I ":!9!97!CJJJsxxJ&1	1 

388(--/
:U*	;r   c                    i }d|z  }|j                   rt        j                  j                  |j                   |      }| j	                  |      }|s|S |j
                  D ]  }|j                  j                  d      d   }|j                  d      s3|j                  j                         sN||j                         vrg ||<   ||   j                  |j                          |S )Nz%s/Registry.pol\Scripts)r3   r!   r4   r5   r6   r&   r%   splitendswithr)   r8   r7   r$   )	r   rB   targetoutputrD   r4   rE   rG   keys	            r   rsopzgp_scripts_ext.rsop\   s    $v-77<< 1 18<Dzz$'H%% /iiood+B/<<	*qvv||~&++-/&(s3K&&qvv./ r   )N)MACHINE)__name__
__module____qualname__r   rI   rS   r   r   r   r   r   &   s    '0;dr   r   c                    t        ddd| gt        t              }|j                         \  }}|j                  dk7  rt	        j
                  d|z         t        j                  t        dt        |j                         t        j                        }t        |      dk(  r#|d   j                         j                  d	      }ng }t        j                  dt        d
t        d|j                         t        j                        }t        |      dk(  r4d	j                  |d   D cg c]  }|j                          c}      }||fS |j                         }||fS c c}w )Ncrontabz-l-ustdoutstderrr   zFailed to read the crontab: %sz(.*)   
z.*)r   r   communicate
returncoder
   warningrefindallr   enddecodeDOTALLlenr8   rN   r5   )usernamepouterrmr&   lotherss           r   fetch_crontabrp   l   s   y$h/TJA}}HC||q4s:;


,cjjlBIIFA
1v{A$**,$$T*


uc2CJJL"))LA
1v{qt4!AGGI45 7? 7? 5s   *E c                     t        d| d|gt        t              }|j                         \  }}|j                  dk7  rt	        d|z        y )NrY   rZ   r[   r   zFailed to install crontab: %s)r   r   r`   ra   RuntimeError)fnameri   rj   _rl   s        r   install_crontabru   }   sJ    y%x0dKA]]_FAs||q:S@AA r   c                   $     e Zd Zd Z fdZ xZS )gp_user_scripts_extc                    |D ]y  \  }}| j                   j                  |       t        |       |v r0t        | j                        \  }}|t        |          j                         D ]?  \  }}||v r|j                  |       | j                   j                  t        |       |       A t               5 }	t        |      dkD  rJ|	j                  dj                  |t        dj                  |      t        g      j                                n|	j                  |j                                |	j                          t!        |	j"                  | j                         d d d        | j                   j%                          | |D ]^  }
|
j&                  sd}d|z  dd|z  dd|z  d	d
|z  di}| j                   j                  |
j"                         d}t(        j*                  j                  |
j&                  |      }t-        d| j.                  |      }|s|j0                  D ]  }|j2                  |j5                         v s!|j6                  j9                         s<||j2                     }|j2                  dt;        |j6                  j                               j=                         }| j                   j?                  t        |       |      }|d|j6                  }t        | j                        \  }}|r||vr|jA                  |       t               5 }	|	j                  dj                  |t        dj                  |      t        g      j                                |	j                          t!        |	j"                  | j                         d d d        | j                   jC                  t        |       ||       | j                   j%                           a y # 1 sw Y   xY w# 1 sw Y   ]xY w)Nr   r_   r   r   z@dailyr   z@monthlyr   z@weeklyr   z@hourlyzUSER/Registry.polroot: )"gp_dbset_guidr0   rp   ri   r1   remover   r	   rh   r    r5   r   re   encodeflushru   r#   commitr3   r!   r4   r   r6   r&   r%   r7   r)   r8   r   	hexdigestretriever$   store)r   r<   r=   r>   r?   ro   r&   r@   entryr*   rB   rC   r-   rD   r4   rE   rG   	cron_freqold_vals                      r   rI   z(gp_user_scripts_ext.process_group_policy   s3   . 	 ND(JJ%4yH$"/">(0T(;(A(A(C <$Iu'u-JJ%%c$i;< () ;Q7|a'		65#'99W#5s+< !==CVXG 0GGI#AFFDMM:; JJ!	 $ $ 	,C  D07:X2W<z1G;i1G;iJ 

##CHH-.ww||C$5$5x@*64::tD!)) ,AyyHMMO3$,QYY$7	/0yy ' 8 B B D%F	"&**"5"5c$i"K+4aff =*7*F&%w*>#NN51!3!5 G !		65+/99W+=s3D )EEKVX!O !	 / F	G
 !JJ,,SY	5I

))+!,	,; ;BG Gs   3B(O%A:O2%O/	2O;c                 &    t         |   |d      S )NUSER)rP   )superrS   )r   rB   	__class__s     r   rS   zgp_user_scripts_ext.rsop   s    w|C|//r   )rU   rV   rW   rI   rS   __classcell__)r   s   @r   rw   rw      s    0,d0 0r   rw   )r!   rc   
subprocessr   r   samba.gp.gpclassr   r   r   hashlibr   tempfiler	   samba.gp.util.loggingr
   r   re   r   rp   ru   rw   r   r   r   <module>r      sR   "  " I I  ' %		DZ DL"B40. 40r   