summaryrefslogtreecommitdiff
path: root/python/samba/netcmd
AgeCommit message (Collapse)AuthorFilesLines
2019-11-10Make sure backup temp directory gets deleted on exceptionHeiko Baumann1-42/+43
This fix ensures that the samba-tool backup temp directory is removed if an exception occurs (e.g. LDAP_INVALID_CREDENTIALS). Signed-off-by: Heiko Baumann <heibau@gmail.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-10-31python/samba/netcmd/gpo.py: typo fixesBjörn Jacke1-0/+1
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-10-23samba-tool: py3 compatiblity in 'user syncpasswords --daemon'Heinz Hoelzl1-1/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14154 Signed-off-by: Heinz Hölzl <heinz.hoelzl@gvcc.net> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Björn Baumbach <bb@sernet.de> Autobuild-User(master): Björn Baumbach <bb@sernet.de> Autobuild-Date(master): Wed Oct 23 15:54:43 UTC 2019 on sn-devel-184
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-10-17samba-tool: Add facility to add rfc2307 attributes to an already created ↵Rowland Penny2-0/+320
user or group Signed-off-by: Rowland Penny <rpenny@samba.org> Reviewed-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlet <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Oct 17 12:21:55 UTC 2019 on sn-devel-184
2019-10-17samba-tool: Update 'samba-tool gpo list <>' descriptionAmit Kumar1-7/+7
We have a command to get gpo listing from Active Directory. samba-tool gpo list <username> This command can list GPOs for both username and machinename, But command help only shows 'username'. This PR - Updates the option presented in help. - Updates name of variable used to retrieve GPO so that it's not misleading if someone reads code later on BUG: https://bugzilla.samba.org/show_bug.cgi?id=14016 Signed-off-by: Amit Kumar <amitkuma@redhat.com> Reviewed-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): Thu Oct 17 09:21:20 UTC 2019 on sn-devel-184
2019-09-24user.py: avoid inefficient string concatenationsBjörn Jacke1-30/+28
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-09-24gpo.py: avoid inefficient string concatenationsBjörn Jacke1-6/+3
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-09-21user.py: import tempfile module only where neededBjörn Jacke1-1/+1
Signed-off-by: Bjoern Jacke <bjacke@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-08-22python: use os.urandom, which is available in python by definitionBjörn Jacke1-39/+2
os.urandom also uses CSPRNG methods like getrandom() when the underlying OS provides those. Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-08-17Prevent samba-tool online backup crashDavid Mulder1-0/+1
On some GPOs, getting a files ntacl throws an NT_STATUS_ACCESS_DENIED. Catch and log the failure when this happens. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14088 Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Tim Beale <timbeale@samba.org>
2019-07-31netcmd: Allow drs replicate --local to create partitionsGarming Sam1-1/+3
Currently, neither the offline (--local) or online (normal replica sync) methods allow partition creation post-join. This overrides the Python default to not create the DB, which allows TDB + MDB to work. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14051 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-24netcmd: Better error message for backup with no RID poolTim Beale1-5/+13
Add a better error message (and what to do about it) if the user tries to back up a DC that hasn't initialized its RID pool yet. Seems to be a fairly common problem hit by users. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14048 RN: Added more informative error message if the 'samba-tool domain backup' command fails due to no RID pool being present on the DC. 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): Wed Jul 24 07:07:01 UTC 2019 on sn-devel-184
2019-07-04samba-tool: implement contact management commandsBjörn Baumbach2-0/+677
Usage: samba-tool contact <subcommand> Contact management. Available subcommands: create - Create a new contact. delete - Delete a contact. edit - Modify a contact. list - List all contacts. move - Move a contact object to an organizational unit or container. show - Display a contact. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool group: add 'edit' command to edit an AD group objectBjörn Baumbach1-0/+114
Same like the samba-tool user edit command. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool computer: add 'edit' command to edit an AD computer objectBjörn Baumbach1-1/+122
Similar to the samba-tool user edit command. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool user edit: avoid base64 encoded strings in editable ldif if possibleBjörn Baumbach2-2/+46
Use clear text arguments strings if possible. Makes it more comfortable for users to edit the user objects attributes. Remove test from knownfail: samba.tests.samba_tool.user_edit.change_attribute_force_no_base64 Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool user edit: simplify codeBjörn Baumbach1-3/+1
Use "None"-changetype here, instead of "Add". This avoids the need to remove the changetype line afterwards. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool user edit: use ldb methods to create ldif to modify userBjörn Baumbach1-38/+13
Remove tests from knownfail: samba.tests.samba_tool.user_edit.add_attribute_base64 samba.tests.samba_tool.user_edit.add_attribute_base64_control samba.tests.samba_tool.user_edit.change_attribute_base64_control BUG: https://bugzilla.samba.org/show_bug.cgi?id=14003 Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04samba-tool: fix format of command description (help messages)Björn Baumbach5-18/+18
Need to quote the backslash '\'. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
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 clone-dc-database: Add --backend-store-size optionGary Lockyer1-3/+13
Add a new "samba-tool drs clone-dc-database" option "backend-store-size". This allows the lmdb map size to be set during a clone, 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-07-02samba-tool: Make the 'bytes' option type avaiableGary Lockyer1-1/+2
Allow samba tool to use the custom bytes option type. Option("--size", type="bytes", metavar="SIZE") To allow the input of file and memory sizes using unit suffixes i.e. 2Gb, 4KiB ... 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-06-18samba-tool: add ntacl changedomsid commandBjörn Baumbach1-0/+164
This tool is meant to locally change all entries in acl_xattr when the machine's SID has accidentially changed or the data set has been copied to another box either via backup/restore or rsync. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-06-18samba-tool ntacl: consolidate code for getting the local domain sidBjörn Baumbach1-53/+32
Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-05-30samba-tool: add 'import samba.drs_utils' to fsmo.pyBjörn Baumbach1-0/+1
On some systems we're seeing this: ERROR(<type 'exceptions.AttributeError'>): uncaught exception - 'module' object has no attribute 'drs_utils' File "/usr/lib/python2.7/dist-packages/samba/netcmd/__init__.py", line 185, in _run return self.run(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/samba/netcmd/fsmo.py", line 533, in run transfer_dns_role(self.outf, sambaopts, credopts, role, samdb) File "/usr/lib/python2.7/dist-packages/samba/netcmd/fsmo.py", line 136, in transfer_dns_role except samba.drs_utils.drsException as e: E.g. it happens on debian stretch (9.9) with python 2.7.13 (on 4.10.4) While it doesn't happen on ubuntu 18.04 with python 2.7.15rc1 or with python 3.6.7. There were also some reports on the mailing lists, see: https://lists.samba.org/archive/samba-technical/2019-May/133624.html BUG: https://bugzilla.samba.org/show_bug.cgi?id=13973 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bbaumbach@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu May 30 08:27:24 UTC 2019 on sn-devel-184
2019-05-30samba-tool: use only one LDAP modify for dns partition fsmo role transferStefan Metzmacher1-16/+6
We should not risk that we end with no role owner. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13973 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-05-30samba-tool: fix replication after dns partition fsmo role transferStefan Metzmacher1-1/+3
The new role owner need to replicate from the old role owner. Before we told the old role owner to replicate from itself. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13973 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-05-29samba-tool dns: use bytes for inet_ntopDouglas Bagnall1-2/+3
From Python's point of view, array.AddrArray is a list of byte-valued integers. In Python 3 we can convert directly using the likes of bytes(array.AddrArray[i].MaxSa[8:24]) but in 4.10 we need to support both, so we use struct. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Wed May 29 11:29:17 UTC 2019 on sn-devel-184
2019-04-11ldapcmp: ignore 'schemaInfo' if two domains are comparedStefan Metzmacher1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13799 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
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 Parent2-2/+2
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-30samba-tool: fix some typosBjörn Baumbach2-4/+4
All command descriptions have a dot '.' at the end. The ou and visualize command need this too. ... group - Group management. ldapcmp - Compare two ldap databases. ntacl - NT ACLs manipulation. ou - Organizational Units (OU) management ... user - User management. visualize - Produces graphical representations of Samba network state Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-03-14dbcheck: don't check expired tombstone objects by default anymoreStefan Metzmacher1-1/+2
These will be removed anyway and any change on them risks to be an originating update that causes replication problems. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Mar 14 03:12:27 UTC 2019 on sn-devel-144
2019-03-14dbcheck: add --selftest-check-expired-tombstones cmdline optionStefan Metzmacher1-1/+6
This will be used by dbcheck tests which operate on static/old provision dumps in the following commits. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14python/samba/netcmd: provide SUPPRESS_HELP via Option classStefan Metzmacher1-0/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
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-03-12gpo: Backup a policy folder containing GPE.INIGarming Sam1-0/+6
The GPE.INI file does not appear to be documented anywhere in the protocol specifications and seems to be due to legacy code. It appears that it used to be how the gPCUserExtensionNames and gPCMachineExtensionNames were maintained without the requirement for LDAP. All we do is ignore the parsing of this file and copy it over as binary. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13825 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Mar 12 01:41:32 UTC 2019 on sn-devel-144
2019-03-12gpo: During restore clobber GPT.INI with a blank versionGarming Sam1-5/+18
Generally speaking, there is not much value to keeping this file. The display name does not ever seem to be used and the version only applies to the original domain or DC it was on. The command line option to revert this behaviour is mostly for the tests or for having a straight 1:1 backup-restore for pure restoration. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13806 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Restore gPCMachineExtensionNames and gPCUserExtensionNamesGarming Sam1-1/+25
After creating a backup and calling 'gpo restore', this makes it so that restoring a GPO will instantly enable it for use. There might be some cases where we might not want to do this, but for now just do it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13627 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Ensure that gplink works when emptyGarming Sam1-1/+5
It appears that RSAT can leave a space in the gPLink field, which we need to handle. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13564 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>