summaryrefslogtreecommitdiff
path: root/python/samba/netcmd
AgeCommit message (Collapse)AuthorFilesLines
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>
2019-02-21samba-tool dsacl: Mark old and new descriptor output correctlyAndrew Bartlett1-4/+7
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-02-21Add command "samba-tool dsacl get" This code is very equal to "samba-tool ↵Martin Krämer1-0/+48
dsacl set", except it only prints out the current sddl of an object. Signed-off-by: Martin Krämer <mk.maddin@gmail.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-21Update dsacl.py - add_ace to handle/verify sddl parameter correctMartin Krämer1-14/+17
Test for samba-tool dsacl set --sddl parmeter Update tests.py - add dsacl (dsacl.py / samba-tool dsacl set) test Signed-off-by: <Martin Krämer mk.maddin@gmail.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-21dbcheck: skip reverse member link checks when cli option specifiedJoe Guo1-1/+9
currently dbcheck cmd tooks about 1 day to finish on a 100k user database. We can skip member reverse link checks to speed it up dramatically. A new cli option is added to enable the skipping. 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>
2019-02-13spelling of associatedDouglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01netcmd: Improve error handling of gpo aclcheck as non-adminTim Beale1-0/+4
Reading the nTSecurityDescriptor attribute over LDAP requires admin creds. However, if you don't specify admin creds, then you get an error like this: bin/samba-tool gpo aclcheck ERROR(<class 'KeyError'>): uncaught exception - 'No such element' File "bin/python/samba/netcmd/__init__.py", line 184, in _run return self.run(*args, **kwargs) File "bin/python/samba/netcmd/gpo.py", line 1536, in run ds_sd_ndr = m['nTSecurityDescriptor'][0] This patch adds an explicit check/error message to make the problem clearer. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-21netcmd: Try to improve domain backup error messageTim Beale1-2/+3
I ran this command as non-root by mistake and didn't find the error message particularly helpful. Tweak the error message so it reminds the user that they should be root. Also display the path we're looking for the sam.ldb file in, to give them more clues. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Mon Jan 21 16:34:06 CET 2019 on sn-devel-144
2019-01-18python: dsal: Fix possibility of identical ACE's being added.Martin Krämer1-1/+1
Currently it is possible to add the same ace multiple times if the case sensitivity does not match the existing one using "--sddl" parameter. As an example while an ace "OA;CIIO;RPWP;3e978925-8c01-11d0-afda-00c04fd930c9;bf967a86-0de6-11d0-a285-00aa003049e2;PS" already exists a sddl "OA;CIIO;RPWP;3E978925-8C01-11D0-AFDA-00C04FD930C9;BF967A86-0DE6-11D0-A285-00AA003049E2;PS" can be added without detection (and can be added multiple times). As an end result after a high number of addings (in my tests it was about 1600-1800 aces for one object) no further changes on that object are possible. Signed-off-by: Martin Krämer <mk.maddin@gmail.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Rowland Penny <rpenny@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jan 18 23:19:13 CET 2019 on sn-devel-144
2019-01-17netcmd: Change GPO commands to use s3 SMB Py bindingsTim Beale1-2/+5
This means we can now use GPO commands on a DC that has SMBv1 disabled. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-17netcmd: Change SMB flags from s4 Py bindings to s3Tim Beale1-6/+7
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
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>
2019-01-14netcmd: Change domain backup commands to use s3 SMB Py bindingsTim Beale1-2/+6
This means we can now backup a DC that has SMBv1 disabled. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Tim Beale <timbeale@samba.org> Autobuild-Date(master): Mon Jan 14 06:49:09 CET 2019 on sn-devel-144
2019-01-10netcmd: Fix broken samba-tool gpo commandsTim Beale1-0/+1
samba-tool gpo create|fetch|backup commands throw exceptions due to a missing Python import: ERROR(<class 'NameError'>): uncaught exception - name 'tempfile' is not defined File "bin/python/samba/netcmd/__init__.py", line 184, in _run return self.run(*args, **kwargs) File "bin/python/samba/netcmd/gpo.py", line 980, in run tmpdir, gpodir = self.construct_tmpdir(tmpdir, gpo) File "bin/python/samba/netcmd/gpo.py", line 386, in construct_tmpdir tmpdir = tempfile.mkdtemp() Introduced by commit e3320b6d3df7a0c7b refactor. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Thu Jan 10 16:21:23 CET 2019 on sn-devel-144
2019-01-09netcmd/user: python[3]-gpgme unsupported and replaced by python[3]-gpgJoe Guo1-25/+61
python[3]-gpgme is deprecated since ubuntu 1804 and debian 9. use python[3]-gpg instead, and adapt the API. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13728 Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-01-08netcmd: Small refactor to SMB connection in domain backupTim Beale1-2/+7
Rework the code so we only do this in one place. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Tim Beale <timbeale@samba.org> Autobuild-Date(master): Tue Jan 8 03:13:48 CET 2019 on sn-devel-144
2019-01-07netcmd: Refactor duplicated SMB connect in GPO commandsTim Beale1-24/+18
Do the SMB connection in a single helper function. Note: this highlights that perhaps we want all SMB connections to be signed, but we can fix that up separately. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-12-19samba-tool: don't print backtrace on simple DNS errorsBjörn Jacke1-5/+5
samba-tool throws backtraces even for simple DNS error messages, we should not frighten users for no good reason. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13721 Signed-off-by: Bjoern Jacke <bj@sernet.de> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Björn Jacke <bj@sernet.de> Autobuild-Date(master): Wed Dec 19 20:58:52 CET 2018 on sn-devel-144
2018-12-10python/samba/netcmd: PY3 port for samba4.drs.samba_tool_drs_showreplNoel Power1-10/+10
Fix various ldb.bytes that need to be stringified in order to get tests to pass Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@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-12-04netcmd: Minor changes to 'group stats' commandTim Beale1-18/+25
These changes were inadvertently left off 0c910245fca70948a3. (They were made to the 2nd patch-set iteration posted to the mailing-list, but for some reason the first patch-set got delivered). Changes are: + rework some variable names for better readability + Average members defaulted to int, so lost any floating point precision. + Replace 'Min members' (which was fairly meaningless) with 'Median members per group'. + Fix flake8 long line warnings Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-23samba-tool processes: display pre-fork masters and workersGary Lockyer1-6/+69
Tag prefork work processes with "(worker 0)", and sort the process list on server name to get a consistent order. Service: PID -------------------------------------- cldap_server 15588 ... ldap_server 15584 ldap_server(worker 0) 15627 ldap_server(worker 1) 15630 ldap_server(worker 2) 15632 ldap_server(worker 3) 15634 nbt_server 15576 notify-daemon 15638 ... samba 0 ... wrepl_server 15580 Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-21samba-tool ldapcmp: print DNs on predictable orderDouglas Bagnall1-2/+2
Rather than unstable hash order. Ideally we'd do them in proper DN order. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-21netcmd/ldapcmp: make code pythonicJoe Guo1-11/+6
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-11-21netcmd/ldapcmp: promote re object to globalJoe Guo1-7/+5
Then we can reuse the re obj. 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-11-21netcmd/ldapcmp: use set instead of list to compare attrsJoe Guo1-31/+22
This will simplify the logic and improve performance. 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-11-21netcmd/ldapcmp: fix wrong way for string copyJoe Guo1-4/+4
Two mistakes here: - res[:-1] will copy but lost the last char - string is immutable in python, there is no need to copy it explicitly 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-11-21netcmd/ldapcmp: pass --skip-missing-dn to LDAPBaseJoe Guo1-2/+2
This option has default value False, and was actually not passed down from cli to LDAPBase. However, LDAPBase.__init__ has default value True for it. After the change, a few tests using ldapcmp are affected. Add --skip-missing-dn explicitly to keep the behavior consistent, otherwise test will fail. 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-11-21netcmd/ldapcmp: avoid modifying data while looping on dictJoe Guo1-5/+7
Just define another dict for return value, seems no need to modify original dict. 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-11-21netcmd/ldapcmp: rm unused global var summaryJoe Guo1-6/+0
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-11-21netcmd/ldapcmp: use set instead of list to find missing DNsJoe Guo1-49/+30
This simplify the logic and improve performance a lot. 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-11-21netcmd/ldapcmp: avoid list comprehension in for loopJoe Guo1-2/+6
The list comprehension will repeat for each item. For large database, this make the command freeze. 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-11-21netcmd/ldapcmp: add choices arg to --view optionJoe Guo1-3/+1
So we don't need to validate ourselves. 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-11-21netcmd/ldapcmp: add choices arg to --scope optionJoe Guo1-3/+1
So we don't need to validate ourselves. 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-11-21netcmd/ldapcmp: rename __eq__ to diffJoe Guo1-2/+2
This method actually changed both objects and print info. __eq__ is not a proper name and is not designed for this case. Rename to diff. 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-11-21netcmd/ldapcmp: fix typo for BundleJoe Guo1-4/+4
Bundel -> Bundle 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-11-20sync_passwords: Remove dirsync cookie logging for continuous operationGarming Sam1-1/+2
Under normal operation, users shouldn't see giant cookies in their logs. We still log the initial cookie retrieved from the cache database, which should still be helpful for identifying corrupt cookies. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13686 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-20netcmd: Flush replUpToDateVector when restoring offline backupTim Beale1-4/+34
The replUpToDateVector could be incorrect after an offline backup was restored. This means replication propagation dampening doesn't work properly. In the worst case, a singleton DC would have no replUpToDateVector at all, and so *all* objects created on that DC get replicated every time a new DRS connection is established between 2 DCs. This becomes a real problem if you used that singleton DC to create 100K objects... This patch flushes the replUpToDateVector when an offline backup gets restored. We need to do this before we add in the new DC and remove the old DCs. Note that this is only a problem for offline backups. The online/rename backups are received over DRS, and as part of the replication they receive the latest replUpToDateVector from the DC being backed up. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-20netcmd: Small backup refactor to avoid compatiblity problemsTim Beale1-3/+20
It will be easy to forget that the backupType marker doesn't exist on v4.9. However, this seems like a dumb reason not to support v4.9 backup-files. Add a wrapper function to avoid potential problems cropping up in future. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-20netcmd: Add backupType marker to backed-up DBTim Beale1-10/+23
We are starting to hit restore cases that are only applicable to a particular type of backup. We already had a marker to differentiate renames, but differentiating offline backups would also be useful. Note that this raises a slight compatibility issue for backups created on v4.9, as the marker won't exist. However, it's only offline backups we will use this marker for (at the moment), and this option doesn't exist on v4.9, so there's no problem. Removing the markers has been refactored out into a separate function to handle the optional presence of the new marker. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-14python/samba/netcmd: PY3 port samba4.blackbox.ldapcmp_restoreNoel Power1-0/+1
Convert attribute from bytes to str Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-14python/samba/netcmd: PY3 port samba.tests.samba_tool.editNoel Power1-1/+1
Need to write bytes to file Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-07samba-tool gpo: convert pseudo-method into methodDouglas Bagnall1-24/+23
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>