From bc388feeeffd29f0bb5df2ca0cedb6c7d7cae1a0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 17 Sep 2021 10:22:29 +0200 Subject: [PATCH 1/3] debug: Remove "override_logfile" The only writer to this variable left with c377845d27d4dcd7. The closest match for override_logfile is is_default_dyn_LOGFILEBASE() with the opposite logic. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Sep 18 00:53:28 UTC 2021 on sn-devel-184 (cherry picked from commit cf4a868be50e795889b76b59f7fbe1cca51bcbfa) --- lib/util/debug.c | 10 ---------- source3/nmbd/nmbd.c | 4 +--- source3/winbindd/winbindd.c | 4 +--- source3/winbindd/winbindd_cm.c | 1 - source3/winbindd/winbindd_dual.c | 18 +++++++++--------- 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/lib/util/debug.c b/lib/util/debug.c index cd52fe4be77..4fd17679227 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -583,16 +583,6 @@ static void debug_backends_log(const char *msg, int msg_level) } } -/* -------------------------------------------------------------------------- ** - * External variables. - */ - -/* - used to check if the user specified a - logfile on the command line -*/ -bool override_logfile; - int debuglevel_get_class(size_t idx) { return dbgc_config[idx].loglevel; diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index d43c52bb406..44121e9915c 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -37,8 +37,6 @@ int global_nmb_port = -1; extern bool rescan_listen_set; extern bool global_in_nmbd; -extern bool override_logfile; - /* have we found LanMan clients yet? */ bool found_lm_clients = False; @@ -857,7 +855,7 @@ static bool open_sockets(bool isdaemon, int port) sys_srandom(time(NULL) ^ getpid()); - if (!override_logfile) { + if (is_default_dyn_LOGFILEBASE()) { char *lfile = NULL; if (asprintf(&lfile, "%s/log.nmbd", get_dyn_LOGFILEBASE()) < 0) { exit(1); diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c index 8c35b8eae76..25d8b723010 100644 --- a/source3/winbindd/winbindd.c +++ b/source3/winbindd/winbindd.c @@ -64,8 +64,6 @@ static void winbindd_setup_max_fds(void); static bool opt_nocache = False; static bool interactive = False; -extern bool override_logfile; - struct imessaging_context *winbind_imessaging_context(void) { static struct imessaging_context *msg = NULL; @@ -1718,7 +1716,7 @@ int main(int argc, const char **argv) poptFreeContext(pc); - if (!override_logfile) { + if (is_default_dyn_LOGFILEBASE()) { char *lfile = NULL; if (asprintf(&lfile,"%s/log.winbindd", get_dyn_LOGFILEBASE()) > 0) { diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index fdb894d7ff6..7381495e155 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -98,7 +98,6 @@ struct dc_name_ip { }; extern struct winbindd_methods reconnect_methods; -extern bool override_logfile; static NTSTATUS init_dc_connection_network(struct winbindd_domain *domain, bool need_rw_dc); static void set_dc_type_and_flags( struct winbindd_domain *domain ); diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 5006d6af096..e19dfafc52f 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -47,8 +47,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND -extern bool override_logfile; - static void forall_domain_children(bool (*fn)(struct winbindd_child *c, void *private_data), void *private_data) @@ -1546,16 +1544,17 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself, close_conns_after_fork(); - if (!override_logfile && logfilename) { + if (is_default_dyn_LOGFILEBASE() && logfilename) { lp_set_logfile(logfilename); reopen_logs(); } if (!winbindd_setup_sig_term_handler(false)) return NT_STATUS_NO_MEMORY; - if (!winbindd_setup_sig_hup_handler(override_logfile ? NULL : - logfilename)) + if (!winbindd_setup_sig_hup_handler( + !is_default_dyn_LOGFILEBASE() ? NULL : logfilename)) { return NT_STATUS_NO_MEMORY; + } /* Stop zombies in children */ CatchChild(); @@ -1776,10 +1775,11 @@ static bool fork_domain_child(struct winbindd_child *child) messaging_register(global_messaging_context(), NULL, MSG_WINBIND_DISCONNECT_DC, winbind_msg_disconnect_dc); - messaging_register(global_messaging_context(), - override_logfile ? NULL : child->logfilename, - MSG_SMB_CONF_UPDATED, - winbindd_msg_reload_services_child); + messaging_register( + global_messaging_context(), + !is_default_dyn_LOGFILEBASE() ? NULL : child->logfilename, + MSG_SMB_CONF_UPDATED, + winbindd_msg_reload_services_child); primary_domain = find_our_domain(); -- 2.31.1 From 6566672da00a3b495a1642ceeb9adf78965d2398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= Date: Thu, 7 Oct 2021 12:08:22 +0200 Subject: [PATCH 2/3] s3:winbindd: Fix winbindd child logfile name handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=14852 Handling of logfile name for main and child winbindd must ensure: 1) Log directory is selected in this order: * -l option of winbindd * "log file" parameter in smb.conf * compile time value '/usr/local/samba/var' 2) Log filename pattern * parent process uses log.winbindd * child uses log.wb- 3) Log reopen works for both parent and child (i.e. log filename is not changed) * kill -HUP * smbcontrol reload-config This commit removes 3 calls of is_default_dyn_LOGFILEBASE() to make sure that: - 1st removal: child uses log.wb- after the fork - 2nd removal: child after HUP signal, does not switch to log.winbindd - 3rd removal: child after smbcontrol reload-config, does not switch to log.winbindd Interesting commits: bfa1b2a8 1484b7f3 3b015a4c d1f7a371 Signed-off-by: Pavel Filipenský Reviewed-by: Ralph Boehme Reviewed-by: Andreas Schneider (cherry picked from commit b92589c31f0eb3eaf2b3b1867e10b759f6a2edda) --- source3/winbindd/winbindd_dual.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index e19dfafc52f..b275dfb128c 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -1544,15 +1544,16 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself, close_conns_after_fork(); - if (is_default_dyn_LOGFILEBASE() && logfilename) { + if (logfilename != NULL) { lp_set_logfile(logfilename); reopen_logs(); } - if (!winbindd_setup_sig_term_handler(false)) + if (!winbindd_setup_sig_term_handler(false)) { return NT_STATUS_NO_MEMORY; - if (!winbindd_setup_sig_hup_handler( - !is_default_dyn_LOGFILEBASE() ? NULL : logfilename)) { + } + + if (!winbindd_setup_sig_hup_handler(logfilename)) { return NT_STATUS_NO_MEMORY; } @@ -1777,7 +1778,7 @@ static bool fork_domain_child(struct winbindd_child *child) winbind_msg_disconnect_dc); messaging_register( global_messaging_context(), - !is_default_dyn_LOGFILEBASE() ? NULL : child->logfilename, + child->logfilename, MSG_SMB_CONF_UPDATED, winbindd_msg_reload_services_child); -- 2.31.1 From 489f7464e378206053d6f34ace7eaa6423149621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Filipensk=C3=BD?= Date: Fri, 8 Oct 2021 13:16:05 +0200 Subject: [PATCH 3/3] docs-xml: Update winbindd(8) manpage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=14852 Signed-off-by: Pavel Filipenský Reviewed-by: Ralph Boehme Reviewed-by: Andreas Schneider Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Tue Oct 12 09:30:02 UTC 2021 on sn-devel-184 (cherry picked from commit 12d04d9a9288a9358d5f5aebaec126cc610952b1) --- docs-xml/manpages/winbindd.8.xml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs-xml/manpages/winbindd.8.xml b/docs-xml/manpages/winbindd.8.xml index 3b7487c1b1c..7a643b8879c 100644 --- a/docs-xml/manpages/winbindd.8.xml +++ b/docs-xml/manpages/winbindd.8.xml @@ -195,7 +195,25 @@ hosts: files wins - &cmdline.common.samba.server; + &cmdline.common.debug.server; + &cmdline.common.config.server; + &cmdline.common.option; + + + -l|--log-basename=logdirectory + + + Base directory name for log/debug files. The parent process + uses filename log.winbindd, the child process uses filename + log.wb-<name>. The log file is never removed by winbindd. + + + + + &cmdline.common.samba.leakreport; + &cmdline.common.samba.leakreportfull; + &cmdline.version; + &popt.autohelp; -- 2.31.1