From 6ef992fd3a0480ff0bc1679adc88f39b7a0945b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Tue, 6 Jun 2023 17:25:35 +0200 Subject: [PATCH 1/9] lib/util: move copyright define to copyright.h BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit b7631bf603fbce9b80b19410f0680ce8c4170a1b) --- lib/util/copyright.h | 28 ++++++++++++++++++++++++++++ source3/include/includes.h | 3 +++ source3/include/smb.h | 3 --- source4/include/includes.h | 3 +++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 lib/util/copyright.h diff --git a/lib/util/copyright.h b/lib/util/copyright.h new file mode 100644 index 00000000000..a29f2285d13 --- /dev/null +++ b/lib/util/copyright.h @@ -0,0 +1,28 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Björn Jacke 2023 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef __LIB_UTIL_COPYRIGHT_H__ +#define __LIB_UTIL_COPYRIGHT_H__ + +/* logged when starting the various Samba daemons */ +#define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2023" + +#endif /* __LIB_UTIL_COPYRIGHT_H__ */ + + diff --git a/source3/include/includes.h b/source3/include/includes.h index 02beb0a0c88..8bb6ee88803 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -242,6 +242,9 @@ enum timestamp_set_resolution { typedef char fstring[FSTRING_LEN]; #endif +/* copyright define */ +#include "../lib/util/copyright.h" + /* debug.h need to be included before samba_util.h for the macro SMB_ASSERT */ #include "../lib/util/debug.h" diff --git a/source3/include/smb.h b/source3/include/smb.h index 487a8b316d8..81d761d2280 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -29,9 +29,6 @@ #include "libcli/smb/smb_common.h" #include "libds/common/roles.h" -/* logged when starting the various Samba daemons */ -#define COPYRIGHT_STARTUP_MESSAGE "Copyright Andrew Tridgell and the Samba Team 1992-2023" - #define LARGE_WRITEX_HDR_SIZE 65 #define LARGE_WRITEX_BUFFER_SIZE (128*1024) diff --git a/source4/include/includes.h b/source4/include/includes.h index e7abf1a2492..8832b97ed02 100644 --- a/source4/include/includes.h +++ b/source4/include/includes.h @@ -57,6 +57,9 @@ #endif #include "../lib/util/attr.h" +/* copyright define */ +#include "../lib/util/copyright.h" + /* debug.h need to be included before samba_util.h for the macro SMB_ASSERT */ #include "../lib/util/debug.h" #include "../lib/util/samba_util.h" -- 2.38.0 From f02cff69810d53ec4d11894bec418daed4c38ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Mon, 18 Sep 2023 13:48:06 +0200 Subject: [PATCH 2/9] debug.h: introduce DEBUG_STARTUP_NOTICE this is log level -1 and lowest syslog priority. This is used for start up messages and copyright notices, which should always be printed but which are no errors or warnings. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit ccfe345fece0a5a44d766fb9426d43c2e046d040) --- lib/util/debug.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/util/debug.h b/lib/util/debug.h index 335a644718f..5433a585ec8 100644 --- a/lib/util/debug.h +++ b/lib/util/debug.h @@ -269,12 +269,14 @@ void debuglevel_set_class(size_t idx, int level); /* * Debug levels matching RFC 3164 */ +#define DBGLVL_STARTUP_NOTICE -1 /* startup notice */ #define DBGLVL_ERR 0 /* error conditions */ #define DBGLVL_WARNING 1 /* warning conditions */ #define DBGLVL_NOTICE 3 /* normal, but significant, condition */ #define DBGLVL_INFO 5 /* informational message */ #define DBGLVL_DEBUG 10 /* debug-level message */ +#define DBG_STARTUP_NOTICE(...) DBG_PREFIX(DBGLVL_STARTUP_NOTICE, (__VA_ARGS__)) #define DBG_ERR(...) DBG_PREFIX(DBGLVL_ERR, (__VA_ARGS__)) #define DBG_WARNING(...) DBG_PREFIX(DBGLVL_WARNING, (__VA_ARGS__)) #define DBG_NOTICE(...) DBG_PREFIX(DBGLVL_NOTICE, (__VA_ARGS__)) -- 2.38.0 From 640e7b279865adc89348d1bfb68d32d540534ab9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 16 Aug 2023 16:47:24 +0200 Subject: [PATCH 3/9] s3:rpc_server: call reopen_logs before we print the copyright notice This matches what we do in smbd, winbindd and nmbd. For the workers it's important to call it at all, otherwise things like 'debug pid = yes' or 'debug class = yes' have no effect in the workers. We could argue if we want the copyright notice on the start of each worker at all, but that's a different discussion... Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett (cherry picked from commit 94723b6732a67482eb7792e82b01e26a807e8265) --- source3/rpc_server/rpc_host.c | 4 ++-- source3/rpc_server/rpc_worker.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/rpc_server/rpc_host.c b/source3/rpc_server/rpc_host.c index 1cb874569e2..b59916b5dda 100644 --- a/source3/rpc_server/rpc_host.c +++ b/source3/rpc_server/rpc_host.c @@ -2838,13 +2838,13 @@ int main(int argc, const char *argv[]) dump_core_setup(progname, lp_logfile(frame, lp_sub)); + reopen_logs(); + DEBUG(0, ("%s version %s started.\n", progname, samba_version_string())); DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); - reopen_logs(); - (void)winbind_off(); ok = init_guest_session_info(frame); (void)winbind_on(); diff --git a/source3/rpc_server/rpc_worker.c b/source3/rpc_server/rpc_worker.c index 4f47a0ad4f3..2ef90547dd6 100644 --- a/source3/rpc_server/rpc_worker.c +++ b/source3/rpc_server/rpc_worker.c @@ -1122,6 +1122,8 @@ int rpc_worker_main( /* Ignore children - no zombies. */ CatchChild(); + reopen_logs(); + DEBUG(0, ("%s version %s started.\n", progname, samba_version_string())); -- 2.38.0 From 1461bdbca4af7d05c054d3cc1bf71ba75a13f5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Mon, 5 Jun 2023 18:10:07 +0200 Subject: [PATCH 4/9] logging: use DBG_STARTUP_NOTICE for startup message BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit 159cfde446c95c387ef212be103b109ea0dca93d) --- source3/rpc_server/rpc_host.c | 6 +++--- source3/rpc_server/rpc_worker.c | 8 ++++---- source3/smbd/server.c | 5 +++-- source3/winbindd/winbindd.c | 5 +++-- source4/samba/server.c | 7 +++---- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/source3/rpc_server/rpc_host.c b/source3/rpc_server/rpc_host.c index b59916b5dda..9e64fa62d0c 100644 --- a/source3/rpc_server/rpc_host.c +++ b/source3/rpc_server/rpc_host.c @@ -2840,10 +2840,10 @@ int main(int argc, const char *argv[]) reopen_logs(); - DEBUG(0, ("%s version %s started.\n", + DBG_STARTUP_NOTICE("%s version %s started.\n" + COPYRIGHT_STARTUP_MESSAGE "\n", progname, - samba_version_string())); - DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); + samba_version_string()); (void)winbind_off(); ok = init_guest_session_info(frame); diff --git a/source3/rpc_server/rpc_worker.c b/source3/rpc_server/rpc_worker.c index 2ef90547dd6..cde0e7bcd59 100644 --- a/source3/rpc_server/rpc_worker.c +++ b/source3/rpc_server/rpc_worker.c @@ -1124,10 +1124,10 @@ int rpc_worker_main( reopen_logs(); - DEBUG(0, ("%s version %s started.\n", - progname, - samba_version_string())); - DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); + DBG_STARTUP_NOTICE("%s version %s started.\n" + COPYRIGHT_STARTUP_MESSAGE "\n", + progname, + samba_version_string()); msg_ctx = global_messaging_context(); if (msg_ctx == NULL) { diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 6feb9001b79..8c80682b6ef 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1747,8 +1747,9 @@ extern void build_options(bool screen); reopen_logs(); - DEBUG(0,("smbd version %s started.\n", samba_version_string())); - DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); + DBG_STARTUP_NOTICE("smbd version %s started.\n" + COPYRIGHT_STARTUP_MESSAGE "\n", + samba_version_string()); DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n", (int)getuid(),(int)getgid(),(int)geteuid(),(int)getegid())); diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 92d5de70915..fdcf3e51242 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -1506,8 +1506,9 @@ int main(int argc, const char **argv) reopen_logs(); - DEBUG(0,("winbindd version %s started.\n", samba_version_string())); - DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); + DBG_STARTUP_NOTICE("winbindd version %s started.\n" + COPYRIGHT_STARTUP_MESSAGE "\n", + samba_version_string()); /* After parsing the configuration file we setup the core path one more time * as the log file might have been set in the configuration and cores's diff --git a/source4/samba/server.c b/source4/samba/server.c index eb4ddeb7ce7..3b3852dc3e5 100644 --- a/source4/samba/server.c +++ b/source4/samba/server.c @@ -630,11 +630,10 @@ static int binary_smbd_main(TALLOC_CTX *mem_ctx, so set our umask to 0 */ umask(0); - DEBUG(0,("%s version %s started.\n", + DBG_STARTUP_NOTICE("%s version %s started.\n" + COPYRIGHT_STARTUP_MESSAGE "\n", binary_name, - SAMBA_VERSION_STRING)); - DEBUGADD(0,("Copyright Andrew Tridgell and the Samba Team" - " 1992-2023\n")); + SAMBA_VERSION_STRING); if (sizeof(uint16_t) < 2 || sizeof(uint32_t) < 4 || -- 2.38.0 From 7b2f1eefd18ab8a5338fef3d889e8abd685a85ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Wed, 15 Nov 2023 19:44:38 +0100 Subject: [PATCH 5/9] README.Coding.md: add DBG_STARTUP_NOTICE macro BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit bb370b9381e5d223ff4ac62f612888f90a63fcc5) --- README.Coding.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.Coding.md b/README.Coding.md index 76f2c70e95a..132f3f4fa58 100644 --- a/README.Coding.md +++ b/README.Coding.md @@ -539,11 +539,12 @@ It should be: Use these following macros instead of DEBUG: ``` -DBG_ERR log level 0 error conditions -DBG_WARNING log level 1 warning conditions -DBG_NOTICE log level 3 normal, but significant, condition -DBG_INFO log level 5 informational message -DBG_DEBUG log level 10 debug-level message +DBG_STARTUP_NOTICE log level -1 startup like notice +DBG_ERR log level 0 error conditions +DBG_WARNING log level 1 warning conditions +DBG_NOTICE log level 3 normal, but significant, condition +DBG_INFO log level 5 informational message +DBG_DEBUG log level 10 debug-level message ``` Example usage: -- 2.38.0 From c5da82f9f4b054d7c022c1e9e70a32fe0fd924f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Mon, 18 Sep 2023 14:34:29 +0200 Subject: [PATCH 6/9] lib/util/become_daemon.c: use DBG_STARTUP_NOTICE BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit 50337acaa566b6696e035e38f6408f65805182a0) --- lib/util/become_daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c index 9424656d403..c6795c585c8 100644 --- a/lib/util/become_daemon.c +++ b/lib/util/become_daemon.c @@ -147,5 +147,5 @@ void daemon_status(const char *daemon, const char *msg) sd_notifyf(0, "STATUS=%s: %s", daemon, msg); } #endif - DBG_ERR("daemon '%s' : %s\n", daemon, msg); + DBG_STARTUP_NOTICE("daemon '%s' : %s\n", daemon, msg); } -- 2.38.0 From 88ef4c7b637f1aa1495ed052aa0b2bfdb61e922b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Mon, 18 Sep 2023 14:35:55 +0200 Subject: [PATCH 7/9] source3/nmbd/nmbd.c: use DBG_STARTUP_NOTICE BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit 72f20311acc4ab8851f18ac2b87f7ecc7803afad) --- source3/nmbd/nmbd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 7cdd9bd1303..1db16726851 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -898,7 +898,9 @@ static bool open_sockets(bool isdaemon, int port) reopen_logs(); - DBG_ERR("nmbd version %s started.\n%s\n", samba_version_string(), COPYRIGHT_STARTUP_MESSAGE); + DBG_STARTUP_NOTICE("nmbd version %s started.\n" + COPYRIGHT_STARTUP_MESSAGE "\n", + samba_version_string()); if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC && !lp_parm_bool(-1, "server role check", "inhibit", false)) { -- 2.38.0 From 0a791974c6831627da36e1eac9f202dd5c079857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Mon, 18 Sep 2023 23:42:31 +0200 Subject: [PATCH 8/9] profile: issues info message with lower log level BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit 55d895dc42248ad524a10812b9975ac05a722fdc) --- source3/profile/profile_dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/profile/profile_dummy.c b/source3/profile/profile_dummy.c index 7d34d209fce..5d3213eec1a 100644 --- a/source3/profile/profile_dummy.c +++ b/source3/profile/profile_dummy.c @@ -27,5 +27,5 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly) void set_profile_level(int level, const struct server_id *src) { - DEBUG(1,("INFO: Profiling support unavailable in this build.\n")); + DBG_NOTICE("INFO: Profiling support unavailable in this build.\n"); } -- 2.38.0 From 21872830aedd01d69a5f8408abcde62dcd1fca61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Jacke?= Date: Mon, 18 Sep 2023 13:45:54 +0200 Subject: [PATCH 9/9] s4/server.c: move some log messages from ERR to NOTICE BUG: https://bugzilla.samba.org/show_bug.cgi?id=15377 Signed-off-by: Bjoern Jacke Reviewed-by: Andrew Bartlett (cherry picked from commit baa67024bca391f2e212b91131f544cc911c6895) --- source4/samba/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/samba/server.c b/source4/samba/server.c index 3b3852dc3e5..e1ad646fae2 100644 --- a/source4/samba/server.c +++ b/source4/samba/server.c @@ -800,7 +800,7 @@ static int binary_smbd_main(TALLOC_CTX *mem_ctx, if (max_runtime) { struct tevent_timer *te; - DBG_ERR("%s PID %d was called with maxruntime %d - " + DBG_NOTICE("%s PID %d was called with maxruntime %d - " "current ts %llu\n", binary_name, (int)getpid(), max_runtime, (unsigned long long) time(NULL)); @@ -904,7 +904,7 @@ static int binary_smbd_main(TALLOC_CTX *mem_ctx, return 1; } - DBG_ERR("%s: using '%s' process model\n", binary_name, model); + DBG_NOTICE("%s: using '%s' process model\n", binary_name, model); { int child_pipe[2]; -- 2.38.0