summaryrefslogtreecommitdiff
path: root/python/samba/netcmd/domain.py
AgeCommit message (Collapse)AuthorFilesLines
2022-05-10samba-tool: Don't try to delete local_tdo_handle twice.Joseph Sutton1-8/+0
This code is unreachable, as local_tdo_handle has already been deleted and set to None earlier. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-05-10python: Remove unnecessary 'pass' statementsJoseph Sutton1-1/+0
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-03-17samba-tool: Fix typoJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-02-23samba-tool/join_member: let py_net_join_member() choose the passwordStefan Metzmacher1-2/+0
It means we'll let trust_pw_new_value() generate the password. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14984 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-12-06samba-tool: Create DNS entries on member joinDavid Mulder1-3/+7
The net ads join command already handles this, and the call was missing from the python bindings for samba-tool domain join member. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-11-04samba-tool: Add domain member leaveDavid Mulder1-0/+31
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): Thu Nov 4 20:43:32 UTC 2021 on sn-devel-184
2021-06-22samba-tool: Demote computer to wellknown containerDavid Mulder1-1/+4
BUG: https://bugzilla.samba.org/show_bug.cgi?id=9143 Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-20samba-tool: Disable AD DC options in samba-tool domainDavid Mulder1-14/+16
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-10samba-tool domain: improve error message when `patch` failsDouglas Bagnall1-1/+2
The old message confused even the wisest among us: https://lists.samba.org/archive/samba/2021-May/236021.html and while /user/bin/patch might be overly specific, it should point people in the right direction. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-04-28python: remove all 'from __future__ import division'Douglas Bagnall1-1/+0
This made '//' and '/' in Python 2 behave as in Python 3. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-28python: remove all 'from __future__ import print_function'Douglas Bagnall1-1/+0
This made Python 2's print behave like Python 3's print(). In some cases, where we had: from __future__ import print_function """Intended module documentation...""" this will have the side effect of making the intended module documentation work as the actual module documentation (i.e. becoming __doc__), because it is once again the first statement in the module. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-21samba-tool: Use s3 net join for member joinDavid Mulder1-4/+39
The s4 member join code has been broken for some time. Modify samba-tool to instead use the working s3 member join code. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Wed Apr 21 21:40:13 UTC 2021 on sn-devel-184
2021-03-17samba-tool: domain tombstones expunge reminds on semi-noopDouglas Bagnall1-0/+7
Sometimes people assume `samba-tool domain tombstones expunge` will expunge tombstones, but in the general case it won't because it only affects those that have reached the tombstone lifetime, but these are likely to have already been deleted by the regularly scheduled task. You need to set the tombstone lifetime to have much effect. This patch doesn't change the behaviour, but it does warn the user that they are probably doing nothing of significance. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-09samba-tool domain: move timestamp functions to commonDouglas Bagnall1-20/+3
Other tools use identical functions, and they too can use common.py Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2020-11-06Use the new CreateTrustedDomainRelax()Isaac Boukris1-44/+13
Signed-off-by: Isaac Boukris <iboukris@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2020-10-22python: Create targetdir recursivelyAndreas Schneider1-1/+1
This fixes `make test` in a release tarball. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14542 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2020-10-02python2 reduction: Merge remaining compat code into commonDavid Mulder1-1/+1
The remaining compat code (get_string, get_bytes, cmp) are useful helper routines which we should simply merge into common (especially since there is some duplication here). Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Fri Oct 2 14:49:36 UTC 2020 on sn-devel-184
2020-08-11python compat: remove binary_typeDouglas Bagnall1-2/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2020-07-17python: wrap 'import dckeytab' in an explanatory functionDouglas Bagnall1-1/+2
The samba.dckeytab module has magic effects on samba.net, but never appears to be used. That can be confusing, both to people and to linters. Here we wrap that confusion up into a well-commented function, so we never again have to wonder why the unused import is there. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: David Mulder <dmulder@samba.org>
2020-02-11samba-tool domain join: remove sub domain join codeGary Lockyer1-16/+10
Remove the unused sub domain join code, the option was removed by commit 5583208aed0e4647269e48aa1d3c5c48a73001ac. This commit completely removes the now unused code. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Feb 11 17:41:32 UTC 2020 on sn-devel-184
2019-12-20pysmbd: make "session_info" arg to py_smbd_set_nt_acl() mandatoryRalph Boehme1-2/+9
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-10-22samba-tool domain: fix an unhandled exceptionAmit Kumar1-1/+5
Uncaught exception on running 'samba-tool domain schemaupgrade' ERROR(<class 'ModuleNotFoundError'>): uncaught exception - No module named 'markdown' File "/usr/lib64/python3.7/site-packages/samba/netcmd/__init__.py", line 185, in _run return self.run(*args, **kwargs) File "/usr/lib64/python3.7/site-packages/samba/netcmd/domain.py", line 4157, in run from samba.ms_schema_markdown import read_ms_markdown File "/usr/lib64/python3.7/site-packages/samba/ms_schema_markdown.py", line 26, in <module> import markdown Signed-off-by: Amit Kumar amitkuma@redhat.com Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-09-01Spelling fixes s/overriden/overridden/Mathieu Parent1-6/+6
Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-08-30samba-tool domain provision: Remove experimental OpenLDAP supportAndrew Bartlett1-41/+0
This feature has long been obsolete, remaining only in the hope that it might be revived in the future. Specifically, in 2011 the S4 OpenLDAP backend HOWTO was removed: commit 1d46325af8541ea467c79cd86e65f93ce6a14ff4 Author: Andrew Bartlett <abartlet@samba.org> Date: Wed Apr 27 22:42:29 2011 +1000 Remove outdated S4 OpenLDAP backend HOWTO. There is a project to revive this, hosted here: https://github.com/Symas/samba and https://github.com/Symas/samba_overlays However discussions at SambaXP with Nadezhda Ivanova indicate a new approach with slapd being started by Samba and taught to read native Samba ldb files is more likely in the short term. This has the advantage that Samba's provision and offline tooling would not need to change, with the solution looking more like how BIND9_DLZ has access to the Samba DB. If any of this is required then reverting these patches will be the least of the difficulties in bringing this to production. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Nadezhda Ivanova <nivanova@symas.com>
2019-07-02samba-tool domain join: remove the subdomain optionGary Lockyer1-18/+5
Remove the sub domain option from join, as it currently does not work. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02samba-tool domain dcpromo: add --backend-store-size optionGary Lockyer1-1/+2
Add a new "samba-tool domain dcpromo" option "backend-store-size". This allows the lmdb map size to be set during a promotion, instead of hard-wiring it to 8Gb. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02samba-tool domain join: Add --backend-store-size optionGary Lockyer1-2/+4
Add a new "samba-tool domain join" option "backend-store-size". This allows the lmdb map size to be set during a provision, instead of hard-wiring it to 8Gb. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02provision: Add --backend-store-size optionGary Lockyer1-6/+3
Add a new "samba-tool domain provision" option "backend-store-size". This allows the lmdb map size to be set during a provision, instead of hard-wiring it to 8Gb Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02samba-tool domain provision: add lmdb database size optionGary Lockyer1-9/+19
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-06-26schema: changing default base schema to 2012_R2Aaron Haslett1-2/+2
Changing default base schema from 2008_R2 to 2012_R2 Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-04-05netcmd: Fix passwordsettings --max-pwd-age commandTim Beale1-2/+12
The min_pwd_age and max_pwd_age parameters are both optional and default to None. However, if we just set the max-pwd-age, then the check 'min_pwd_age >= max_pwd_age' will throw a Python exception because it's trying to compare an int to NoneType (min_pwd_age). This works on Python 2 but is a problem on Python 3. We could just add a check that min_pwd_age is not None, but that defeats the point of having the check if you're only setting either the min or max age indepedently. This patch gets the current min/max password age from the DB (in ticks). If either setting is changed, the ticks will be updated. Then at the end we check the min is still less than the max (to do this, we convert the ticks back to days in the interests of readability). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13873 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Apr 5 08:03:08 UTC 2019 on sn-devel-144
2019-04-05netcmd: Add some timestamp conversion helper functionsTim Beale1-10/+22
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13873 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-04-05netcmd: Use python constant for -0x8000000000000000Tim Beale1-5/+9
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13873 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-04-02Spelling fix s/informations/information/Mathieu Parent1-1/+1
Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-03-12samba-tool domain provision: Fix --interactive module in python3Andrew Bartlett1-0/+1
The prompts were not being printed to the screen because the stream was not being flushed. As reported on the samba mailing list by Adam Xu: https://lists.samba.org/archive/samba/2019-March/221753.html BUG: https://bugzilla.samba.org/show_bug.cgi?id=13828 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Tim Beale <timbeale@catalyst.net.nz>
2019-01-16join: Fix TypeError when handling exceptionTim Beale1-1/+1
When we can't resolve a domain name, we were inadvertently throwing a TypeError whilst trying to output a helpful message. E.g. ERROR(<class 'TypeError'>): uncaught exception - 'NTSTATUSError' object does not support indexing Instead of indexing the object, we want to index the Exception.args so that we just display the string portion of the exception error. The same problem is also present for the domain trust commands. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13747 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org> Reviewed-by: Jeremy Allison <rpenny@samba.org>
2018-12-10python/samba/netcmd: PY3 fix samba4.blackbox.trust_utils testNoel Power1-4/+4
In python3 we are using ldb.bytes where we need strings Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-01samba-tool domain: remove unused variablesDouglas Bagnall1-4/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-10-29python: do not use "is" for string equalityDouglas Bagnall1-2/+2
This is not always going to work, and is not guaranteed to be consistent even between minor versions. Here is a simple counterexample: >>> a = 'hello' >>> a is 'hello' True >>> a is 'hello'.lower() False >>> a == a.lower() True Possibly it always works for the empty string, but we cannot rely on that. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Oct 29 23:13:36 CET 2018 on sn-devel-144
2018-10-25samba-tool domain: remove unused importsDouglas Bagnall1-4/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-10-23python/samba/netcmd: PY3 make sure get_testparm_var returns 'str'Noel Power1-2/+3
part of PY3 port samba4.blackbox.upgrade.samba3-upgrade* Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-23python/samba/netcmd: PY3 Fix error in samba4.blackbox.schemaupgradeNoel Power1-1/+1
Getting Exception: must be str, not ldb.bytes error in scheme_upgrade phase of test Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-23python/samba/netcmd: PY3 only possible to decode bytesNoel Power1-1/+1
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-12netcmd: Change Py3 incompatible long() for tombstone expungeTim Beale1-2/+2
The code to expunge tombstones uses long(), which is not Python3 compatible. Python3 uses int() instead, and works out how big it needs to be. As long as we don't run the samba-tool command on a 32-bit machine after the year 2038, then we should avoid any integer overflow on Python 2.x. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-10-10netcmd: apply the new get_logger to cmdsJoe Guo1-33/+5
This is an example of how to use the new logger. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-26join: Avoid duplicating "Default-First-Site-Name" stringTim Beale1-3/+0
The provision code already defines "Default-First-Site-Name" so we might as well reuse it. The join.py already uses a suitable default, so assigning the default in the domain netcmd code is unnecessary. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-06PEP8: fix E123: closing bracket does not match indentation of opening ↵Joe Guo1-2/+2
bracket's line Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-06PEP8: fix E122: continuation line missing indentation or outdentedJoe Guo1-4/+4
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-03python/samba/netcmd: Fix password usage for py2/py3 compatabilityNoel Power1-2/+5
getpass returns str (e.g. bytes) in python2 and str (unicode) in py3. Adapt code to so we don't do illegal things (like try and decode) a string in python3 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: better formatting of (CONST1|CONST2)Douglas Bagnall1-1/+3
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>