1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

511 Commits

Author SHA1 Message Date
Douglas Bagnall
fe9b12b274 pidl/ndr/python: avoid memory errors in getsetters
This:

   $ python3 -c'from samba.dcerpc import lsa; x = lsa.EnumAccounts(); x.in_handle'

should not raise a MemoryError, which is very unfriendly given that
'x.in_handle' is just named, not called, as far as the user is
concerned. Returning None is the proper thing.

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): Tue Aug  6 18:17:11 UTC 2019 on sn-devel-184
2019-08-06 18:17:11 +00:00
Andrew Bartlett
5df815cfd2 pidl: Remove the need to always specify --client with --python
This allows us to avoid generating client code for NDR-only protocols that do
not go over DCE/RPC

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-06-26 04:12:33 +00:00
Andrew Bartlett
34f9a089d8 py3: Remove PyStr_FromString() compatability macro
We no longer need Samba to be py2/py3 compatible so we choose to return to the standard
function names.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2019-06-24 17:24:27 +00:00
Gary Lockyer
5d67e87d1c pidl: Allow ndrdump to print public structures
Generate code to allow ndrdump to operate on public structures.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
2019-06-06 03:30:18 +00:00
Noel Power
3326bba419 pidl: Call PY_DISCARD_FUNC_SIG in generated code to avoid ugly warning
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-05-16 17:55:16 +00:00
Andrew Bartlett
4229c27853 pidl: Call PyLong_FromUnsignedLongLong directly rather than via inline helper
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-05-06 05:46:11 +00:00
Andrew Bartlett
819ee849cb pidl: Call PyLong_FromLongLong() directly rather than via inline helper
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-05-06 05:46:11 +00:00
Andrew Bartlett
b0714c70ea pidl: Always call PyLong_FromUnsignedLongLong() in ndr_PyLong_FromUnsignedLongLong()
The C type is "unsigned long long" so use that always, as the Python type is now always the same.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-05-06 05:46:11 +00:00
Andrew Bartlett
26d8d68ca3 pidl: Always call PyLong_FromLongLong() in ndr_PyLong_FromLongLong()
The C type is "long long" so use that always, as the Python type is now always the same.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-05-06 05:46:11 +00:00
Andrew Bartlett
e9874a097d pidl: No longer use Python3 compat define: PyInt_FromLong -> PyLong_FromLong
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-05-06 05:46:11 +00:00
Lutz Justen
e24e344d0d waf: install: Remove installation of PIDL and manpages.
It's not used outside of Samba other than wireshark
who have their own vendor fork.

Signed-off-by: Lutz Justen <ljusten@google.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Apr 23 02:08:56 UTC 2019 on sn-devel-144
2019-04-23 02:08:56 +00:00
Douglas Bagnall
abf2e7c4a5 pidl/s4/python: call export "export" in py exceptions
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12 00:42:18 +00:00
Douglas Bagnall
f0ecfd384c pidl/Python: initialise a datablob
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Mar  4 22:41:01 UTC 2019 on sn-devel-144
2019-03-04 22:41:01 +00:00
Andreas Schneider
532ce0d20a pidl: Use NDR_ZERO_STRUCT(P) macros
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13778

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-02-14 15:59:26 +01:00
Noel Power
85b7574b91 pidl: Fix Generated ndr python code to DECREF imported modules
Generated code calls Py_ImportModule but in all error returns
and also successful exit the code fails to decrement reference to
loaded modules in MODULE_INIT_FUNC function.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-02-07 13:44:30 +01:00
Stefan Metzmacher
1d7930c8ad pidl/Python: use py_dcerpc_ndr_pointer_wrap/deref if multiple pointer levels are used
This will help the raw_protocol test to explore lsa_GetUserName.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12 03:13:41 +01:00
Stefan Metzmacher
98d5872293 s4:rpc_server: make it possible to specify ncacn_np_secondary_endpoint
Even a connect to \\pipe\lsarpc should return a secondary_address
of '\\pipe\\lsass'. But that will be implemented in a following commit.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12 03:13:41 +01:00
Stefan Metzmacher
e9eb8e6a44 s4:rpc_server: only pass context to op_bind() hooks
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2019-01-12 03:13:39 +01:00
Andreas Schneider
57783d6295 pidl: Fix unsigned integer comparison warning
bin/default/librpc/gen_ndr/py_wkssvc.c:27344:33: warning:
comparison of integer expressions of different signedness: ‘long int’
and ‘long long unsigned int’ [-Wsign-compare] <--[gcc]
    if (test_var < 0 || test_var > uint_max) {
                                 ^

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Dec 13 05:00:20 CET 2018 on sn-devel-144
2018-12-13 05:00:20 +01:00
Andreas Schneider
5508c19c5c pidl: Fix function for py_<name>_ndr_print_(in|out)
The function takes two PyObject arguments, See:

https://docs.python.org/3/c-api/structures.html#c.PyCFunction

and

https://docs.python.org/2/c-api/structures.html#c.PyCFunction

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-13 01:49:30 +01:00
Andreas Schneider
676a8fdefc pidl: Use C99 initializers for last element in ndr_interface_call(_pipes)
librpc/gen_ndr/ndr_witness.c:1421:2: warning: missing initializer for
field ‘in_pipes’ of ‘const struct ndr_interface_call’
[-Wmissing-field-initializers] <--[gcc]
  { NULL, 0, NULL, NULL, NULL }
  ^

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-13 01:49:30 +01:00
Noel Power
bb9e945e4a PY3: fix string.rsplit usage (doens't exist in PY3)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-16 06:16:19 +02:00
Noel Power
693834f731 PY3: fix iteritems usage, not supported in python3
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-16 06:16:19 +02:00
Alexander Bokovoy
7f6ce8f834 pidl/wscript: update to handle waf 2.0.4
Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-05 06:37:23 +02:00
Thomas Nagy
8077f462c9 build:wafsamba: Build on waf 1.9
Signed-off-by: Thomas Nagy <tnagy@waf.io>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-05 06:37:21 +02:00
Alexander Bokovoy
99d6237a63 pidl/tests: fix ndr_push_init_ctx() usage
The code in libndr got rid of the second argument quite some time ago
(2010): f9ca9e46ad

However, pidl tests did include a code that passed two arguments.
Recently GCC started to fail to compile such code.

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Aug 30 04:48:00 CEST 2018 on sn-devel-144
2018-08-30 04:48:00 +02:00
Mathieu Parent
d4bbff5ce5 Fix pidl manpage sections
.TH header should match file name (i.e 3pm and not 3 for Parse::Pidl::NDR).

Signed-off-by: Mathieu Parent <math.parent@gmail.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2018-05-12 02:09:28 +02:00
Jeremy Allison
fe2ac3e304 s4: COM: Remove talloc_autofree_context() from (unused) COM code.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12932

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-07-26 21:35:21 +02:00
Günther Deschner
a44bce6dfa libndr/compression: pass down compressed length in ndr_pull_compression_start
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-07-19 21:22:13 +02:00
Stefan Metzmacher
81bbfb0105 pidl:NDR/Parser: add missing {start,end}_flags() to ParseElementPrint()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2017-06-27 16:57:43 +02:00
Stefan Metzmacher
823bc4c07a pidl:NDR/Parser: initialize [skip] values in ndr_pull_*
It's too dangerous to leave values uninitialzed!
[skip_noinit] can be used if required.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2017-06-26 08:47:14 +02:00
Stefan Metzmacher
b922472fd6 pidl:NDR/Parser: add "skip_noinit" element
In future "skip" will be changed to initialize the element
with ZERO_STRUCT() on ndr_pull_*.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2017-06-26 08:47:14 +02:00
Stefan Metzmacher
3bc6b55385 pidl:NDR/Parser: fix "skip" for pointers
We should handle the "skip" at the element level before
we traverse trough the element levels.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2017-06-26 08:47:14 +02:00
Volker Lendecke
67040cf612 pidl: Fix array range checks in python output
Without this, we generated code like

if (ndr_table_dnsserver.num_calls < 0) {
        PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_DnssrvOperation_ndr_pack");
        return NULL;
}
call = &ndr_table_dnsserver.calls[0];

This does not really make sense, and Coverity found comparing the unsigned
num_calls against <0 a bit pointless.

Should fix 138 Coverity findings and make the code a bit more correct.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2017-06-20 18:50:06 +02:00
Petr Viktorin
40e409bf9e python3: Use "y#" instead of "s#" for binary data in PyArg_ParseTuple
The "s#" format code for PyArg_ParseTupleAndKeywords and Py_BuildValue
converts a char* and size to/from Python str (with utf-8 encoding under
Python 3).
In some cases, we want bytes (str on Python 2, bytes on 3) instead. The
code for this is "y#" in Python 3, but that is not available in 2.

Introduce a PYARG_BYTES_LEN macro that expands to "s#" or "y#", and use
that in:
- credentials.get_ntlm_response (for input and output)
- ndr_unpack argument in PIDL generated code

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-05-19 22:20:15 +02:00
Jeremy Allison
9703464b94 pidl: Fix Coverity warnings from duplicate NULL checks.
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Jeremy Allison <jra@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): Sat May  6 16:03:17 CEST 2017 on sn-devel-144
2017-05-06 16:03:17 +02:00
Jeremy Allison
306783d6f5 lib: modules: Change XXX_init interface from XXX_init(void) to XXX_init(TALLOC_CTX *)
Not currently used - no logic changes inside.

This will make it possible to pass down a long-lived talloc
context from the loading function for modules to use instead
of having them internally all use talloc_autofree_context()
which is a hidden global.

Updated all known module interface numbers, and added a
WHATSNEW.

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Ralph Böhme <slow@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Apr 22 01:17:00 CEST 2017 on sn-devel-144
2017-04-22 01:17:00 +02:00
Lumir Balhar
2de5fa45e0 python: pidl: Port Python interface generator
Port PIDL generator of Python interfaces to generate interfaces in
Python 3 compatible form.

Python 2.7 is now required, so we can use PyCapsule in both versions.

Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Pair-programmed-by: Andrew Bartlett <abartlet@samba.org>
2017-03-10 07:31:11 +01:00
Stefan Metzmacher
2170f55629 pidl:Python: use of pytalloc_GenericObject_reference*() for pyrpc_{ex,im}port_union() wrapping
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>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Sat Feb 25 06:33:33 CET 2017 on sn-devel-144
2017-02-25 06:33:33 +01:00
Stefan Metzmacher
1ee0c0f828 pidl:Python: replace pytalloc_CObject_FromTallocPtr() with pytalloc_GenericObject_reference_ex()
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-25 02:39:11 +01:00
Stefan Metzmacher
d62eb3cc9f pidl:Python: make sure print HASH references for STRUCT types
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-25 02:39:11 +01:00
Günther Deschner
d30b008a64 pidl: use ndr_push_charset_to_null() when [to_null] keyword is used in IDL
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-01-24 10:53:17 +01:00
Andrew Bartlett
ffb8b50e3c s4-rpc_server: Allow each interface to declare if it uses handles
This will allow the NETLOGON server in the AD DC to declare that it does not use
handles, and so allow some more flexibility with association groups

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-12-20 01:11:23 +01:00
Andrew Bartlett
31d625bcd2 s4-rpc_server: Add back support for lsa over \\pipe\\netlogon optionally
The idea here is that perhaps some real client relies on this (and not just Samba torture
commands), so we need a way to support it for the 4.6 release.

If no such client emerges, it can be deprecated and removed in the normal way.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2016-12-15 08:21:12 +01:00
Andrew Bartlett
50dff7e094 pidl: Make dcesrv\_$name\_interface "static const"
This moves it out of the global namespace

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Dec  8 13:25:57 CET 2016 on sn-devel-144
2016-12-08 13:25:57 +01:00
Andrew Bartlett
c6c1463852 pidl: Make static struct api_struct also const
This moves the table to read-only memory

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-12-01 05:54:22 +01:00
Andrew Bartlett
d368ee2298 pidl: Change *_get_pipe_fns() to return const struct api_struct *
This will allow the table to be made static const in the next commit

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-12-01 05:54:22 +01:00
Andrew Bartlett
778fc58eb2 pidl: Use a static const initialised struct in dcerpc_server_$name_init(void)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-12-01 05:54:22 +01:00
Alexis La Goutte
3c9d703d45 Fix typo
Fix (minor) typo found in wireshark with lintian tools
https://code.wireshark.org/review/#/c/18485/

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-12-01 05:54:21 +01:00
Stefan Metzmacher
57539c8441 pidl:Python: add PyTypeObject objects for function structs
They provide get/set methods for the in_* and out_* elements
and the magic __ndr_{push,pull,print}_{in,out}__ hooks to enable
the marshalling via ndr_{push,pull,print}_{in,out}().

This provides an easy way to generate and parse the payload of
DCERPC requests and responses, which is very useful for writing
tests.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-10-26 11:20:19 +02:00