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

7056 Commits

Author SHA1 Message Date
Douglas Bagnall
c80606274f ldb ABI bump for pyldb_Ldb_AsLdbContext change
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>

Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Jul 10 05:48:52 UTC 2019 on sn-devel-184
2019-07-10 05:48:52 +00:00
Douglas Bagnall
fdb9a59069 pyldb: ldb.register_module() checks arguments a little bit
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-10 04:32:13 +00:00
Douglas Bagnall
192386ede6 pyldb: remove ldb.open, which was never survivable
There was no way to call ldb.open without evoking signal 11, so it is
unlikely anyone was using it.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-10 04:32:13 +00:00
Douglas Bagnall
1d6b472cdc pyldb: rename pyldb_Dn_AsDn() to pyldb_Dn_AS_DN()
Following the python/C convention for checking vs non-checking
convertors.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-10 04:32:13 +00:00
Douglas Bagnall
339f8bbdda pyldb: check for errors in PyLdb_GetPyType()
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-10 04:32:13 +00:00
Douglas Bagnall
e075f52a75 pyldb: fork pyldb_Ldb_AsLdbContext macro to reflect unsafeness
In the Python/C API, conversion functions which check the types of their arguments
have names like:

double PyFloat_AsDouble(PyObject *pyfloat);

while conversion macros that don't check have names like:

PyFloat_AS_DOUBLE(pyfloat)

The pyldb_Ldb_AsLdbContext() macro looks like one of the checking functions
but it actually isn't. This has fooled us more than once. Here we fork
the macro into two -- one which performs checks and keeps the camel
case, and one with a shouty name that keeps the check-free behaviour.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-10 04:32:13 +00:00
Douglas Bagnall
f5e0339a0d pyldb: add pyldb_check_type()
This will be used by pyldb_Ldb_AsLdbContext().

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-10 04:32:13 +00:00
Douglas Bagnall
19a13cbe06 ldb: do not allow adding a DN as a base to itself
If you try to add a dn to itself, it expands as it goes. The resulting
loop cannot end well.

It looks like this in Python:

    dn = ldb.Dn(ldb.Ldb(), 'CN=y,DC=x')
    dn.add_base(dn)

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-10 04:32:13 +00:00
Andreas Schneider
31a943fa08 lib:crypto: Add GNUTLS_FIPS140_SET_(LAX|STRICT)_MODE to helpers
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-07-09 12:16:11 +00:00
Andreas Schneider
a31a40b41a lib:crypto: Fix path to header file in gnutls_helpers.h
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-07-09 12:16:11 +00:00
Ralph Boehme
bf5d5fd17c docs/xml: change default for "mangled names" to "illegal"
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2019-07-08 16:22:38 +00:00
Stefan Metzmacher
3264b1f317 docs-xml: change "client min protocol" to SMB2_02
It's time to disable SMB1 by default...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-07-08 16:22:38 +00:00
Stefan Metzmacher
840b8501b4 docs-xml: change "server min protocol" to SMB2_02
SMB2_02 was available with Windows Vista.
It's time to turn SMB1 off by default.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2019-07-08 16:22:37 +00:00
Noel Power
17ce70d6d9 lib/param: clang: Fix Value stored is never read
Fixes:
lib/param/loadparm.c:2164:2: warning: Value stored to 'bRetval' is never read <--[clang]
        bRetval = false;
        ^         ~~~~~
1 warning generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-08 09:30:09 +00:00
Noel Power
d759f4aa4b lib/util: clang: Fix 'Null pointer passed as an argument'
Fixes lib/util/iov_buf.c:50:4: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang]
                        memcpy(p, iov[i].iov_base, thislen);
                        ^
1 warning generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-08 09:30:09 +00:00
Björn Jacke
d6b8cbc8f7 param: change default of "allocation roundup size" to 0
Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-07-07 21:32:25 +00:00
Martin Schwenke
9d90ac352d util: Fix off-by-one error in message about overflow
len includes space for the NUL character, so the calculation needs to
take the NUL character into account.

While touching this, drop unnecessary casts by updating format string
and update to modern debug macro.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Jul  5 02:24:52 UTC 2019 on sn-devel-184
2019-07-05 02:24:52 +00:00
Martin Schwenke
5f7d82a889 util: Avoid localised underflow
Avoid parenthesising an unsigned subtraction that can be negative and,
therefore, underflow.  There is no need for the parentheses and
removing them results in an expression that is evaluated left-to-right
and can not underflow.

It isn't clear that the underflow matters.  lp <= ls, so if (li - lp)
underflows then ls + (li - lp) will always overflow.  This should
produce the correct answer.  However, depending on this seems wrong.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-05 01:05:21 +00:00
Gary Lockyer
86d480ade2 ldb: Release ldb 2.0.5
* add ldb_options_get
  add a function to get the options passed in ldb connect.

* add "batch_mode" option.
  This options stops sub transactions being started for key value
  operations.  It is intended to improve the performance in batch
  operations.  As it bypasses the protections on operations if an
  operation fails, the entire transaction will be aborted by a commit.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04 10:02:23 +00:00
Gary Lockyer
6226ab3b61 ldb: Rework index_transaction_cache_size to allow caller to specify a larger size
The previous code would override the caller with the DB size
estimate rather than allowing the caller to force the bigger size.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04 10:02:23 +00:00
Gary Lockyer
f87472c9e3 ldb ldb_key_value: test ldb batch
Test the the ldb "batch_mode" option sets batch mode operation.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04 10:02:23 +00:00
Gary Lockyer
652258768a ldb key_value: Add batch_mode option
When performing a join the overhead of the sub transactions protecting
key value operations becomes significant.  This commit adds a new
"batch_mode" option that disables the sub transactions around key value
operations.

The operation level index cache is also disabled, which means the
overall transaction level index cache can become inconsistent if an
operation fails. To protect against this and other possible on disk
inconsistencies, if any operation fails during a batch_mode
transaction the commit will fail and transaction will be rolled back.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04 10:02:23 +00:00
Gary Lockyer
32f2e390e4 ldb: Add new internal helper function ldb_options_get()
This is needed for modules to access the ldb->options array, as this in in ldb_private.h

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04 10:02:23 +00:00
Andrew Bartlett
f583245706 ldb: Fix dependency on ldb_key_value_sub_txn_{mdb_}test
ldb_tdb can be a module, but the test is actually looking for ltdb_err_map() in
ldb_tdb_err_map.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-07-04 10:02:23 +00:00
Andrew Bartlett
e513bab961 ldb: Try to explain the confusing overload of the LDB_FLG_MOD_* enumeration and other flags
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Jul  4 03:51:58 UTC 2019 on sn-devel-184
2019-07-04 03:51:58 +00:00
Andrew Bartlett
bc48b4b158 ldb: Add tests for Ldb.write_ldif() including the FLG_SHOW_BINARY and FLAG_FORCE_NO_BASE64_LDIF
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-07-04 02:07:21 +00:00
Andrew Bartlett
f8fbd9cfe1 pyldb: Apply flags specified by ldb.Ldb(flags=...) even if the URL is not set
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-07-04 02:07:21 +00:00
Björn Baumbach
894ddafc25 ldb/ldb_ldif: add LDB_FLAG_FORCE_NO_BASE64_LDIF flag
Flag is used to enforce binary encoded attribute values per attribute.

Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04 02:07:20 +00:00
Björn Baumbach
89d95fb75c ldb/ldb_ldif: add copy_raw_bytes helper variable to ldb_ldif_write_trace()
Signed-off-by: Björn Baumbach <bb@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-04 02:07:20 +00:00
Volker Lendecke
fa2d5b3daa lib: Fix return of server_id_db_prune_name()
The tdb routines return 0/-1 and return the specific error via
tdb_error(). server_id_db_prune_name() is expected to return an errno,
not 0/-1.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Wed Jul  3 10:51:32 UTC 2019 on sn-devel-184
2019-07-03 10:51:32 +00:00
Volker Lendecke
f4430086fa tdb: Adapt _tdb_transaction_cancel() to README.Coding
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2019-07-03 08:55:23 +00:00
Volker Lendecke
4ef5a42ca2 tdb: Adapt tdb_rescue() to README.Coding
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
2019-07-03 08:55:23 +00:00
Noel Power
c3bad08e2b lib/krb5_wrap: Fix leaking using mkstemp
commit: 8b92539997 introduced a leak
by replacing mktemp with mkstemp (mkstemp returns an open fd)

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-07-03 08:55:23 +00:00
Gary Lockyer
bbc2000079 lib ldb ldb_mdb: Pass the lmdb map size as an ldb option
Allow the lmdb map size to be specified in the ldb option
"lmdb_env_size".

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02 02:23:09 +00:00
Gary Lockyer
e46d5bb669 ldb: Release ldb 2.0.4
* copy the ldb_options passed to ldb_connect onto the ldb_context,
  making them more generally available.

* fix index buffering.
  As a performance enhancement the indexes are cached in memory during a
  transaction, and written to disk as part of the prepare commit. The
  indexes could become corrupt in the event of a failed operation.

* fix read beyond buffer
  Calling the "ldb_parse_tree" function with a filter consisting of
  exactly a single space (" ") would trigger a read beyond the input
  buffer.
  BUG: https://bugzilla.samba.org/show_bug.cgi?id=13900

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02 02:23:09 +00:00
Gary Lockyer
3b52ca59a2 lib ldb: save a copy of the options on the context
Copy the options supplied to to ldb_connect, and place them on the
ldb_context. This allows backend options i.e. lmbd map size to be passed
cleanly from the callers.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02 02:23:09 +00:00
Gary Lockyer
a77fda0cd4 lib tdb: memcmp ubsan warning
Fix the ubsan warning

lib/tdb/common/tdb.c:184:9: runtime error: null pointer passed as
argument 2, which is declared to never be null"

memcmp call now guarded by a length check.

memcmp returns zero when called with a zero length parameter.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Mon Jul  1 14:50:54 UTC 2019 on sn-devel-184
2019-07-01 14:50:53 +00:00
Noel Power
2b7236ffe1 lib/krb5_wrap: clang: Fix warning: Null pointer passed as an argument
Fixes:

lib/krb5_wrap/krb5_samba.c:3241:3: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang]
                memcpy(gss_cksum + 28, in_data->data, orig_length);
                ^

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-01 13:34:11 +00:00
Noel Power
8b92539997 lib/krb5_wrap: clang: Fix warning: Call to function 'mktemp' is insecure
Fixes:

lib/krb5_wrap/krb5_samba.c:2012:2: warning: Call to function 'mktemp' is insecure as it always creates or uses insecure temporary file.  Use 'mkstemp' instead <--[clang]
        mktemp(tmp_name);
        ^~~~~~

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-01 13:34:11 +00:00
Noel Power
7bddd6aefe lib/util: clang: Fix warning: Value stored to 'ret' is never read warning
Fixes:

lib/util/server_id_db.c:181:3: warning: Value stored to 'ret' is never read <--[clang]
                ret = tdb_store(tdb, key, talloc_tdb_data(ids), TDB_MODIFY);
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-01 13:34:11 +00:00
Noel Power
3b43daaccb lib/ldb/common: clang: Fix Value stored to 'ret' is never read warning
Fixes:

lib/ldb/common/ldb.c:1091:3: warning: Value stored to 'ret' is never read <--[clang]
                ret = 0;
                ^     ~
1 warning generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-01 13:34:11 +00:00
Noel Power
9e78f7b53d lib/tdb/common: Fix Array access results in a null pointer dereference
Fixes;

lib/tdb/common/transaction.c:613:7: warning: Array access (via field 'blocks') results in a null pointer dereference <--[clang]
                if (tdb->transaction->blocks[i] != NULL) {
                    ^
1 warning generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-01 13:34:10 +00:00
Noel Power
848290d37f lib/tdb/common: Fix warning: Null pointer passed as argument to param
Fixes:

lib/tdb/common/rescue.c:299:2: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang]
        qsort(found.arr, found.num, sizeof(found.arr[0]), cmp_key);
        ^     ~~~~~~~~~

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-01 13:34:10 +00:00
Noel Power
dcaaf9ff7a lib/util: Fix Value stored to 'ret' is never read warning
Fixes:

lib/util/tfork.c:260:3: warning: Value stored to 'ret' is never read <--[clang]

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-01 13:34:10 +00:00
Martin Schwenke
043334f2eb util: Fix signed/unsigned comparisons by casting
One case needs a variable declared, so it can be compared to -1 and
then cast to size_t for comparison.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jul  1 08:00:29 UTC 2019 on sn-devel-184
2019-07-01 08:00:29 +00:00
Martin Schwenke
115353a001 util: Fix signed/unsigned comparisons by declaring as size_t
I may be missing something subtle but I can't see a reason for
declaring these as ssize_t.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-07-01 06:44:13 +00:00
Martin Schwenke
abea597b7f util: Fix signed/unsigned comparisons by declaring as size_t
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andreas Schneider <asn@samba.org>
2019-07-01 06:44:13 +00:00
Swen Schillig
d5383297f0 tests-util: Adding test to verify "allow no conversion" flag
The internal string conversion routines smb_strtoul(l) return
an error if the provided string could not be converted to an integer.
This can be the case if the string is empty or if it starts with non-numeric
characters which cannot be converted.
The standard C library, however, does allow this and simply returns 0 as the
converted value.
If this behaviour is wanted, it can be enabled by using
the "SMB_STR_ALLOW_NO_CONVERSION" flag.

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Sun Jun 30 12:47:24 UTC 2019 on sn-devel-184
2019-06-30 12:47:24 +00:00
Swen Schillig
dac981a388 tests-util: Adding test to verify "full-string-conversion" flag
The standard string to integer conversion routines stop at the first
character which cannot be converted to a number.
However, if such a character is found, it is not considered an error.
With the flag "SMB_STR_FULL_STR_CONV" enabled, an error will be returned
if the string could not be converted entirely.

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-06-30 11:32:19 +00:00
Swen Schillig
ed533debc4 tests-util: Adding test to verify "allow-negative" flag
The standard string to integer conversion routines allow strings
with a leading "-" to indicate a negative number.
However, the returned value is always an unsigned value representing
the bit-pattern of this negative value.
Typically, this behaviour is NOT wanted and therefore the standard
behavior of the internal smb_strtoul(l) return an erros in such situations.
It can be enabled though by using the flag SMB_STR_ALLOW_NEGATIVE.
This test verifies the correct processing.

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
2019-06-30 11:32:18 +00:00