summaryrefslogtreecommitdiffstats
path: root/lib/util/debug.c
Commit message (Collapse)AuthorAgeFilesLines
* debug: Set close-on-exec for the main log file FDAndrew Bartlett2015-02-161-0/+3
| | | | | | | | | | | | | | | | This does not change the properties of dup2() of the fd as STDERR, however this is closed before we start smbd or winbindd as child processes. This is needed otherwise the logfile remains open in the child process, and logfile rotation can mean this old log remains on disk indefinatly. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11100 Pair-programmed-with: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Feb 16 11:42:47 CET 2015 on sn-devel-104
* lib: Simplify check_log_sizeVolker Lendecke2014-12-281-5/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib/util: provide a dbgtext_va() function which takes va_listStefan Metzmacher2014-12-171-5/+19
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* lib/util: Add RFC3339 timestamp support to timeval_str_buf()Martin Schwenke2014-10-131-1/+2
| | | | | | | | | | | | Note that this can't be done more simply or portably with strftime(3) since "%z" isn't portable. Signed-off-by: Martin Schwenke <martin@meltin.net> Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Oct 13 12:27:04 CEST 2014 on sn-devel-104
* debug: Standalone compile without includes.hMartin Schwenke2014-09-191-3/+8
| | | | | | | | | | | | | 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>
* lib: Make close_low_fd() independently linkableVolker Lendecke2014-08-011-0/+1
| | | | | 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>
* 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-311-1/+1
| | | | | | | | | 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>
* debug: Statically allocate format_bufrVolker Lendecke2014-07-311-10/+2
| | | | | | | | Everybody needs this, so there's no point talloc'ing it. The side effect is that it removes a dependency on smb_panic() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Fix debug_parse_paramsVolker Lendecke2014-07-311-1/+1
| | | | | | | | | | | | | | The additional check this patch removes potentially drops some debuglevel class settings. While not documented, it is possible to add a debug class like for example "tdb:10" multiple times with multiple values. Later settings overwrite earlier ones, but only if the overall number of settings does not exceed the total number of available debug classes. This patch changes our behaviour, but I can't imagine a situation where someone relies on this check. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Make Debug1 staticVolker Lendecke2014-07-311-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Remove a dependency on charconvVolker Lendecke2014-07-311-1/+1
| | | | | | | | | | | | | | | | util_str has: /* characters below 0x3F are guaranteed to not appear in non-initial position in multi-byte charsets */ if ((c & 0xC0) == 0) { return strrchr(s, c); } '/' is 0x2f, so there's no point in calling strrchr_m and thus pulling in a whole lot of stuff Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Factor out debug_parse_param()Volker Lendecke2014-07-311-8/+31
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Move variables where they are usedVolker Lendecke2014-07-311-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Fix indentation in debug_parse_paramsVolker Lendecke2014-07-311-5/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* debug: Remove thread-related code from debug.cVolker Lendecke2014-07-311-54/+0
| | | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Thu Jul 31 16:20:53 CEST 2014 on sn-devel-104
* lib/util: remove outdated comment from debug.cMichael Adam2014-07-301-4/+0
| | | | | | | These variables do not exist any more. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib/util: add 'ldb' debug classStefan Metzmacher2013-07-091-0/+1
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Björn Jacke <bj@sernet.de>
* debug: Add debugclass for DNS serverKai Blin2013-05-161-0/+1
| | | | | Signed-off-by: Kai Blin <kai@samba.org> Reviewed-By: Amitay Isaacs <amitay@gmail.com>
* s3:smbd: add a scavenger process for disconnected durable handlesGregor Beck2013-04-181-0/+1
| | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Gregor Beck <gbeck@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* Fix bug #9471 - SEGV when using second vfs module.Tsukasa Hamano2012-12-071-1/+1
| | | | | | | | | | | Don't use default_classname_table when we obviously shoud be using classname_table. Reviewed by: Jeremy Allison <jra@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Fri Dec 7 17:51:50 CET 2012 on sn-devel-104
* debug: Do not constantly rename logs when max log size = 0Andrew Bartlett2012-06-111-16/+18
| | | | | | | | | | | | | | | | In Samba4, the max log size parameter is not yet connected, so maxlog is 0 This means that we would, on receipt of a -HUP, have all child processes attempt a rename. Now we have the -HUP mean we reopen the logs unconditionally, and then we see if the log is too large (samba3 mode) or simply proceed assuming that someone else has renamed the logs for us. Andrew Bartlett Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Jun 11 13:34:43 CEST 2012 on sn-devel-104
* Remove an unused variable.Jeremy Allison2012-06-011-3/+1
| | | | | Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Fri Jun 1 03:03:12 CEST 2012 on sn-devel-104
* lib/util: Add a callback facility for debug messagesAndrew Bartlett2012-03-081-13/+44
| | | | | | | This will allow dlz_bind9 to put log messages somewhere useful, which may make it easier to debug. Andrew Bartlett
* change low FDs are handled in SambaAndrew Bartlett2012-03-041-3/+8
| | | | | | | | | | | We now only close fds 0, 1, 2 when we are a forked daemon, and take care not to close a file descriptor that we might need for foreground stdin monitoring. This should fix stdout logging in the lsa and epmapper deamons (ie in make test). Andrew Bartlett
* lib/util/debug: with log level = 10 we should be more verboseStefan Metzmacher2011-11-161-3/+9
| | | | | | | | | | | | | | log level = 10 already impacts performance, so we can turn on more details and print the pid, [e][u|g]id and class information. So it implies "debug pid = yes", "debug uid = yes" and "debug class = yes". This generates a lot more useful log files. metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Wed Nov 16 12:25:02 CET 2011 on sn-devel-104
* debug: log early messages to stdout, and keep it openAndrew Bartlett2011-07-201-0/+6
| | | | | | | | | The --log-stdout option was compromised by the log file descriptors being closed once the file process forked. Andrew Bartlett Signed-off-by: Andrew Tridgell <tridge@samba.org>
* lib/util/ Fix crash bug caused by gfree_debug()Andrew Bartlett2011-05-131-1/+1
| | | | | | | The issue is that we should reset the debug_num_classes to 0 when we un-initialise the debug system. Andrew Bartlett
* debug: default debug to stderr Andrew Tridgell2011-04-041-1/+2
| | | | | | | if setup_logging() hasn't been called then default to sending debug to stderr Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
* debug: Restore the s3-style check in check_log_size()Volker Lendecke2011-03-311-1/+6
| | | | | | | This has caused me considerable grief. Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Thu Mar 31 19:42:38 CEST 2011 on sn-devel-104
* debug: ignore debug_set_logfile() with a blank stringAndrew Tridgell2011-03-291-1/+5
| | | | | | | Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Tue Mar 29 07:03:58 CEST 2011 on sn-devel-104
* debug: fixed a valgrind errorAndrew Tridgell2011-03-041-1/+4
| | | | | | | Thanks to Volker for spotting this one! Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Fri Mar 4 03:09:52 CET 2011 on sn-devel-104
* lib/util: new merged debug systemAndrew Bartlett2011-03-011-0/+1059
| | | | | | | | | | | | This is the s3 debug system, with a number of changes to tidy it up for common use. The debug class system is simplified by the removal of the ISSET table, the system no longer attempts to cope with assignment of DEBUGLEVEL, and the full class table is always available (rather than just DEBUGLEVEL_CLASS[DBCG_ALL]) from startup. It is also no longer confusingly described as a hack, but as the initial table. Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Tue Mar 1 04:32:12 CET 2011 on sn-devel-104
* lib/util move debug.[ch] out of the wayAndrew Bartlett2011-03-011-273/+0
| | | | | | | This will allow a modified version of the s3 debug system to be the new common debug system. Andrew Bartlett
* lib/debug Add clarifying commentsAndrew Bartlett2010-11-241-2/+2
|
* debug: fixed default debug settingsAndrew Tridgell2010-11-041-0/+2
| | | | | | | | | this fixes -d in our command line tools (eg. samba-tool) Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Thu Nov 4 01:48:15 UTC 2010 on sn-devel-104