summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2021-11-11 05:23:09 +0100
committerRalph Boehme <slow@samba.org>2021-11-11 13:49:32 +0000
commit54f54fc2627acbf5fac5e1fa86ab9f743741f3c4 (patch)
treefdd496b6aa2c76db5357900f09fa95f7144086a2 /source3/printing
parent25043ebb2e6f74592e802f78d327f844e615a442 (diff)
downloadsamba-54f54fc2627acbf5fac5e1fa86ab9f743741f3c4.tar.gz
samba-bgqd: fix startup and logging
Let samba-bgqd use the new POPT_COMMON_DAEMON infrastructure. The calls to setup_logging() can safely be removed as this is already taken care of by samba_cmdline_init(). To avoid a logfile basename of ".log" when using "%m", we add a call to set_remote_machine_name(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/samba-bgqd.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/source3/printing/samba-bgqd.c b/source3/printing/samba-bgqd.c
index 336a007ab9a..f21327fc622 100644
--- a/source3/printing/samba-bgqd.c
+++ b/source3/printing/samba-bgqd.c
@@ -41,6 +41,7 @@
#include "source3/lib/util_procid.h"
#include "source3/auth/proto.h"
#include "source3/printing/queue_process.h"
+#include "source3/lib/substitute.h"
static void watch_handler(struct tevent_req *req)
{
@@ -158,6 +159,7 @@ static int samba_bgqd_pidfile_create(
int main(int argc, const char *argv[])
{
+ struct samba_cmdline_daemon_cfg *cmdline_daemon_cfg = NULL;
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
const char *progname = getprogname();
@@ -168,8 +170,6 @@ int main(int argc, const char *argv[])
struct tevent_req *watch_req = NULL;
struct tevent_signal *sigterm_handler = NULL;
struct bq_state *bq = NULL;
- int foreground = 0;
- int no_process_group = 0;
int log_stdout = 0;
int ready_signal_fd = -1;
int watch_fd = -1;
@@ -182,21 +182,7 @@ int main(int argc, const char *argv[])
struct poptOption long_options[] = {
POPT_AUTOHELP
POPT_COMMON_SAMBA
- {
- .longName = "foreground",
- .shortName = 'F',
- .argInfo = POPT_ARG_NONE,
- .arg = &foreground,
- .descrip = "Run daemon in foreground "
- "(for daemontools, etc.)",
- },
- {
- .longName = "no-process-group",
- .shortName = '\0',
- .argInfo = POPT_ARG_NONE,
- .arg = &no_process_group,
- .descrip = "Don't create a new process group" ,
- },
+ POPT_COMMON_DAEMON
/*
* File descriptor to write the PID of the helper
@@ -234,6 +220,7 @@ int main(int argc, const char *argv[])
talloc_enable_null_tracking();
frame = talloc_stackframe();
umask(0);
+ set_remote_machine_name("smbd-bgqd", true);
ok = samba_cmdline_init(frame,
SAMBA_CMDLINE_CONFIG_SERVER,
@@ -243,6 +230,8 @@ int main(int argc, const char *argv[])
exit(ENOMEM);
}
+ cmdline_daemon_cfg = samba_cmdline_get_daemon_cfg();
+
pc = samba_popt_get_context(progname,
argc,
argv,
@@ -263,16 +252,12 @@ int main(int argc, const char *argv[])
log_stdout = (debug_get_log_type() == DEBUG_STDOUT);
- if (foreground) {
+ if (!cmdline_daemon_cfg->fork) {
daemon_status(progname, "Starting process ... ");
} else {
- become_daemon(true, no_process_group, log_stdout);
- }
-
- if (log_stdout) {
- setup_logging(progname, DEBUG_STDOUT);
- } else {
- setup_logging(progname, DEBUG_FILE);
+ become_daemon(true,
+ cmdline_daemon_cfg->no_process_group,
+ log_stdout);
}
BlockSignals(true, SIGPIPE);