1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00
Commit Graph

889 Commits

Author SHA1 Message Date
Martin Schwenke
c12aa0c444 lib/util: Use charset_compat.h if SAMBA_UTIL_CORE_ONLY
When doing a CTDB standalone build we don't want to use dynconfig,
since this introduces a lot of unwanted complexity.  To avoid this,
either:

* charset needs to be nobbled to avoid loading the case tables, since
  this depends on dynconfig; or

* charset needs to be avoid completely, so some functions need to be
  replaced with their ASCII counterparts.

The 2nd options seems more honest and less error-prone.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Martin Schwenke
1fd4556917 lib/util: Factor out subsystem samba-util-core from samba-util
samba-util depends on Samba-specific code.  Exclude this code from
samba-util-core.  When told to, via SAMBA_UTIL_CORE_ONLY, only build
samba-util-core and dependencies.  When SAMBA_UTIL_CORE_ONLY is not
defined then the behaviour should be unchanged.

Standalone builds of CTDB will be done against samba-util-core to
avoid pulling in Samba-specific code.

An alternative would be to remove the Samba-dependent code from
samba-util.  However, some of it is used by OpenChange.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Martin Schwenke
db15cc5388 lib/util: Clean up includes for util.c
Allows standalone compiles without external includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Martin Schwenke
8dac190ee1 lib/util: Clean up includes for fault.c
Add fault.h.  Allows standalone compiles without external includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Martin Schwenke
d92940819f lib/util: Clean up includes for substitute.c
Add substitute.h.  Allows standalone compiles without external
includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Martin Schwenke
2426130c90 lib/util: Replace an SMB_ASSERT()
Avoid a cyclic dependency.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Martin Schwenke
b69edfed7d lib/util: Clean up includes for signal.c
Add signal.h.  Allows standalone compiles without external includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:21 +02:00
Martin Schwenke
fd9f0c27e7 lib/util: Clean up includes for time.[ch]
Allows standalone compile without external includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:20 +02:00
Martin Schwenke
1f0e5cb38c lib/util: Clean up includes for data_blob.[ch]
Allows standalone compile without external includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:20 +02:00
Martin Schwenke
2d7dfe3d68 lib/util: Clean up includes for xfile.[ch]
The include files added to xfile.h are already included
unconditionally elsewhere (replace.h, samba_util.h, ...) so Samba
can't be built without them.

To minimise dependencies, only include specific util headers instead
of samba_util.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:20 +02:00
Martin Schwenke
3d6675fd1e lib/util: Clean up includes for blocking.c
Add blocking.h.  Allows standalone compile without external
includes.h.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-10-04 00:11:20 +02:00
Jeremy Allison
fc8e1056fe lib: util [ctdb]: Signal handling - change CatchChild() and CatchChildLeaveStatus() to return the previous handler.
Bug #10831 - SIGCLD Signal handler not correctly reinstalled on old library code use - smbrun etc.

https://bugzilla.samba.org/show_bug.cgi?id=10831

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-09-30 20:40:16 +02:00
Jeremy Allison
612b74296c lib: util: asn1 tests. Check every asn1 return.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-26 00:51:16 +02:00
Volker Lendecke
0f9669eb9f lib/util: Drop unnecessary use of talloc_tos()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-09-20 06:03:13 +02:00
Martin Schwenke
6d450b3b48 lib/util: Return some functions to util_str.c
These were moved in commit 8e704e4107
when util_str.c was not shared.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Sep 19 20:34:05 CEST 2014 on sn-devel-104
2014-09-19 20:34:05 +02:00
Martin Schwenke
f3d50e5ff5 lib/util: Move next_token* functions to util_str.c
This is part of an attempt to untangle charset from util.c.

Most of this was moved from util_str.c in commit
55903e6f91.  next_token() was moved from
charset to util.c in commit 4be643d4ce
so that it would be alongside next_token_talloc().

Now that util_str.c is in shared lib/util it is no longer necessary to
have these in util.c.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-19 18:11:11 +02:00
Martin Schwenke
1bf36f177b lib/util: Move idr_get_new_random() to new source file idtree_random.c
This function depends on genrand.c, which depends on lib/crypto.  This
way the other IDR tree code can be used without lib/crypto.

While doing this, create idtree.h and idtree_random.h and clean up the
includes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-19 18:11:11 +02:00
Martin Schwenke
e0a5c43bd0 debug: Standalone compile without includes.h
Compiling utilities with includes.h is confusing because includes.h
could come from source3, source4 or ctdb.  Utilities should be
independent of such things.

Add a minimal set of fined-grained includes that attempts to avoid the
catch-all samba_util.h.  A comment indicates what is used from
samba_util.h so that future clean-ups are easier.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-19 18:11:11 +02:00
Martin Schwenke
d55cdc367d charset: Avoid compiler warnings with --enable-developer
These:

  [ 44/309] Compiling ../lib/util/charset/util_unistr_w.c
  ../../lib/util/charset/util_unistr_w.c: In function ‘strlower_w’:
  ../../lib/util/charset/util_unistr_w.c:182:127: warning: right-hand operand of comma expression has no effect [-Wunused-value]
      COPY_UCS2_CHAR(s,&v);

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-19 18:11:11 +02:00
Martin Schwenke
427afe2655 util: Fix indentation
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-09-19 18:11:11 +02:00
Jeremy Allison
b9d3fd4cc5 lib: util: Check *every* asn1 return call and early return.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Sep 19 01:29:00 CEST 2014 on sn-devel-104
2014-09-19 01:29:00 +02:00
Volker Lendecke
041eb5c5bc lib: util_tdb does not need samba-util
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-09-18 20:36:11 +02:00
Volker Lendecke
5454f71fc0 lib: Move tdb lock timeout fns to source3
This is not the nicest code and needs to be replaced. Remove it from
common.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-09-18 20:36:11 +02:00
Volker Lendecke
32d190a020 lib: Make set_blocking() available independently
async_connect_send() needs this, and I don't want to pull in samba-util
just for this

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-18 20:36:11 +02:00
Volker Lendecke
25df58a853 lib: Make samba-debug a private library
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-18 20:36:11 +02:00
Andreas Schneider
9f5f5fa8eb lib: Add daemon_status() to util library.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10816

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
2014-09-17 10:51:36 +02:00
Volker Lendecke
4be583493a lib: Remove unused file_lines_slashcont
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-17 00:31:21 +02:00
Volker Lendecke
e8996582c6 lib: Move "large_file_support()" to the source4 smb server
That's the only place where it's used, make it static there.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-17 00:31:21 +02:00
Jeremy Allison
0519088c53 s3: smbd: Change the function signature of srvstr_push() from returning a length to returning an NTSTATUS with a length param.
srvstr_push_fn() now returns an NTSTATUS reporting any
string conversion failure.

We need to get serious about returning character set conversion errors
inside smbd.

Bug 10775 - smbd crashes when accessing garbage filenames

https://bugzilla.samba.org/show_bug.cgi?id=10775

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2014-09-16 01:56:54 +02:00
Volker Lendecke
46e912210d lib: Introduce server_id_same_process()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-23 00:24:18 +02:00
Volker Lendecke
097c5b15e2 lib: Remove parser code, now replaced with tini parser.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Aug 15 20:34:56 CEST 2014 on sn-devel-104
2014-08-15 20:34:56 +02:00
Jeremy Allison
51bea0b767 Add tiniparser - tiny version of iniparser that only implements what Samba uses.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2014-08-14 21:27:13 +02:00
Volker Lendecke
ed66a984bf Use tini in preference.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-14 21:27:13 +02:00
Volker Lendecke
63acc8e810 Add tini parser.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-14 21:27:13 +02:00
Volker Lendecke
64271c493d lib: strings: Simplify strcasecmp
This makes us fallback to strcasecmp early if any INVALID_CODEPOINT
appears. Without this patch we just continue to compare if both strings
happen to have an INVALID_CODEPOINT in the same spot.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-06 01:05:14 +02:00
Jeremy Allison
ca1617121a s4: tests: Added local.charset test for Bug 10716 - smbd constantly crashes when filename contains non-ascii character
https://bugzilla.samba.org/show_bug.cgi?id=10716

Signed-off-by: Jeremy Allison <jra@samba.org>
2014-08-06 01:05:14 +02:00
Jeremy Allison
dfe8dd87e1 lib: strings: Fix the behavior of strncasecmp_m_handle() in the face of bad conversions.
When either string has a bad conversion, we fall back to
doing raw ascii byte comparisons using strcasecmp(). This
is wrong - we should fall back to strncasecmp.

The problem is we've already stepped past the character
that failed the conversion, so we're not re-testing those
characters for comparison. This can have the effect of
causing strncasecmp_m_handle() to report that two strings
are identical when they are not, if the failed conversion
takes place at the end of the string.

The correct behavior is to step back to the point of
the string(s) that failed the conversion, and continue
the test from there.

This is a litle trickier than the previous fix, as
it requires converting the incoming n variable from
remaining characters to compare to remaining bytes to
compare.

As bytes are always the smallest character size
(1 byte) then it's safe to convert the remaining
characters to check by decrementing the source string
by the last character length (in bytes) and incrementing
the remaining bytes to scan by the same value, then
calling strncasecmp() with the stepped back strings
remaining.

Signed-off-by: Jeremy Allison <jra@samba.org>
2014-08-06 01:05:14 +02:00
Jeremy Allison
9380478a0b lib: strings: Fix the behavior of strcasecmp_m_handle() in the face of bad conversions.
When either string has a bad conversion, we fall back to
doing raw ascii byte comparisons using strcasecmp().

The problem is we've already stepped past the character
that failed the conversion, so we're not re-testing those
characters for comparison. This can have the effect of
causing strcasecmp_m_handle() to report that two strings
are identical when they are not, if the failed conversion
takes place at the end of the string.

The correct behavior is to step back to the point of
the string(s) that failed the conversion, and continue
the test from there.

Found by <lev@zadarastorage.com> when investigating bug
10716 - smbd constantly crashes when filename contains non-ascii character.

Given the normal character set of utf-8, and an on
disk filename of ISO-8859-1 of file-é on disk hex
value: 66 69 6c 65 2d e9, an incoming open given the
correct utf8 name of file-é will collide when it
should not.

Fixes:

Bug 10716 - smbd constantly crashes when filename contains non-ascii character

https://bugzilla.samba.org/show_bug.cgi?id=10716

Signed-off-by: Jeremy Allison <jra@samba.org>
2014-08-06 01:05:14 +02:00
Volker Lendecke
fb9d8c4026 lib: Remove unused nstrcpy
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Aug  4 09:58:16 CEST 2014 on sn-devel-104
2014-08-04 09:58:16 +02:00
Volker Lendecke
811e0e6f99 lib: Make DEBUG a subsystem of its own
In the future this might become a library, but even with the SUBSYSTEM
it should be clear what debug.c depends upon.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Aug  2 00:36:50 CEST 2014 on sn-devel-104
2014-08-02 00:36:50 +02:00
Volker Lendecke
a7c243b62c lib: Make close_low_fd() independently linkable
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-01 22:11:46 +02:00
Volker Lendecke
4ac12fb2f7 debug: Use close_low_fd in reopen_logs_internal
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-01 22:11:46 +02:00
Volker Lendecke
b310ea6353 lib: Use close_low_fd in close_low_fds
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-01 22:11:46 +02:00
Volker Lendecke
2dd8b6b25c lib: Add close_low_fd
This factors out the essential code from close_low_fds for one file
descriptor: Redirect a fd to /dev/null

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-01 22:11:46 +02:00
Volker Lendecke
9b24abe2f7 fix unstrcpy
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10735
CVE-2014-3560: unstrcpy macro length is invalid

Autobuild-User(master): Ira Cooper <ira@samba.org>
Autobuild-Date(master): Fri Aug  1 22:10:23 CEST 2014 on sn-devel-104
2014-08-01 22:10:23 +02:00
Volker Lendecke
e249e794ec debug: Avoid dependency on str_list_make
strtok_r just also does the job and is available in libc

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-07-31 18:49:47 +02:00
Volker Lendecke
0e448f8d35 debug: Fix blank line endings
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-07-31 18:49:47 +02:00
Volker Lendecke
8792de7a16 debug: Increase maximum header length
With function names it can become quite long

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-07-31 18:49:47 +02:00
Volker Lendecke
06a0b1c851 debug: In dbghdrclass, don't call strlen repeatedly
Also properly protect against header_str overflow

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-07-31 18:49:47 +02:00
Volker Lendecke
200d94e563 debug: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-07-31 18:49:47 +02:00