
    b                         d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d ZdZ ed	e j        d
         dd          Z G d de          ZdS )    N)
gp_pol_ext)	b64encode)NamedTemporaryFile)PopenPIPE)logc                     |                     t          j                  }|D ]E}t          j                            ||           }t          j                            |          r|c S Fd S )N)splitospathseppathjoinisfile)
executabler   pathspfs        9/usr/lib/python3/dist-packages/samba/gp/gp_sudoers_ext.pyfind_executabler      sb    JJrz""E  GLLJ''7>>! 	HHH	4    a
  
### autogenerated by samba
#
# This file is generated by the gp_sudoers_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.
#

visudoPATH:z	/usr/sbin)r   c                   $    e Zd Zd Z	 ddZd ZdS )gp_sudoers_extc                     dS )NzUnix Settings/Sudo Rights )selfs    r   __str__zgp_sudoers_ext.__str__.   s    **r   /etc/sudoers.dc           	         |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 ]}|j        |	k    r	|j                                        rt%          |j                                                                                  }| j                             t          |           |          }|sst,          }|d|j        z  z  }t/                      5 }t1          |j        d          5 }|                    |           d d d            n# 1 swxY w Y   t5          t6          dd|j        gt8          t8                                                    }d d d            n# 1 swxY w Y   |dk    rt/          d	d
|          5 }t1          |j        d          5 }|                    |           d d d            n# 1 swxY w Y   | j                             t          |           ||j                   d d d            n# 1 swxY w Y   nt?          j         d|j                   | j         	                                 d S )Nz1Software\Policies\Samba\Unix Settings\Sudo RightsMACHINE/Registry.polz%s
wz-cz-f)stdoutstderrr   gp_F)prefixdeletedirzSudoers apply failed)!gp_dbset_guidstritemsr   r   existsunlinkr(   commitfile_sys_pathnamer   parseentrieskeynamedatastripr   encodedecoderetrieveintror   openwriter   r   r   waitstorer   error)r   deleted_gpo_listchanged_gpo_listsdirguidsettings	attributesudoersgposectionpol_filer   pol_confeold_valcontentsr   r#   sudo_validations                      r   process_group_policyz#gp_sudoers_ext.process_group_policy1   s5   . 	  	 ND(J%%%4yyH$$*23t99*=*C*C*E*E < <&Iww~~g.. +	'***J%%c$ii;;;;J# !	, !	,C   ,Q
##CH---1w||C$5x@@::d++ !) , ,AyG+++$-afmmoo$>$>$E$E$G$G	"&*"5"5c$ii"K"K& J',H$7H!3!5!5 M%)!&#%6%6 !6!$%GGH$5$5$5!6 !6 !6 !6 !6 !6 !6 !6 !6 !6 !6 !6 !6 !6 !6 ).vtT16.J37)F )F )FFJdff !0M M M M M M M M M M M M M M M  /!33%7u?D<@&B &B &B !=EF)-afc):): %:a()(9(9(9%: %: %: %: %: %: %: %: %: %: %: %: %: %: %:$(J$4$4SYY5>56V%= %= %=!= != != != != != != != != != != != != != != !$	*@!& I I I
))+++C!	, !	,sl   7JH/	#J/H33J6H37?JJ	J%L";K	L"K!!L"$K!%1L""L&)L&c                    i }d}|j         rt          j                            |j         |          }|                     |          }|s|S |j        D ]}|j                            d          d         }|                    d          rT|j	        
                                r;||                                vrg ||<   ||                             |j	                   |S )Nr"   \zSudo Rights)r1   r   r   r   r3   r4   r5   r
   endswithr6   r7   keysappend)r   rH   outputrJ   r   rK   rL   keys           r   rsopzgp_sudoers_ext.rsop_   s    ) 
	/7<< 18<<Dzz$''H % / /iood++B/<<.. /16<<>> /&++--//&(s3K&&qv...r   N)r    )__name__
__module____qualname__r   rP   rY   r   r   r   r   r   -   sL        + + + ",, ,, ,, ,,\    r   r   )r   samba.gp.gpclassr   base64r   tempfiler   
subprocessr   r   samba.gp.util.loggingr   r   r;   environr   r   r   r   r   <module>rc      s   " 
			 ' ' ' ' ' '       ' ' ' ' ' ' " " " " " " " " % % % % % %  		 

6***KK8
: 
: 
:@ @ @ @ @Z @ @ @ @ @r   