]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool: Pick local host if calling samba-tool from DC
authorDavid Mulder <dmulder@suse.com>
Mon, 25 Oct 2021 14:49:35 +0000 (08:49 -0600)
committerDavid Mulder <dmulder@samba.org>
Tue, 26 Oct 2021 14:23:42 +0000 (14:23 +0000)
It is reasonable to assume, that if we are running a command from a DC,
that a user expects that the command will run against this DC.

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Rowland Penny <rpenny@samba.org>
Autobuild-User(master): David Mulder <dmulder@samba.org>
Autobuild-Date(master): Tue Oct 26 14:23:42 UTC 2021 on sn-devel-184

python/samba/netcmd/common.py

index bb17bfa10f2f21f3bc8abfc9c8f8f5f6dbb89057..588806b2ad31b85c97e13234d1bcd0b7e7fd3a43 100644 (file)
@@ -18,6 +18,7 @@
 #
 
 import re
+from socket import gethostname
 from samba.dcerpc import nbt
 from samba.net import Net
 import ldb
@@ -59,6 +60,10 @@ def netcmd_finddc(lp, creds, realm=None):
     '''Return domain-name of a writable/ldap-capable DC for the default
        domain (parameter "realm" in smb.conf) unless another realm has been
        specified as argument'''
+    # It is reasonable to assume, that if we are running a command from a DC,
+    # that a user expects that the command will run against this DC.
+    if lp.get('server role') == 'active directory domain controller':
+        return gethostname()
     net = Net(creds=creds, lp=lp)
     if realm is None:
         realm = lp.get('realm')