
    g                         S SK r S SKrS SKrS SKrS SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJrJrJr  S SKJr  S SKJr  S SKJr  S	S
KJr  S r " S S\5      rg)    N)system_session)system_session_unix)
get_string)CommandCommandErrorOption)Samba3)param)upgrade_from_samba3   )common_ntvfs_optionsc                 <   [        [        R                  S5      n[        R                  " U SSSU-  U/[        R
                  US9nUR                  5       u  pVUR                  5         UR                  S5      nU(       a  [        US   5      R                  5       $ g)	Nwz-sz-lz--parameter-name=%s)stdoutstderr   
r    )openosdevnull
subprocessPopenPIPEcommunicateclosesplitr   strip)testparmsmbconfvarnameerrfilepouterrliness           D/usr/lib/python3/dist-packages/samba/netcmd/domain/classicupgrade.pyget_testparm_varr'   *   s    2::s#G(D$/'97D *	AA JSMMOIIeE%(#))++    c                   \   \ rS rSrSrSr\R                  \R                  S.r	\
" SSSSS	9\
" S
SSSS	9\
" SSSSS	9\
" SSSSS9\
" SSSSS9\
" SSS/ SQSSS9/r\
" SS/ SQS S!S"S#9/r\R                  " 5       (       a"  \R                  \5        \R                  \5        S$/r   S(S& jrS'rg%))cmd_domain_classicupgrade7   zUpgrade from Samba classic (NT4-like) database to Samba AD DC database.

Specify either a directory with all Samba classic DC databases and state files (with --dbdir) or
the testparm utility from your classic installation (with --testparm).
z"%prog [options] <classic_smb_conf>)	sambaoptsversionoptsz--dbdirstringDIRz+Path to samba classic DC database directory)typemetavarhelpz
--testparmPATHzPath to samba classic DC testparm utility from the previous installation.  This allows the default paths of the previous installation to be followedz--targetdirzCPath prefix where the new Samba 4.0 AD domain should be initialisedz-qz--quietzBe quiet
store_true)r2   actionz-vz	--verbosez
Be verbosez--dns-backendchoicezNAMESERVER-BACKEND)SAMBA_INTERNALBIND9_FLATFILE	BIND9_DLZNONEa  The DNS server backend. SAMBA_INTERNAL is the builtin name server (default), BIND9_FLATFILE uses bind9 text database to store zone information, BIND9_DLZ uses samba4 AD to store zone information, NONE skips the DNS setup entirely (this DC will not be a DNS server)r7   )r0   r1   choicesr2   defaultz--use-xattrs)yesnoautoz[yes|no|auto]zDefine if we should use the native fs capabilities or a tdb file for storing attributes likes ntacl when --use-ntvfs is set. auto tries to make an intelligent guess based on the user rights and system capabilitiesr?   )r0   r;   r1   r2   r<   r   Nc           
         [         R                  R                  U5      (       d  [        SU-  5      eU(       a2  [         R                  R                  U5      (       d  [        SU-  5      eU(       a2  [         R                  R                  U5      (       d  [        SU-  5      eU(       d  U(       d  [        S5      eU R	                  XeS9nU(       a  U(       a  UR                  S5        S nUR                  5       n[        R                  " 5       nUR                  (       a  UR                  SUR                  5        Ub:  [         R                  R                  U5      (       d  [         R                  " U5        SnUS	:X  a  S
nGOUS:X  a  U(       d  S
nGOU(       d  [        S5      eUS:X  a  UR                  S5      (       d  U(       a2  [        R                  " [         R                  R!                  U5      S9nO][        R                  " [         R                  R!                  [         R                  R#                  UR                  S5      5      5      S9n  [$        R&                  R)                  UUR*                  SS[-        5       S5        S
nUR3                  5         0 nU(       a  UUS'   UUS'   UUS'   US-   US'   OV[5        XAS5      US'   [5        XAS5      US'   [5        XAS5      US'   [5        XAS5      US'   [7        US   5      S:X  a  US   US'   U H  nUR                  UUU   5        M     UR1                  S5        UR9                  U5        [;        X5      nUR1                  S5        [=        UX[?        5       XUS9  g ! [.         a    UR1                  S5         GNf = f! UR3                  5         f = f)NzFile %s does not existz"Testparm utility %s does not existzDirectory %s does not existz'Please specify either dbdir or testparm)verbosequietz2both dbdir and testparm specified, ignoring dbdir.realmTr=   Fr?   zr--use-xattrs=no requires --use-ntvfs (not supported for production use).  Please re-run with --use-xattrs omitted.z
posix:eadb)dirzprivate dirzO:S-1-5-32G:S-1-5-32zS-1-5-32nativezYou are not root or your system does not support xattr, using tdb backend for attributes. If you intend to use this provision in production, rerun the script as root on a system supporting xattrs.zstate directoryzlock directoryz
/smbpasswdzsmb passwd filer   zReading smb.confProvisioning)session_infouseeadbdns_backend	use_ntvfs) r   pathexistsr   
get_loggerwarningget_loadparms3paramget_contextrC   setisdirmkdirgettempfileNamedTemporaryFileabspathdirnamesambantaclssetntaclnamer   	Exceptioninfor   r'   lenloadr	   r   r   )selfr   	targetdirdbdirr   rB   rA   
use_xattrsr,   r-   rI   rJ   loggerlps3confeadbtmpfilepathsr"   samba3s                       r&   runcmd_domain_classicupgrade.rune   s3    ww~~g&&7'ABBBGGNN844ChNOO..<uDEEXHII>XNNOPE##%$$&??JJw	0 77==++#D6!)D  J K K6!&**\*B*B"55"''//):TU"55"''//"''//Z\Z`Z`anZoJp:qr 
NLL))"gll*@*4*=*?*2	4
 !D  ',E#$#(E- &+E"#',|';E#$'7K\']E#$#3H}#UE- '7K\']E#$&6xJZ&[E"# 5*+,1+01A+B'(AJJq%(#  	&'G(N#FFNDT$(Y	XC ! NKK !M NN
 s$    8N N0,N3 /N00N3 3O )NNNNFFr?   NNNF)__name__
__module____qualname____firstlineno____doc__synopsisoptionsSambaOptionsVersionOptionstakes_optiongroupsr   takes_optionsntvfs_optionsrZ   is_ntvfs_fileserver_builtextendr   
takes_argsrm   __static_attributes__ro   r(   r&   r*   r*   7   s    4H ))-- 	yxA	C|(F k	l}8UY	[tYZEt[|LIX7KPV (	)M& 	~H6K&j 	M &&((12]+JEIW[(-XXr(   r*   )r   rV   r   rZ   samba.getoptgetoptrv   
samba.authr   samba.auth_utilr   samba.commonr   samba.netcmdr   r   r   samba.samba3r	   r
   rP   samba.upgrader   commonr   r'   r*   ro   r(   r&   <module>r      sF   2 
     % / # 6 6  ) - (
FX FXr(   