File: //lib/python3/dist-packages/samba/tests/blackbox/__pycache__/bug13653.cpython-310.pyc
o
�/a) � @ s` d Z ddlmZmZmZmZ ddlmZ ddlm Z ddl
mZ ddlm
Z
G dd� de�Zd S )
a
Blackbox test verifying bug 13653
https://bugzilla.samba.org/show_bug.cgi?id=13653
When creating a new user and specifying the local filepath of the sam.ldb DB,
it's possible to create an account that you can't actually login with.
This only happens if the DB is using encrypted secrets and you specify "ldb://"
in the sam.ldb path, e.g. "-H ldb://st/ad_dc/private/sam.ldb".
The user account will be created, but its secrets will not be encrypted.
Attempts to login as the user will then be rejected due to invalid credentials.
We think this may also cause replication/joins to break.
You do get a warning about "No encrypted secrets key file" when this happens,
although the reason behind this message is not obvious. Specifying a "tdb://"
prefix, or not specifying a prefix, works fine.
Example of the problem below using the ad_dc testenv.
addc$ bin/samba-tool user create tdb-user pass12#
-H tdb://st/ad_dc/private/sam.ldb
User 'tdb-user' created successfully
# HERE: using the "ldb://" prefix generates a warning, but the user is still
# created successfully.
addc$ bin/samba-tool user create ldb-user pass12#
-H ldb://st/ad_dc/private/sam.ldb
No encrypted secrets key file. Secret attributes will not be encrypted or
decrypted
User 'ldb-user' created successfully
addc$ bin/samba-tool user create noprefix-user pass12#
-H st/ad_dc/private/sam.ldb
User 'noprefix-user' created successfully
addc$ bin/ldbsearch -H ldap://$SERVER -Utdb-user%pass12# '(cn=tdb-user)' dn
# record 1
dn: CN=tdb-user,CN=Users,DC=addom,DC=samba,DC=example,DC=com
# Referral
ref: ldap://addom.samba.example.com/CN=Configuration,DC=addom,DC=samba,
DC=example,DC=com
# Referral
ref: ldap://addom.samba.example.com/DC=DomainDnsZones,DC=addom,DC=samba,
DC=example,DC=com
# Referral
ref: ldap://addom.samba.example.com/DC=ForestDnsZones,DC=addom,DC=samba,
DC=example,DC=com
# returned 4 records
# 1 entries
# 3 referrals
# HERE: can't login as the user created with "ldb://" prefix
addc$ bin/ldbsearch -H ldap://$SERVER -Uldb-user%pass12# '(cn=ldb-user)' dn
Wrong username or password: kinit for ldb-user@ADDOM.SAMBA.EXAMPLE.COM failed
(Client not found in Kerberos database)
Failed to bind - LDAP error 49 LDAP_INVALID_CREDENTIALS
- <8009030C: LdapErr: DSID-0C0904DC,
comment: AcceptSecurityContext error, data 54e, v1db1> <>
Failed to connect to 'ldap://addc' with backend
'ldap': LDAP error 49 LDAP_INVALID_CREDENTIALS
- <8009030C: LdapErr: DSID-0C0904DC,
comment: AcceptSecurityContext error, data 54e, v1db1> <>
Failed to connect to ldap://addc - LDAP error 49 LDAP_INVALID_CREDENTIALS
- <8009030C: LdapErr: DSID-0C0904DC,
comment: AcceptSecurityContext error, data 54e, v1db1> <>
addc$ bin/ldbsearch -H ldap://$SERVER -Unoprefix-user%pass12#
'(cn=noprefix-user)' dn
# record 1
dn: CN=noprefix-user,CN=Users,DC=addom,DC=samba,DC=example,DC=com
# Referral
ref: ldap://addom.samba.example.com/CN=Configuration,DC=addom,DC=samba,
DC=example,DC=com
# Referral
ref: ldap://addom.samba.example.com/DC=DomainDnsZones,DC=addom,DC=samba,
DC=example,DC=com
# Referral
ref: ldap://addom.samba.example.com/DC=ForestDnsZones,DC=addom,DC=samba,
DC=example,DC=com
# returned 4 records
# 1 entries
# 3 referrals
� )�BlackboxTestCase�BlackboxProcessError�delete_force�env_loadparm)�Credentials)�SamDB)�system_session)�environc sP e Zd Z� fdd�Z� fdd�Zdd� Zdd� Zd d
� Zdd� Zd
d� Z � Z
S )�
Bug13653Testsc s\ t t| ��� td | _td | _td | _t� }t� }t � }|�
|� t|||d�| _d S )N�TEST_ENV�SERVER�
PREFIX_ABS)�session_info�credentials�lp)
�superr
�setUpr �env�server�prefixr r r �guessr �ldb)�selfr �creds�session�� __class__� �?/usr/lib/python3/dist-packages/samba/tests/blackbox/bug13653.pyr � s
�zBug13653Tests.setUpc
s\ t t| ��� zd| j| j�� f }t| j|� W d S ty- } zW Y d }~d S d }~ww �NzCN=%s,CN=Users,%s)r r
�tearDown�userr � domain_dnr � Exception�r �dn�er r r r � s ��zBug13653Tests.tearDownc
C s\ d| j | j�� f }z t| j|� W d S ty- } z| �t|�� W Y d }~d S d }~ww r )r! r r"