Bug 284603 - net/samba420: samba-tool domain provision failed
Summary: net/samba420: samba-tool domain provision failed
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: FreeBSD Samba Team (mail alias)
URL:
Keywords:
Depends on:
Blocks: DEFAULT_VERSIONS=samba=4.20
  Show dependency tree / graph
 
Reported: 2025-02-06 09:05 UTC by shellingfield
Modified: 2025-12-23 23:30 UTC (History)
7 users (show)

See Also:
bugzilla: maintainer-feedback? (samba)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shellingfield 2025-02-06 09:05:11 UTC
env:
 - FreeBSD 14.2-RELEASE-p1
 - net/samba420

command:
# samba-tool domain provision --domain=DEV --realm=dev.example.com --adminpass=XXXXXXXXXX --use-rfc2307 --dns-backend=BIND9_DLZ --server-role dc

result:
WARNING: Using passwords on command line is insecure. Installing the setproctitle python module will hide these from shortly after program start.
INFO 2025-02-06 10:38:31,462 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2119: Looking up IPv4 addresses
INFO 2025-02-06 10:38:31,462 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2136: Looking up IPv6 addresses
WARNING 2025-02-06 10:38:31,462 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2143: No IPv6 address will be assigned
INFO 2025-02-06 10:38:31,683 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2309: Setting up share.ldb
INFO 2025-02-06 10:38:31,703 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2313: Setting up secrets.ldb
INFO 2025-02-06 10:38:31,714 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2318: Setting up the registry
INFO 2025-02-06 10:38:31,748 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2321: Setting up the privileges database
INFO 2025-02-06 10:38:31,769 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2324: Setting up idmap db
INFO 2025-02-06 10:38:31,784 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #2331: Setting up SAM db
INFO 2025-02-06 10:38:31,793 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #882: Setting up sam.ldb partitions and settings
INFO 2025-02-06 10:38:31,793 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #894: Setting up sam.ldb rootDSE
INFO 2025-02-06 10:38:31,795 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1310: Pre-loading the Samba 4 and AD schema
Unable to determine the DomainSID, can not enforce uniqueness constraint on local domainSIDs

INFO 2025-02-06 10:38:31,828 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1387: Adding DomainDN: DC=dev,DC=example,DC=com
INFO 2025-02-06 10:38:31,838 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1419: Adding configuration container
INFO 2025-02-06 10:38:31,849 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1434: Setting up sam.ldb schema
INFO 2025-02-06 10:38:33,535 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1454: Setting up sam.ldb configuration data
INFO 2025-02-06 10:38:33,652 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1496: Setting up display specifiers
INFO 2025-02-06 10:38:34,665 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1504: Modifying display specifiers and extended rights
INFO 2025-02-06 10:38:34,689 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1511: Adding users container
INFO 2025-02-06 10:38:34,691 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1517: Modifying users container
INFO 2025-02-06 10:38:34,691 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1520: Adding computers container
INFO 2025-02-06 10:38:34,692 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1526: Modifying computers container
INFO 2025-02-06 10:38:34,693 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1530: Setting up sam.ldb data
INFO 2025-02-06 10:38:34,792 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1561: Setting up well known security principals
INFO 2025-02-06 10:38:34,812 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1575: Setting up sam.ldb users and groups
INFO 2025-02-06 10:38:34,901 pid:66515 /usr/local/lib/python3.11/site-packages/samba/provision/__init__.py #1583: Setting up self join
check_spn_alias_collision: trying to add SPN 'DNS/vm-freebsd2.dev.example.com' on 'CN=dns-vm-freebsd2,CN=Users,DC=dev,DC=example,DC=com' when 'host/vm-freebsd2.dev.example.com' is on 'CN=VM-FREEBSD2,OU=Domain Controllers,DC=dev,DC=example,DC=com'
Repacking database from v1 to v2 format (first record CN=ms-DNS-Propagation-Time,CN=Schema,CN=Configuration,DC=dev,DC=example,DC=com)
Repack: re-packed 10000 records so far
Repacking database from v1 to v2 format (first record CN=domainDNS-Display,CN=412,CN=DisplaySpecifiers,CN=Configuration,DC=dev,DC=example,DC=com)
Repacking database from v1 to v2 format (first record CN=AdminSDHolder,CN=System,DC=dev,DC=example,DC=com)

ERROR(<class 'NameError'>): uncaught exception - name 'targetdir' is not defined
  File "/usr/local/lib/python3.11/site-packages/samba/netcmd/__init__.py", line 285, in _run
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/samba/netcmd/domain/provision.py", line 343, in run
    result = provision(self.logger,
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/samba/provision/__init__.py", line 2363, in provision
    provision_fill(samdb, secrets_ldb, logger, names, paths,
  File "/usr/local/lib/python3.11/site-packages/samba/provision/__init__.py", line 1972, in provision_fill
    if targetdir and smbd.have_nfsv4_acls() and smbd.has_nfsv4_acls(targetdir):
       ^^^^^^^^^

misc:
 - w/o --dns-backend=BIND9_DLZ, or adding --targetdir would not change at all
 - this was worked on net/samba419.

some files created in provisioning are successfully stored into /var/db/samba4/ and also created /usr/local/etc/smb4.conf, but not completely.

Regards,
Comment 1 Roger Fujii 2025-04-26 11:34:46 UTC
Looks like the problem is that targetdir is used and isn't passed down.  The problem can be fixed by passing targetdir to provision_fill, so the calls in join.py, line 919 (I passed ctx.targetdir just before ctx.paths )

and 

__init__.py, line 1913 ( added targetdir as a parameter )

These files are in /usr/local/lib/python3.11/site-packages/samba
Comment 2 Michael Osipov freebsd_committer freebsd_triage 2025-04-26 18:22:23 UTC
(In reply to Roger Fujii from comment #1)

Is this an upstream or downstream problem?
Comment 3 Roger Fujii 2025-04-27 18:49:33 UTC
Unclear if it is upstream or downstream - I only debugged the 420 pkg install.   As this is with samba-tool, which is a python package, not sure where the source came from, so figured the ports builder would know.
Comment 4 Michael Osipov freebsd_committer freebsd_triage 2025-04-28 12:16:57 UTC
(In reply to Roger Fujii from comment #3)

My question was rather whether why apply a downstream patch which could break it. I didn't check it.
Comment 5 ml 2025-06-30 04:39:56 UTC
(In reply to Michael Osipov from comment #4)

I thinks it's a downtream problem: "targetdir" usage in "provision_fill" is added by patch "0024-Cherry-pick-ZFS-provisioning-code-by-iXsystems-Inc.patch".
So, possibly, it's that patch that is incomplete.
Comment 7 Hiroo Ono 2025-12-22 12:08:21 UTC
the targetdir argument should not be added to provision_fill in python/samba/provision/__init__.py.

The official samba 4.20.7's provision_fill() does not have targetdir (look around lines 1965-1968):
https://gitlab.com/samba-team/samba/-/blob/samba-4.20.7/python/samba/provision/__init__.py?ref_type=tags

While the file from the package samba420-4.20.7_11 has line below on 1972:

        if targetdir and smbd.have_nfsv4_acls() and smbd.has_nfsv4_acls(targetdir):

This line should have been deleted.
Comment 8 Mateusz Piotrowski freebsd_committer freebsd_triage 2025-12-23 22:23:31 UTC
(In reply to Hiroo Ono from comment #7)

So, would you say that:

    if targetdir and smbd.have_nfsv4_acls() and smbd.has_nfsv4_acls(targetdir):
         smbd.set_nfsv4_defaults()

is entirely incorrect and should be removed from net/samba420?

If so, then we should remove that from net/samba422 and net/samba423 as well.
Comment 9 Andrej Ebert 2025-12-23 23:10:34 UTC
(In reply to Mateusz Piotrowski from comment #8)

As far as I remember, targetdir for is added by some of the zfs/nfsv4acl compatibility patches, I think there's just some place where it needs to be added, rather than removed completely. At least I wouldn't  remove it in the working 422 port.
Comment 10 Hiroo Ono 2025-12-23 23:30:12 UTC
(In reply to Mateusz Piotrowski from comment #8)

Sorry, this was a part added by FreeBSD ports' patch, so we should keep it.

An annoying thing is that the targetdir argument of provision_fill() is
removed between samba4.19 and samba4.20 as it is not used in official version,
and we have to add targetdir argument forever. (4.22 and 4.23 also need it).

https://gitlab.com/samba-team/samba/-/blob/samba-4.19.9/python/samba/provision/__init__.py?ref_type=tags
line 1922

https://gitlab.com/samba-team/samba/-/blob/samba-4.20.8/python/samba/provision/__init__.py?ref_type=tags
line 1906