summaryrefslogtreecommitdiff
path: root/lib/util/debug.c
AgeCommit message (Collapse)AuthorFilesLines
2020-11-10debug: remove a cast, which makes the Solaris Studio compiler unhappyBjörn Jacke1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14526 Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-07-02lib/debug: set the correct default backend loglevel to MAX_DEBUG_LEVELRalph Boehme1-1/+1
This fixed a regression introduced by commit c83ce5f4f99aef94530411ec82cc03e9935b352d for bug #14345. The backend loglevel globally restricts logging of a particular backend. If this value is smaller then any explicitly configured logging class, logging for this class is skipped. Eg, given the following logging config in smb.conf: log level = 1 auth_json_audit:3@/var/log/samba/samba_auth_audit.log the default class loglevel of 1 (dbgc_config[DBGC_ALL].loglevel) will be assigned to the backend loglevel. So even though the logging class auth_json_audit is configured at level 3, this doesn't become effective as the file backend drops all log messages with a level below 1. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14426 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Jul 2 13:25:29 UTC 2020 on sn-devel-184
2020-07-02lib/debug: assert file backendRalph Boehme1-6/+6
The debug file backend is a built-in default, if it's missing we're totally screwed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14426 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2020-05-07lib:util: Fix smbclient -l basename dirAmit Kumar1-1/+7
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14345 Pair-Programmed-With: Andreas Schneider <asn@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Amit Kumar <amitkuma@redhat.com> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu May 7 10:38:29 UTC 2020 on sn-devel-184
2020-04-22util: Fix signed/unsigned integer comparisonMartin Schwenke1-1/+1
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Wed Apr 22 01:48:03 UTC 2020 on sn-devel-184
2020-02-19lib: Fix rotating nonstandard debug class log filesVolker Lendecke1-1/+1
Looking at the same pointer in the loop does not really make sense to me Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2019-09-01Spelling fixes s/preceeding/preceding/Mathieu Parent1-1/+1
Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-06-11lib/util: clang: Fix 'Null pointer passed as an argument...' warningNoel Power1-3/+7
Fixes: lib/util/debug.c:705:7: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer gary@catalyst.net.nz
2019-05-28lib/util: set current_msg_{level,class} also during a DEBUGADD[C]() callStefan Metzmacher1-5/+12
In some situations we use DEBUGADDC() in order to print out content without a related debug header line. This is important with the new per class logfile with: log level = 1 dsdb_json_audit:10@/var/log/samba/log.dsdb_json_audit BUG: https://bugzilla.samba.org/show_bug.cgi?id=13915 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2019-05-06lib util debug: Increase format buffer to 4KiBGary Lockyer1-1/+1
Increase the debug line buffer to 4KiB, the existing size of 1KiB is too small for dsdbChange JSON audit messages. These messages were then split across multipe lines causing issues in log ingestion tools expecting single line messages. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13902 Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Mon May 6 01:18:22 UTC 2019 on sn-devel-184
2019-02-07lib/debug: retain full string in state.prog_name globalDavid Disseldorp1-4/+8
setup_logging() retains a global pointer to the provided const string in state.prog_name, which is later used in the debug_backend->reload() callback. Some setup_logging() callers, such as popt_common_callback(), incorrectly assume that a dynamic buffer is safe to provide as a prog_name parameter. Fix this by copying the entire string in setup_logging(). Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-12-20debug: enable per debug-class logfilesRalph Boehme1-2/+13
This finally enables per debug-class logfiles by hooking into reopen_logs_internal() calls to reopen_one_log() per configured debug-class. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: remove fd and debugf from state, use dbgc_config[DBGC_ALL]Ralph Boehme1-25/+34
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: update logsize checking for per debug-class logfilesRalph Boehme1-0/+14
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: update need_to_check_log_size() for per debug-class logfilesRalph Boehme1-2/+15
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: add support for per debug-class logfilesRalph Boehme1-1/+14
This adds support for per debug-class logfiles to the function parsing the "log level" option. The enhanced syntax is: log level = CLASS:LEVEL[@PATH] [CLASS:LEVEL[@PATH] ... ] Eg log level = full_audit:1@/var/log/audit.logfile While the option is already parsed and stored in in the dbgc_config[] array, the feature is still effectively disabled, as reopen_logs_internal() still doesn't open the per debug-class logfiles. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: add resource cleanup for per debug-class logfilesRalph Boehme1-0/+1
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: add logfile and fd to struct debug_classRalph Boehme1-1/+17
Initialized to -1. Already checked in debug_file_log() without affecting behaviour until subsequent commits set per-debug-class fds. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: factor out logfile size checkRalph Boehme1-19/+54
The new function will also be used for upcoming per-debug-class logfiles. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: factor out a function that opens and closes the new and old logfileRalph Boehme1-16/+24
The new function reopen_one_log() will also be used for per-class logfiles in subsequent commmits. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: track current debug message classRalph Boehme1-0/+4
This is analog to current_msg_level. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: convert dbgc_config to an array of struct debug_classRalph Boehme1-16/+29
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: README.Coding fixesRalph Boehme1-12/+19
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: rename DEBUGLEVEL_CLASS variable to dbgc_configRalph Boehme1-19/+19
Variable names should not be given in uppercase. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-12-20debug: move some definitions aroundRalph Boehme1-51/+52
They will be needed by some function in a subsequent commit. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-11-08debug: Use debuglevel_(get|set) functionAndreas Schneider1-1/+11
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Nov 8 11:03:11 CET 2018 on sn-devel-144
2018-11-08lib:util: Fix DEBUGCLASS pointer initializiationAndreas Schneider1-2/+2
This fixes a segfault in pyglue: ==10142== Process terminating with default action of signal 11 (SIGSEGV) ==10142== Bad permissions for mapped region at address 0x6F00A20 ==10142== at 0x6F1074B: py_set_debug_level (pyglue.c:165) BUG: https://bugzilla.samba.org/show_bug.cgi?id=13679 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2018-08-18s3: util: Do not take over stderr when there is no log filePaulo Alcantara1-2/+5
In case we don't have either a /var/log/samba directory, or pass a non-existent log directory through '-l' option, all commands that are daemonized with '-D' option hang when executed within a subshell. An example on how to trigger that: # rm -r /var/log/samba # s=$(nmbd -D -s /etc/samba/smb.conf -l /foo123) (never returns) So, when the above command is executed within a subshell the following happens: (a) Parent shell creates a pipe, sets write side of it to fd 1 (stdout), call read() on read-side fd, forks off a new child process and then executes nmbd in it. (b) nmbd sets up initial logging to go through fd 1 (stdout) by calling setup_logging(..., DEBUG_DEFAULT_STDOUT). 'state.fd' is now set to 1. (c) reopen_logs() is called by the first time which then calls reopen_logs_internal() (d) in reopen_logs_internal(), it attempts to create log.nmbd file in /foo123 directory and fails because directory doesn't exist. (e) Regardless whether the log file was created or not, it calls dup2(state.fd, 2) which dups fd 1 into fd 2. (f) At some point, fd 0 and 1 are closed and set to /dev/null The problem with that is because parent shell in (a) is still blocked in read() call and the new write side of the pipe is now fd 2 -- after dup2() in (e) -- and remains unclosed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13578 Signed-off-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Jim McDonough <jmcd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Aug 18 01:32:25 CEST 2018 on sn-devel-144
2018-05-17lib:util: Fix size types in debug.cAndreas Schneider1-7/+7
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
2018-05-16debug: Add group logging classesGary Lockyer1-0/+2
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed May 16 07:02:20 CEST 2018 on sn-devel-144
2018-05-16logging: add ldb audit classesGary Lockyer1-0/+6
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-22s3: smbd: SMB2: Add DBGC_SMB2_CREDITS class to specifically debug credit issues.Jeremy Allison1-0/+1
https://bugzilla.samba.org/show_bug.cgi?id=13347 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
2018-03-22s3: debug: smb2: Create a new DBGC_SMB2 debug class and mark all ↵Jeremy Allison1-0/+1
smbd/smb2_*.c files with it. Will allow easier smb2-specific debugging. https://bugzilla.samba.org/show_bug.cgi?id=13347 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
2017-09-30lib: Fix a signed/unsigned hickupVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2017-09-07debug: Add new debug class "drs_repl" for DRS replication processingAndrew Bartlett1-0/+1
This is used in the client and in the server Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-06-30debug: new debug class for kerberosAndrew Bartlett1-0/+1
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-04-18lib: debug: Avoid negative array access.Jeremy Allison1-1/+1
Report and patch from Hanno Böck <hanno@hboeck.de>. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12746 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org>
2017-03-29auth_log: Add JSON logging of Authorisation and AuthenticationsGary Lockyer1-0/+1
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Pair-Programmed: Andrew Bartlett <abartlet@samba.org>
2017-03-29debug: Add debug class for auth_auditAndrew Bartlett1-0/+1
This will be an audit stream of authentication and connection-level authorization Signed-off-by: Andrew Bartlett <abartlet@samba.org> Pair-Programmed-by: Gary Lockyer <gary@catalyst.net.nz> Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
2017-02-11debug: Do not depend on the whole of samba_util.hAndrew Bartlett1-1/+2
By depending only on util_strlist.h and blocking.h we avoid pulling in the generated NTSTATUS list for this low-level subsystem Signed-off-by: Andrew Bartlett <abartlet@samba.org> Pair-programmed-with: Bob Campbell <bobcampbell@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-01-20debug: add "ringbuf" backend logging to a ringbufferRalph Boehme1-0/+83
This is useful for debugging bugs that involve timing effects and are not reproducible when logging at higher debug levels with the file backend. The log can be dumped to a file with gdb: (gdb) dump binary memory samba.log debug_ringbuf debug_ringbuf+SIZE Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2017-01-20debug: parse, store and pass backend optionRalph Boehme1-9/+22
Will be used in the next commit by new "ringbuf" backend. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2016-12-09lib/util: Fix indentation within routine description for dbghdrclassAnoop C S1-15/+15
Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Fri Dec 9 02:02:36 CET 2016 on sn-devel-144
2016-12-08lib/util: Fix input arguments description for dbghdrclass() routineAnoop C S1-3/+1
Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-12-02util: Initialize pointerAndreas Schneider1-1/+1
Coverity warns about so this will silence it. Reviewed-by: Jeremy Allison <jra@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org>
2016-10-14debug: Fix a few signed/unsigned hickupsVolker Lendecke1-3/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2016-06-27libutil: Support systemd 230Andreas Schneider1-3/+3
systemd 230 version finally deprecated libsystemd-daemon/libsystemd-journal split and put everything in libsystemd library. Make sure HAVE_LIBSYSTEMD define is supported in the code (we already have it defined by the waf). BUG: https://bugzilla.samba.org/show_bug.cgi?id=11936 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Richard Sharpe <rsharpe@samba.org> Autobuild-User(master): Richard Sharpe <sharpe@samba.org> Autobuild-Date(master): Mon Jun 27 00:01:55 CEST 2016 on sn-devel-144
2016-05-13debug: fix -O3 warning - unused return code of write()Michael Adam1-2/+9
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
2015-11-06Fix various spelling errorsMathieu Parent1-1/+1
Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Nov 6 13:43:45 CET 2015 on sn-devel-104
2015-07-17lib/util: include config.h before any glibc headersUri Simchoni1-1/+1
config.h may have some flags which affect glibc behavior, e.g. _FILE_OFFSET_BITS=64. To make sure these flags have the desired effect, config.h must be included before any glibc header files. This commit does not fix a specific known bug. It changes the code to comply with coding conventions. Signed-off-by: Uri Simchoni <urisimchoni@gmail.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: "Stefan Metzmacher" <metze@samba.org>