summaryrefslogtreecommitdiff
path: root/source4/libnet
AgeCommit message (Collapse)AuthorFilesLines
2018-05-17FIXUP: Improve memory handling on py_net_change_passwordAndrew Bartlett1-2/+7
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <noel.power@suse.com> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Thu May 17 14:28:19 CEST 2018 on sn-devel-144
2018-05-17s4/libnet: Allow passwords containing non ascii characters to be passedNoel Power1-9/+14
Although we can pass unicode to py_net_change_password unfortunately in Python2 unicode strings are encoded with the default encoding (e.g. ascii) when extracting the unicode string to buffer. In Python3 the default encoding for "s" format is utf8. Use the "es" format instead of "s" so we can specify the encoding so behaviour is correct in py2/py3. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-10samdb: Add remote address to connectGary Lockyer1-2/+3
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-04-13s3/libnet/wscript: build samba-net lib for extra-python/py3Noel Power1-10/+15
python_net needs to link appropriate samba-net library for extra-py/py3 version so we need to build it for extra-python/py3 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-13wscript_build: make sure we link extra-python versions of librariesNoel Power1-1/+1
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23python3 port for dckeytab moduleNoel Power2-13/+25
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-19bugfix memory leak. partition_dn is only used to search and compare and is ↵Andrej Gessel1-2/+2
not freed at the function end. Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-03-03Replace NT_STATUS_HAVE_NO_MEMORY macroSwen Schillig1-2/+8
Replaced NT_STATUS_HAVE_NO_MEMORY macro and fixed memory leaking error-path. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Sat Mar 3 00:00:34 CET 2018 on sn-devel-144
2018-03-02Minor cleanup of libnet_LookupName_recvSwen Schillig1-30/+39
Reduce indentation level and comply with 80 column rule. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2018-03-02Zero libnet_LookupName out struct before usingSwen Schillig1-4/+1
Zero libnet_LookupName out struct before setting results, preventing false result interpretation. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
2018-02-24Minor cleanup to libnet_join_memberSwen Schillig1-27/+19
Prevent code duplication by consolidating cleanup task at the end of the function. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Feb 24 23:19:05 CET 2018 on sn-devel-144
2018-02-01talloc_zero libnet_context on initSwen Schillig1-8/+2
Zero the libnet_context on initialization preventing an uninitalized cli_credentials struct. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Feb 1 00:33:34 CET 2018 on sn-devel-144
2018-01-25Fix wrong condition for error string assignmentSwen Schillig1-2/+2
Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Thu Jan 25 17:19:12 CET 2018 on sn-devel-144
2018-01-25libnet: Use talloc_zero instead of ZERO_STRUCTPVolker Lendecke1-3/+3
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
2018-01-09libnet: Add NULL checks to py_net_finddcVolker Lendecke1-0/+10
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-11-24schema: Make writing indices flag an enum for a new stateGarming Sam1-2/+2
In schema_load_init, we find that the writing of indices is not locked in any way. This leads to race conditions. To resolve this, we need to have a new state (SCHEMA_COMPARE) which can report to the caller that we need to open a transaction to write the indices. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-09-07debug: Add new debug class "drs_repl" for DRS replication processingAndrew Bartlett1-0/+3
This is used in the client and in the server Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-08-18replmd: Don't fail cycle if we get link for deleted object with GET_TGTTim Beale1-0/+4
We are going to end up supporting 2 different server schemes: A. the old/default behaviour of sending all the linked attributes last, at the end of the replication cycle. B. the new/Microsoft way of sending the linked attributes interleaved with the source/target objects. Normally if we're talking to a server using the old scheme-A, we won't ever use the GET_TGT flag. However, there are a couple of cases where it can happen: - A link to a new object was added during the replication cycle. - An object was deleted while the replication was in progress (and the linked attribute got queued before the object was deleted). Talking to an Samba DC running the old scheme will just cause it to start the replication cycle from scratch again, which is fairly harmless. However, there is a chance that the same thing can happen again, in which case the replication cycle will fail (because GET_TGT was already set). Even if we're using the new scheme (B), we could still potentially hit this case, as we can still queue up linked attributes between requests (group memberships can be larger than what can fit into a single replication chunk). If GET_TGT is set in the GetNcChanges request, then the local copy of the target object should always be up-to-date when we process the linked attribute. So if we still think the target object is deleted/recycled at this point, then it's safe to ignore the linked attribute (because we know our local copy is up-to-date). This logic matches the MS spec logic in ProcessLinkValue(). Not failing the replication cycle may be beneficial if we're trying to do a full-sync of a large database. Otherwise it might be time-consuming and frustrating to repeat the sync unnecessarily. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Garming Sam <garming@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12972
2017-08-18drs: Fail replication transaction instead of dropping linksTim Beale1-0/+1
If the DRS client received a linked attribute that it couldn't resolve the target for, then it would just ignore that link and keep going. That link would then be lost forever (although a full-sync would resolve this). Instead of silently ignoring the link, fail the transaction. This *can* happen on Samba, but it is unusual. The target object and linked-attribute would need to be added while a replication is still in progress. It can also happen fairly easily when talking to a Windows DC. There are two import exceptions to this: 1). Linked attributes that span partitions. We can never guarantee that we will have received the target object, because it may be in a partition we haven't replicated yet. Samba doesn't have a great way of handling this currently, but we shouldn't fail the replication (because that breaks basic join tests). Just skip that linked attribute and hope that a subsequent full-sync will fix it. (I queried Microsoft and they said resolving cross-partition linked attributes is a implementation-specific problem to solve. GET_TGT won't resolve it) 2). When the replication involves a subset of objects, e.g. critical-only. In these cases, we don't increase the highwater-mark, so it is probably not such a dire problem if we don't add the link. In the case of critical-only, we will do a subsequent full sync which will then add the links. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Garming Sam <garming@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12972
2017-07-28libnet: Initialize req_level in become_dc testsTim Beale1-1/+1
The net.api.become.dc tests would always pass the request into libnet_vampire_cb_store_chunk() with req_level=0, which meant that storing the chunk didn't use the correct replica_flags/exop. I noticed this problem when working on client-side support for GET_TGT. My changes relied on the critical-only request flag being passed down into replmd, but because the request flags weren't passed correctly, my changes caused the become_dc tests to fail. 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>
2017-07-14py3: Make sure to specify METH_VARARGS together with METH_KEYWORDSAlexander Bokovoy1-1/+1
A Python 3 bug https://bugs.python.org/issue15657 explains that one should always use METH_VARARGS|METH_KEYWORDS when defining a function rather than a lonely METH_KEYWORDS. We had only one definition like this in Samba and it was the one that affects FreeIPA when running in Python 3 mode. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12905 Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-05-25libnet join: Fix error handling on provision_store_self_join failureGary Lockyer1-1/+8
This avoids leaving the error string NULL. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-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): Thu May 25 06:28:02 CEST 2017 on sn-devel-144
2017-05-25pynet: Add a hook to decrypt one attributeAndrew Bartlett1-0/+74
This will help with testing GetNCChanges and supplementalCredentials against Windows in Python Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-05-23dsdb: Do not write the @INDEXLIST or @ATTRIBUTES records during schema refreshAndrew Bartlett1-1/+1
Instead, write it once in the module init, if required, and after a modify to the schema partition is detected Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-03-29python net: add username, oldpassword and domain to change_passwordGary Lockyer1-7/+19
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
2017-03-10waf: disable-python - don't build samba-netIan Stakenvicius1-1/+2
samba-net requires PROVISION, which is disabled when python isn't available. Signed-off-by: Ian Stakenvicius <axs@gentoo.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-03-10python: Port the samba.net module to Python 3Petr Viktorin2-17/+27
Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-02-25py_net: make use of pytalloc_GenericObject_steal()Stefan Metzmacher1-3/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12601 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-02-23samba-tool drs replicate: Add --single-objectAndrew Bartlett1-3/+3
This may help when an object has been incorrectly locally removed from the NC or there is an urgent need to replicate a specific object (say when full replication is inoperable). Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-02-21s4:libnet: make use of generate_random_machine_password()Stefan Metzmacher1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12262 Signed-off-by: Stefan Metzmacher <metze@samba.org>
2017-02-08s4:libnet: s/highestCommitedUSN/highestCommittedUSNStefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-11-04python-libnet: Use new NTSTATUSError, WERRORError and DsExtendedError exceptionsAndrew Bartlett1-14/+102
This will allow callers to catch specific errors rather than RuntimeException As this slightly changes the exception, the timecmd test must be updated. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12398
2016-11-04dsdb: Catch errors in extended operations (like allocating a RID Set)Andrew Bartlett1-2/+19
There are cases where allocating a RID Set can reasonably fail. Catch those nicely. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12398
2016-11-04dsdb: Rework DSDB code to use WERRORAndrew Bartlett4-70/+89
The WERROR codes are more descriptive for DSDB issues, and almost all the code was converting from WERROR to NTSTATUS. This will allow us to better catch specific errors like WERR_DS_DRA_MISSING_PARENT Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12398
2016-08-31krb5_wrap: Rename smb_krb5_open_keytab_relative()Andreas Schneider1-4/+4
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-08-11s4:dsdb/repl: set working_schema->resolving_in_progress during schema creationStefan Metzmacher1-0/+5
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12128 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-08-11s4:dsdb/repl: Improve memory handling in replicated schema codeAndrew Bartlett1-1/+1
This attempts to make it clear what memory is short term and what memory is long term BUG: https://bugzilla.samba.org/show_bug.cgi?id=12115 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-07-28valgrind: Avoid a warning about uninitialized memoryGarming Sam1-1/+1
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-06-28libnet: Fix CID 1362934: CHECKED_RETURNVolker Lendecke1-1/+6
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2016-06-06samba-tool domain join: Set drsuapi.DRSUAPI_DRS_GET_ANC during initial replAndrew Bartlett1-4/+7
This is needed so that we get parents before children. We need this to ensure that we always know the correct parent for a new child object, rather than just trusting the DN string Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-06-06repl: Pass in the full partition DN to dsdb_replicated_objects_convert()Andrew Bartlett1-2/+26
When we were processing an EXOP, we would pass in a DN specific to that operation, but this stopped repl_meta_data from finding the parent object Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-04-25s4:libnet: fix 'Syscall param writev(vector[...])' valgrind errorNoel Power1-0/+1
running smbtorture rpc.dfs.netdfs.StdRoot yields the following valgrind trace ==18861== Syscall param writev(vector[...]) points to uninitialised byte(s) ==18861== at 0xFBA2C87: writev (in /lib64/libc-2.19.so) ==18861== by 0x106CB033: writev_handler (async_sock.c:340) ==18861== by 0xF67812A: ??? (in /usr/lib64/libtevent.so.0.9.26) ==18861== by 0xF6765F6: ??? (in /usr/lib64/libtevent.so.0.9.26) ==18861== by 0xF6727FC: _tevent_loop_once (in /usr/lib64/libtevent.so.0.9.26) ==18861== by 0xF673ACE: tevent_req_poll (in /usr/lib64/libtevent.so.0.9.26) ==18861== by 0x5D19325: tevent_req_poll_ntstatus (tevent_ntstatus.c:109) ==18861== by 0x88B2E0D: dcerpc_binding_handle_call (binding_handle.c:556) ==18861== by 0xBC6D0D2: dcerpc_srvsvc_NetShareDel_r (ndr_srvsvc_c.c:4272) ==18861== by 0x9786C0C: libnet_DelShare (libnet_share.c:195) ==18861== by 0x2E0174: test_NetShareDel (dfs.c:103) ==18861== by 0x2E126F: test_cleanup_stdroot (dfs.c:488) ==18861== Address 0x18869b46 is 598 bytes inside a block of size 1,325 alloc'd ==18861== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==18861== by 0xF464A73: _talloc_pooled_object (in /usr/lib64/libtalloc.so.2.1.5) ==18861== by 0xF67366D: _tevent_req_create (in /usr/lib64/libtevent.so.0.9.26) ==18861== by 0xB0D49FF: smb1cli_req_create (smbXcli_base.c:1322) ==18861== by 0xB0E1E6D: smb1cli_trans_send (smb1cli_trans.c:512) ==18861== by 0xB0ED47D: tstream_smbXcli_np_readv_trans_start (tstream_smbXcli_np.c:901) ==18861== by 0xB0EC847: tstream_smbXcli_np_writev_write_next (tstream_smbXcli_np.c:578) ==18861== by 0xB0EC4D7: tstream_smbXcli_np_writev_send (tstream_smbXcli_np.c:505) ==18861== by 0xC259DFA: tstream_writev_send (tsocket.c:695) ==18861== by 0xC25AD64: tstream_writev_queue_trigger (tsocket_helpers.c:513) ==18861== by 0xF673023: tevent_common_loop_immediate (in /usr/lib64/libtevent.so.0.9.26) ==18861== by 0xF677EED: ??? (in /usr/lib64/libtevent.so.0.9.26) ==18861== Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-04-25s4/libnet: fix exporting to keytab by SPNRalph Boehme1-16/+23
Fix a regression introduced by 5c5d586d3ebd40 that broke exporting service principals by their spn with samba-tool exportkeytab --principal=<SPN>. Iterating with samba_kdc_nextkey() only returns UPNs, so this can't work with SPNs. If we want to search for a specific SPN, we have to use samba_kdc_fetch(). Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2016-03-24s4-libnet: Link dckeytab.so correctly when is AD DC enabledAndreas Schneider2-3/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Mar 24 15:12:21 CET 2016 on sn-devel-144
2016-03-23s4-libnet: only build python-dckeytab module for Heimdal in AD DC modeAlexander Bokovoy1-1/+1
Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org> Autobuild-User(master): Uri Simchoni <uri@samba.org> Autobuild-Date(master): Wed Mar 23 23:43:51 CET 2016 on sn-devel-144
2016-03-15build: mark explicit dependencies on pytalloc-utilGarming Sam1-1/+1
All subsystems that include pytalloc.h need to link against pytalloc-util. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11789 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Tue Mar 15 07:08:16 CET 2016 on sn-devel-144
2016-03-10s4-libnet: Implement export_keytab without HDBAndreas Schneider1-33/+159
This is used by 'samba-tool domain exportkeytab'. This loads the HDB Samba backend thus needs access to samdb. To avoid using heimdal specific code here, we could talk to samdb directly and write a keytab file. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2015-10-26repl: Use DSDB_REPL_FLAG_PRIORITISE_INCOMING in samba-tool drs replicate --localAndrew Bartlett1-0/+4
Previously this would only be set when we did server-to-server replication Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26repl: Give an error if we get a secret when not expecting oneAndrew Bartlett1-1/+6
We should never get a secret from a server when we specify DRSUAPI_DRS_SPECIAL_SECRET_PROCESSING This asserts that this is the case. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-10-26samba-tool: Remove vampire subcommand and now unused libnet_Vampire()Andrew Bartlett2-341/+0
This has been deprecated for a long time now Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>