summaryrefslogtreecommitdiffstats
path: root/lib/util
Commit message (Collapse)AuthorAgeFilesLines
* lib: util [ctdb]: Signal handling - change CatchChild() and ↵Jeremy Allison2014-09-302-6/+6
| | | | | | | | | | | 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>
* lib: util: asn1 tests. Check every asn1 return.Jeremy Allison2014-09-261-5/+9
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
* lib/util: Drop unnecessary use of talloc_tos()Volker Lendecke2014-09-201-6/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* lib/util: Return some functions to util_str.cMartin Schwenke2014-09-192-55/+55
| | | | | | | | | | | These were moved in commit 8e704e4107b284bfc1e43f4c698ac0e6c5ae1800 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
* lib/util: Move next_token* functions to util_str.cMartin Schwenke2014-09-192-146/+145
| | | | | | | | | | | | | | | This is part of an attempt to untangle charset from util.c. Most of this was moved from util_str.c in commit 55903e6f9120f1ec58a8554813229975c3028a09. next_token() was moved from charset to util.c in commit 4be643d4ce33d5ce2bf9deacc3f6d0fde90cf626 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>
* lib/util: Move idr_get_new_random() to new source file idtree_random.cMartin Schwenke2014-09-196-63/+176
| | | | | | | | | | | 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>
* debug: Standalone compile without includes.hMartin Schwenke2014-09-192-3/+14
| | | | | | | | | | | | | 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>
* charset: Avoid compiler warnings with --enable-developerMartin Schwenke2014-09-191-2/+2
| | | | | | | | | | | | 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>
* util: Fix indentationMartin Schwenke2014-09-191-1/+1
| | | | | Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib: util: Check *every* asn1 return call and early return.Jeremy Allison2014-09-191-61/+45
| | | | | | | | 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
* lib: util_tdb does not need samba-utilVolker Lendecke2014-09-181-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* lib: Move tdb lock timeout fns to source3Volker Lendecke2014-09-182-96/+0
| | | | | | | | 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>
* lib: Make set_blocking() available independentlyVolker Lendecke2014-09-181-2/+7
| | | | | | | | 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>
* lib: Make samba-debug a private libraryVolker Lendecke2014-09-181-4/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Add daemon_status() to util library.Andreas Schneider2014-09-172-0/+17
| | | | | | | 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>
* lib: Remove unused file_lines_slashcontVolker Lendecke2014-09-172-30/+0
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Move "large_file_support()" to the source4 smb serverVolker Lendecke2014-09-172-22/+0
| | | | | | | 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>
* s3: smbd: Change the function signature of srvstr_push() from returning a ↵Jeremy Allison2014-09-162-3/+6
| | | | | | | | | | | | | | | | | 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>
* lib: Introduce server_id_same_process()Volker Lendecke2014-08-232-5/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove parser code, now replaced with tini parser.Volker Lendecke2014-08-151-508/+2
| | | | | | | | 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
* Add tiniparser - tiny version of iniparser that only implements what Samba uses.Jeremy Allison2014-08-143-1/+441
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* Use tini in preference.Volker Lendecke2014-08-141-0/+28
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Add tini parser.Volker Lendecke2014-08-143-1/+348
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: strings: Simplify strcasecmpVolker Lendecke2014-08-061-35/+13
| | | | | | | | | 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>
* s4: tests: Added local.charset test for Bug 10716 - smbd constantly crashes ↵Jeremy Allison2014-08-061-0/+12
| | | | | | | | when filename contains non-ascii character https://bugzilla.samba.org/show_bug.cgi?id=10716 Signed-off-by: Jeremy Allison <jra@samba.org>
* lib: strings: Fix the behavior of strncasecmp_m_handle() in the face of bad ↵Jeremy Allison2014-08-061-2/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib: strings: Fix the behavior of strcasecmp_m_handle() in the face of bad ↵Jeremy Allison2014-08-061-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib: Remove unused nstrcpyVolker Lendecke2014-08-041-5/+0
| | | | | | | | 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
* lib: Make DEBUG a subsystem of its ownVolker Lendecke2014-08-021-2/+7
| | | | | | | | | | | 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
* lib: Make close_low_fd() independently linkableVolker Lendecke2014-08-016-51/+101
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* debug: Use close_low_fd in reopen_logs_internalVolker Lendecke2014-08-011-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Use close_low_fd in close_low_fdsVolker Lendecke2014-08-011-33/+19
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Add close_low_fdVolker Lendecke2014-08-012-0/+48
| | | | | | | | 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>
* fix unstrcpyVolker Lendecke2014-08-011-1/+1
| | | | | | | | | | | 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
* debug: Avoid dependency on str_list_makeVolker Lendecke2014-07-311-41/+29
| | | | | | | 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>
* debug: Fix blank line endingsVolker Lendecke2014-07-311-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Increase maximum header lengthVolker Lendecke2014-07-311-1/+1
| | | | | | | With function names it can become quite long Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: In dbghdrclass, don't call strlen repeatedlyVolker Lendecke2014-07-311-20/+40
| | | | | | | Also properly protect against header_str overflow Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Fix a typoVolker Lendecke2014-07-311-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Simplify debug_parse_levelsVolker Lendecke2014-07-311-6/+6
| | | | | | | Just some minimal refactoring Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Simplify Debug1() -- no va_argsVolker Lendecke2014-07-311-34/+18
| | | | | | | | | | | All callers just have "%s" as format string now, so we don't need to vasprintf anymore. This could speed up DEBUG a bit, we don't do a separate copy and the printf logic Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Remove an "else"Volker Lendecke2014-07-311-1/+3
| | | | | | | No else necessary, we just did a "goto done:" Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Remove two pointless assignmentsVolker Lendecke2014-07-311-2/+0
| | | | | | | "goto done:" jumps to that exact assignment :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Only call Debug1 once in dbghdrclassVolker Lendecke2014-07-311-6/+9
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Move adding timeval and loglevelVolker Lendecke2014-07-311-12/+11
| | | | | | | | The whole routine incrementally creates the hdr_string, do it for the time string and the debuglevel as well Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: slprintf->snprintfVolker Lendecke2014-07-311-6/+7
| | | | | | | snprintf does not need the -1 in sizeof(buf)-1 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Use timeval_str_buf in dbghdrclassVolker Lendecke2014-07-311-12/+11
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Simplify dbghdrclass with an early returnVolker Lendecke2014-07-311-41/+43
| | | | | | | No code change, visible with "git diff -w" Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* lib: Create time_basic.[ch]Volker Lendecke2014-07-316-66/+130
| | | | | | | | | Make the two functions that debug.c needs a subsystem of their own. The goal is to put debug.c on a diet. Anybody who wants to use it should not be forced to pull in half of Samba :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* lib: Use timeval_str_buf in timeval_stringVolker Lendecke2014-07-311-38/+17
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>