Bug 15373 - Uncaught exception on running 'samba-tool domain trust create'
Summary: Uncaught exception on running 'samba-tool domain trust create'
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: AD: LDB/DSDB/SAMDB (show other bugs)
Version: 4.18.2
Hardware: x64 Linux
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-12 13:37 UTC by Luciano
Modified: 2023-05-16 03:17 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luciano 2023-05-12 13:37:31 UTC
samba-tool reports the following error when creating a trust between Samba 4.18.2 Active Directory and Microsoft Active Directory:

# Command-line:

samba-tool domain trust create infra.local --type=forest --direction=both --create-location=local --skip-validation --ipaddress=<PDC_IP_Address> --username=administrator@infra.local --password=Password

--

# Output:

LocalDomain Netbios[SAMDOM] DNS[samdom.internal] SID[S-1-5-21-xxxxx]

RemoteDC Netbios[ADDS01] DNS[ADDS01.infra.local] 

ServerType[PDC,GC,LDAP,DS,KDC,TIMESERV,CLOSEST,WRITABLE,FULL_SECRET_DOMAIN_6,ADS_WEB_SERVICE,DS_8,__unknown_00038000__]

RemoteDomain Netbios[INFRA] DNS[infra.local] SID[S-1-5-21-xxxxx]

Creating local TDO.

Local TDO created

Setting supported encryption types on local TDO.

ERROR(<class 'UnboundLocalError'>): uncaught exception - local variable 'remote_tdo_handle' referenced before assignment
  File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py", line 230, in _run
    return self.run(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/samba/netcmd/domain.py", line 2852, in run
    if remote_tdo_handle is not None:

--

Even with the error, the trust is created and authentication / authorization between the two parties works anyway.

# Environment information:

- Linux distribution / version: Ubuntu 22.04.2 LTS
- Samba version: 4.18.2
- Microsoft Active Directory domain controllers: Windows Server 2019 or Windows Server 2022 (same behavior with either)
- Microsoft Active Directory forest and domain level: 2012 or 2016 (same behavior with either)
Comment 1 Jo Sutton 2023-05-14 20:35:46 UTC
The UnboundLocalError was fixed in commit e4b81f7f6d43fba73ca4f34ed412fe85d35fb7cb, but the fix was not backported to 4.18.
Comment 2 Jo Sutton 2023-05-16 03:17:16 UTC
I didn’t mean to imply that a deliberate decision was made not to backport the fix. A patch that wasn’t considered for backporting at the time it was merged can still receive a backport later, if to do so would be worthwhile.