Файловый менеджер - Редактировать - /usr/lib64/python3.6/site-packages/samba/netcmd/domain/__pycache__/backup.cpython-36.pyc
Ðазад
3 �I�dl� � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlj Z d dlmZm Z d dlZd dlmZ d dlmZ d dlmZ d dlmZmZmZ d dlmZ d dlmZmZmZ d d lm Z d d l!m"Z"m#Z# d dl$m%Z%m&Z&m'Z' d dlm(Z( d d l)m*Z* d dl+m,Z,m-Z- d dl.m/Z/ d dl0m1Z1 d dl+m2Z2 d dl3m4Z4 d dl5Z5d dl+m6Z6m7Z7m8Z8 d dl9m:Z:m;Z;m<Z< d dl=m>Z> d dl?m@Z@ d dlAZAd dlBmCZC d dlmDZD d dlEmFZF d dlGmHZH d dlImJZJ d dlmKZL dd� ZMdd � ZNd!d"� ZOd#d$� ZPd%d&� ZQd9d'd(�ZRd)d*� ZSd+d,� ZTd-d.� ZUG d/d0� d0ejVjW�ZXG d1d2� d2e*�ZYG d3d4� d4ejVjW�ZZG d5d6� d6ejVjW�Z[G d7d8� d8ejVj\�Z]dS ):� N)�SamDB�get_default_backend_store)�LdbError)�libsmb_samba_internal)�param)� backup_online�backup_restore�backup_offline)�system_session)� DCJoinContext� join_clone�DCCloneAndRenameContext)�dom_sid)�Option�CommandError)�misc�security�drsblobs)�Ldb)�cmd_fsmo_seize)�make_smbconf�DEFAULTSITE)�update_krbtgt_account_password)� remove_dc)�secretsdb_self_join)�dbcheck)�guess_names�determine_host_ip�determine_host_ip6)�fill_dns_data_partitions�get_dnsadmins_sid�get_domainguid)�tdb_copy)�mdb_copy)�CalledProcessError)�sites)�_dsdb_load_udv_v2)�ndr_pack)�SMB_SIGNING_REQUIRED)�safe_tarfilec C s y| j � }W n@ tk rL } z$|jd� |jd� td|��W Y d d }~X nX t| j� �}t|�d t|� }yN| jtj d| g ddgd�}t |�d kr�td | ��td||d jf ��W n: tjk r� } z|j\}} |tj kr� W Y d d }~X nX t|�d t|� S ) Nz}A SID could not be allocated for restoring the domain. Either no RID Set was found on this DC, or the RID Set was not usable.z�To initialise this DC's RID pools, obtain a RID Set from this domain's RID master, or run samba-tool dbcheck to fix the existing RID Set.zCannot create backup�-z<SID=%s>zshow_deleted:1zshow_recycled:1)�scope�base�attrs�controls� z]Cannot create backup - this DC's RID pool is corrupt, the next SID (%s) appears to be in use.z�Cannot create backup - this DC's RID pool is corrupt, the next SID %s points to existing object %s. Please run samba-tool dbcheck on the source DC.r )Z next_free_ridr �infor r �get_domain_sid�str�search�ldb� SCOPE_BASE�len�dn�args�ERR_NO_SUCH_OBJECT) �samdb�logger�rid�err�sidZsid_for_restore�res�e�enum�emsg� rC �/usr/lib64/python3.6/backup.py�get_sid_for_restore@ s0 rE c C sF t j� }|j|j� |j� }|jt� tj| d||d�}|j|� |S )z7Returns an SMB connection to the sysvol share on the DC�sysvol)�lp�creds) �s3paramZget_context�loadZ configfileZget_smb_signingZset_smb_signingr( �libsmbZConn)�serverrG rH Zs3_lpZsaved_signing_stateZconnrC rC rD �smb_sysvol_connp s rM c C s t j j� j� jdd�S )N�:r* )�datetime�nowZ isoformat�replacerC rC rC rD � get_timestamp s rR c C s d||f }t jj| |�S )Nzsamba-backup-%s-%s.tar.bz2)�os�path�join)� targetdir�name�time_str�filenamerC rC rD �backup_filepath� s rZ c C s4 | j d| � tj|d�}|j|dd� |j� d S )NzCreating backup file %s...zw:bz2z./)�arcname)r0 �tarfile�open�add�close)r; �tmpdirrZ �tfrC rC rD �create_backup_tar� s rb c C s� t tjj| d�d�}z�tjj� jd�}|jd| � |jd|jd� � |jd||f � |jd|jd �|jd �j � f � |jdt |� � |r�|jd| � W d |j� X d S ) Nz backup.txt�wz%Y-%b-%d %H:%M:%SzBackup created %s zUsing samba-tool version: %s z server stringz Domain %s backup, using DC '%s' z/Backup for domain %s (NetBIOS), %s (DNS realm) Z workgroup�realmz#Backup contains domain secrets: %s z%s )r] rS rT rU rO rP Zstrftime�write�get�lowerr2 r_ )rV rG �backup_typerL �include_secretsZ extra_info�frX rC rC rD �create_log_file� s rk c C s8 t j� }t j| d�|_t j|t j|�||<