[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Thu Nov 11 14:43:01 UTC 2021


The branch, master has been updated
       via  06ed4ccba6c lib/cmdline: setup default file logging for servers
       via  97592f16bfb lib/cmdline: remember config_type in samba_cmdline_init()
       via  120a598e531 lib/cmdline: fix indentation
       via  fa9d9974d06 lib/debug: in debug_set_logfile() call reopen_logs_internal()
       via  948a82bd265 lib/debug: fix fd check before dup'ing to stderr
       via  117d45df47a winbindd: remove is_default_dyn_LOGFILEBASE() logic
       via  54f54fc2627 samba-bgqd: fix startup and logging
       via  25043ebb2e6 source3: move lib/substitute.c functions out of proto.h
      from  c28be406746 auth:creds: Guess the username first via getpwuid(my_id)

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 06ed4ccba6cfe08aef061866f98b1d1da26682b8
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 8 12:09:43 2021 +0100

    lib/cmdline: setup default file logging for servers
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897
    RN: samba process doesn't log to logfile
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Thu Nov 11 14:42:13 UTC 2021 on sn-devel-184

commit 97592f16bfb8590efbd2ed31fc9883d747ec650f
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 8 12:09:16 2021 +0100

    lib/cmdline: remember config_type in samba_cmdline_init()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 120a598e53173aacc0994318223bdac33dac4fbd
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 8 12:08:47 2021 +0100

    lib/cmdline: fix indentation
    
    s/whitespace/tab/
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit fa9d9974d068897d35539e5316f606a15e8b38de
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 8 19:41:50 2021 +0100

    lib/debug: in debug_set_logfile() call reopen_logs_internal()
    
    This simplifies the logging API for callers that typically would want to set
    logging by just setup_logging() once without bothering that typically
    configuration is loaded (via some lpcfg_load*() or lp_load*() varient) which
    will only then pick up the configured logfile from smb.conf without actually
    applying the new logifle to the logging subsytem.
    
    Therefor our daemons will additionally call reopen_logs() explicitly in their
    startup code after config is loaded, eg
    
    	setup_logging(getprogname(), DEBUG_FILE);
    	...
    	lpcfg_load(lp_ctx, config_file);
    	...
    	reopen_logs();
    
    By calling reopen_logs_internal() implicitly from debug_set_logfile() there's no
    need to call reopen_logs() explicitly anymore to apply the logfile.
    
    As reopen_logs() will also apply other logging configuration options, we have to
    keep the explicit calls in the daemon code. But at least this allows consistent
    logging setup wrt to the logfile in the new cmdline library.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 948a82bd2651e73e4e669a89dc77ba93abbb9b2f
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 10 14:13:11 2021 +0100

    lib/debug: fix fd check before dup'ing to stderr
    
    Before I added per-class logfile and we had only one fd for the logfile the code
    looked like this:
    
            /* Take over stderr to catch output into logs */
            if (state.fd > 0) {
                    if (dup2(state.fd, 2) == -1) {
                            /* Close stderr too, if dup2 can't point it -
                               at the logfile.  There really isn't much
                               that can be done on such a fundamental
                               failure... */
                            close_low_fd(2);
                    }
            }
    
    In the current code the equivalent to state.fd is dbgc_config[DBGC_ALL].fd.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 117d45df47a1f3206bc38aaeaa11f2b327e43530
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 10 18:27:08 2021 +0100

    winbindd: remove is_default_dyn_LOGFILEBASE() logic
    
    Handling of -l commandline parameter is already implemented by lib/cmdline/.
    
    is_default_dyn_LOGFILEBASE() == true is the default case and this causes us to
    temporarily overwrite the configured logfile with LOGFILEBASE/log.winbindd until
    winbindd_reload_services_file() restores it.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 54f54fc2627acbf5fac5e1fa86ab9f743741f3c4
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 11 05:23:09 2021 +0100

    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 at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 25043ebb2e6f74592e802f78d327f844e615a442
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 10 20:18:07 2021 +0100

    source3: move lib/substitute.c functions out of proto.h
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14897
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/cmdline/cmdline_s3.c                    |  2 +-
 lib/cmdline/cmdline_s4.c                    | 16 ++++++++
 lib/util/debug.c                            |  5 ++-
 source3/auth/auth_generic.c                 |  1 +
 source3/auth/auth_ntlmssp.c                 |  1 +
 source3/auth/auth_util.c                    |  1 +
 source3/include/proto.h                     | 33 ---------------
 source3/lib/substitute.c                    |  1 +
 source3/lib/substitute.h                    | 63 +++++++++++++++++++++++++++++
 source3/modules/vfs_expand_msdfs.c          |  1 +
 source3/modules/vfs_full_audit.c            |  1 +
 source3/modules/vfs_recycle.c               |  1 +
 source3/modules/vfs_unityed_media.c         |  1 +
 source3/modules/vfs_virusfilter_utils.c     |  1 +
 source3/nmbd/nmbd.c                         |  1 +
 source3/nmbd/nmbd_synclists.c               |  1 +
 source3/param/loadparm.c                    |  1 +
 source3/passdb/passdb.c                     |  1 +
 source3/passdb/pdb_ldap.c                   |  1 +
 source3/printing/print_generic.c            |  1 +
 source3/printing/printing.c                 |  1 +
 source3/printing/samba-bgqd.c               | 35 +++++-----------
 source3/rpc_server/lsa/srv_lsa_nt.c         |  1 +
 source3/rpc_server/netlogon/srv_netlog_nt.c |  1 +
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c   |  1 +
 source3/smbd/ipc.c                          |  1 +
 source3/smbd/lanman.c                       |  1 +
 source3/smbd/message.c                      |  1 +
 source3/smbd/msdfs.c                        |  1 +
 source3/smbd/process.c                      |  1 +
 source3/smbd/reply.c                        |  1 +
 source3/smbd/server.c                       |  1 +
 source3/smbd/service.c                      |  1 +
 source3/smbd/sesssetup.c                    |  1 +
 source3/smbd/share_access.c                 |  1 +
 source3/smbd/smb2_server.c                  |  1 +
 source3/smbd/smb2_sesssetup.c               |  1 +
 source3/smbd/trans2.c                       |  1 +
 source3/smbd/uid.c                          |  1 +
 source3/torture/torture.c                   |  1 +
 source3/utils/net_sam.c                     |  1 +
 source3/winbindd/wb_getpwsid.c              |  1 +
 source3/winbindd/winbindd.c                 | 10 +----
 43 files changed, 130 insertions(+), 70 deletions(-)
 create mode 100644 source3/lib/substitute.h


Changeset truncated at 500 lines:

diff --git a/lib/cmdline/cmdline_s3.c b/lib/cmdline/cmdline_s3.c
index 1f8d9ed5eb5..639d403aed3 100644
--- a/lib/cmdline/cmdline_s3.c
+++ b/lib/cmdline/cmdline_s3.c
@@ -55,7 +55,7 @@ static bool _samba_cmdline_load_config_s3(void)
 	case SAMBA_CMDLINE_CONFIG_CLIENT:
 		ok = lp_load_client(config_file);
 		break;
-        case SAMBA_CMDLINE_CONFIG_SERVER:
+	case SAMBA_CMDLINE_CONFIG_SERVER:
 	{
 		const struct samba_cmdline_daemon_cfg *cmdline_daemon_cfg =
 			samba_cmdline_get_daemon_cfg();
diff --git a/lib/cmdline/cmdline_s4.c b/lib/cmdline/cmdline_s4.c
index 61c1b96ba8d..29e9f34bbe2 100644
--- a/lib/cmdline/cmdline_s4.c
+++ b/lib/cmdline/cmdline_s4.c
@@ -25,6 +25,7 @@
 #include "cmdline_private.h"
 
 static bool _require_smbconf;
+static enum samba_cmdline_config_type _config_type;
 
 static bool _samba_cmdline_load_config_s4(void)
 {
@@ -43,6 +44,20 @@ static bool _samba_cmdline_load_config_s4(void)
 		}
 	}
 
+	switch (_config_type) {
+	case SAMBA_CMDLINE_CONFIG_SERVER: {
+		const struct samba_cmdline_daemon_cfg *cmdline_daemon_cfg =
+			samba_cmdline_get_daemon_cfg();
+
+		if (!cmdline_daemon_cfg->interactive) {
+			setup_logging(getprogname(), DEBUG_FILE);
+		}
+		break;
+	}
+	default:
+		break;
+	}
+
 	config_file = get_dyn_CONFIGFILE();
 	ok = lpcfg_load(lp_ctx, config_file);
 	if (!ok) {
@@ -81,6 +96,7 @@ bool samba_cmdline_init(TALLOC_CTX *mem_ctx,
 		return false;
 	}
 	_require_smbconf = require_smbconf;
+	_config_type = config_type;
 
 	creds = cli_credentials_init(mem_ctx);
 	if (creds == NULL) {
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 2f4a86734ce..784357e9370 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -1143,6 +1143,8 @@ void debug_set_logfile(const char *name)
 	}
 	TALLOC_FREE(dbgc_config[DBGC_ALL].logfile);
 	dbgc_config[DBGC_ALL].logfile = talloc_strdup(NULL, name);
+
+	reopen_logs_internal();
 }
 
 static void debug_close_fd(int fd)
@@ -1249,7 +1251,6 @@ bool reopen_logs_internal(void)
 {
 	struct debug_backend *b = NULL;
 	mode_t oldumask;
-	int new_fd = 0;
 	size_t i;
 	bool ok;
 
@@ -1314,7 +1315,7 @@ bool reopen_logs_internal(void)
 	 * If log file was opened or created successfully, take over stderr to
 	 * catch output into logs.
 	 */
-	if (new_fd != -1) {
+	if (dbgc_config[DBGC_ALL].fd > 0) {
 		if (dup2(dbgc_config[DBGC_ALL].fd, 2) == -1) {
 			/* Close stderr too, if dup2 can't point it -
 			   at the logfile.  There really isn't much
diff --git a/source3/auth/auth_generic.c b/source3/auth/auth_generic.c
index fc7a7549e8e..ff51307e43a 100644
--- a/source3/auth/auth_generic.c
+++ b/source3/auth/auth_generic.c
@@ -36,6 +36,7 @@
 #include "auth/credentials/credentials.h"
 #include "lib/param/loadparm.h"
 #include "librpc/gen_ndr/dcerpc.h"
+#include "source3/lib/substitute.h"
 
 static NTSTATUS auth3_generate_session_info_pac(struct auth4_context *auth_ctx,
 						TALLOC_CTX *mem_ctx,
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index 676aa9d892c..f2deca09aa6 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -25,6 +25,7 @@
 #include "auth.h"
 #include "libcli/security/security.h"
 #include "lib/util/tevent_ntstatus.h"
+#include "source3/lib/substitute.h"
 
 NTSTATUS auth3_generate_session_info(struct auth4_context *auth_context,
 				     TALLOC_CTX *mem_ctx,
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index dec854d85c3..4527dedc49d 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -38,6 +38,7 @@
 #include "rpc_client/util_netlogon.h"
 #include "source4/auth/auth.h"
 #include "auth/auth_util.h"
+#include "source3/lib/substitute.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_AUTH
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c136db63b38..6154b1ab26d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -139,39 +139,6 @@ int smbrun_no_sanitize(const char *cmd, int *outfd, char * const *env);
 int smbrun(const char *cmd, int *outfd, char * const *env);
 int smbrunsecret(const char *cmd, const char *secret);
 
-/* The following definitions come from lib/substitute.c  */
-
-bool set_local_machine_name(const char *local_name, bool perm);
-const char *get_local_machine_name(void);
-bool set_remote_machine_name(const char *remote_name, bool perm);
-const char *get_remote_machine_name(void);
-void sub_set_smb_name(const char *name);
-void set_current_user_info(const char *smb_name, const char *unix_name,
-			   const char *domain);
-void sub_set_socket_ids(const char *peeraddr, const char *peername,
-			const char *sockaddr);
-const char *get_current_username(void);
-void standard_sub_basic(const char *smb_name, const char *domain_name,
-			char *str, size_t len);
-char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
-		       const char *domain_name, const char *str);
-char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
-			const char *input_string,
-			const char *username,
-			const char *grpname,
-			const char *domain,
-			uid_t uid,
-			gid_t gid);
-char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
-			  const char *servicename, const char *user,
-			  const char *connectpath, gid_t gid,
-			  const char *str);
-char *talloc_sub_full(TALLOC_CTX *mem_ctx,
-			  const char *servicename, const char *user,
-			  const char *connectpath, gid_t gid,
-			  const char *smb_name, const char *domain_name,
-			  const char *str);
-
 /* The following definitions come from lib/sysquotas.c  */
 
 int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index b98a0acf1cb..a941b89f82a 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -20,6 +20,7 @@
 
 
 #include "includes.h"
+#include "substitute.h"
 #include "system/passwd.h"
 #include "secrets.h"
 #include "auth.h"
diff --git a/source3/lib/substitute.h b/source3/lib/substitute.h
new file mode 100644
index 00000000000..2056d163dd7
--- /dev/null
+++ b/source3/lib/substitute.h
@@ -0,0 +1,63 @@
+/*
+   Unix SMB/CIFS implementation.
+   string substitution functions
+   Copyright (C) Andrew Tridgell 1992-2000
+   Copyright (C) Gerald Carter   2006
+
+   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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SUBSTITUTE_H
+#define SUBSTITUTE_H
+
+bool set_local_machine_name(const char *local_name, bool perm);
+const char *get_local_machine_name(void);
+bool set_remote_machine_name(const char *remote_name, bool perm);
+const char *get_remote_machine_name(void);
+void sub_set_socket_ids(const char *peeraddr, const char *peername,
+			const char *sockaddr);
+void set_current_user_info(const char *smb_name,
+			   const char *unix_name,
+			   const char *domain);
+const char *get_current_username(void);
+void standard_sub_basic(const char *smb_name,
+			const char *domain_name,
+			char *str,
+			size_t len);
+char *talloc_sub_basic(TALLOC_CTX *mem_ctx,
+			const char *smb_name,
+			const char *domain_name,
+			const char *str);
+char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
+			const char *input_string,
+			const char *username,
+			const char *grpname,
+			const char *domain,
+			uid_t uid,
+			gid_t gid);
+char *talloc_sub_advanced(TALLOC_CTX *ctx,
+			const char *servicename,
+			const char *user,
+			const char *connectpath,
+			gid_t gid,
+			const char *str);
+char *talloc_sub_full(TALLOC_CTX *ctx,
+			const char *servicename,
+			const char *user,
+			const char *connectpath,
+			gid_t gid,
+			const char *smb_name,
+			const char *domain_name,
+			const char *str);
+#endif
diff --git a/source3/modules/vfs_expand_msdfs.c b/source3/modules/vfs_expand_msdfs.c
index 34e7051dca5..fe3c6f47462 100644
--- a/source3/modules/vfs_expand_msdfs.c
+++ b/source3/modules/vfs_expand_msdfs.c
@@ -25,6 +25,7 @@
 #include "auth.h"
 #include "../lib/tsocket/tsocket.h"
 #include "msdfs.h"
+#include "source3/lib/substitute.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 2c07eab69ca..5903849931e 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -73,6 +73,7 @@
 #include "passdb/machine_sid.h"
 #include "lib/util/tevent_ntstatus.h"
 #include "lib/util/string_wrappers.h"
+#include "source3/lib/substitute.h"
 
 static int vfs_full_audit_debug_level = DBGC_VFS;
 
diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c
index 6e657943110..b794ebc2d8c 100644
--- a/source3/modules/vfs_recycle.c
+++ b/source3/modules/vfs_recycle.c
@@ -27,6 +27,7 @@
 #include "system/filesys.h"
 #include "../librpc/gen_ndr/ndr_netlogon.h"
 #include "auth.h"
+#include "source3/lib/substitute.h"
 
 #define ALLOC_CHECK(ptr, label) do { if ((ptr) == NULL) { DEBUG(0, ("recycle.bin: out of memory!\n")); errno = ENOMEM; goto label; } } while(0)
 
diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c
index 62a1456b996..fbd4d968172 100644
--- a/source3/modules/vfs_unityed_media.c
+++ b/source3/modules/vfs_unityed_media.c
@@ -62,6 +62,7 @@
 #include "../lib/tsocket/tsocket.h"
 #include "lib/util/smb_strtox.h"
 #include <libgen.h>
+#include "source3/lib/substitute.h"
 
 #define UM_PARAM_TYPE_NAME "unityed_media"
 
diff --git a/source3/modules/vfs_virusfilter_utils.c b/source3/modules/vfs_virusfilter_utils.c
index c7f8089ffc7..b8b44eb203b 100644
--- a/source3/modules/vfs_virusfilter_utils.c
+++ b/source3/modules/vfs_virusfilter_utils.c
@@ -25,6 +25,7 @@ struct iovec;
 #include "lib/util/iov_buf.h"
 #include <tevent.h>
 #include "lib/tsocket/tsocket.h"
+#include "source3/lib/substitute.h"
 
 int virusfilter_debug_class = DBGC_VFS;
 
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 44121e9915c..7470897587e 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -29,6 +29,7 @@
 #include "util_cluster.h"
 #include "lib/gencache.h"
 #include "lib/global_contexts.h"
+#include "source3/lib/substitute.h"
 
 int ClientNMB       = -1;
 int ClientDGRAM     = -1;
diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c
index a65cbb87e0e..d291927fbc8 100644
--- a/source3/nmbd/nmbd_synclists.c
+++ b/source3/nmbd/nmbd_synclists.c
@@ -33,6 +33,7 @@
 #include "libsmb/clirap.h"
 #include "../libcli/smb/smbXcli_base.h"
 #include "lib/util/string_wrappers.h"
+#include "source3/lib/substitute.h"
 
 struct sync_record {
 	struct sync_record *next, *prev;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 62878c213d3..a08a9a06748 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -76,6 +76,7 @@
 #include "lib/crypto/gnutls_helpers.h"
 #include "lib/util/string_wrappers.h"
 #include "auth/credentials/credentials.h"
+#include "source3/lib/substitute.h"
 
 #ifdef HAVE_SYS_SYSCTL_H
 #include <sys/sysctl.h>
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 068c5a5ea70..863f260ea90 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -33,6 +33,7 @@
 #include "auth/credentials/credentials.h"
 #include "lib/param/param.h"
 #include "lib/util/string_wrappers.h"
+#include "source3/lib/substitute.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_PASSDB
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index e6d8a84c60f..93da28b1941 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -56,6 +56,7 @@
 #include "lib/util_sid_passdb.h"
 #include "lib/util/smb_strtox.h"
 #include "lib/util/string_wrappers.h"
+#include "source3/lib/substitute.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_PASSDB
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index 743c311bbd5..8798a4cf34a 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -20,6 +20,7 @@
 #include "includes.h"
 #include "printing.h"
 #include "smbd/proto.h"
+#include "source3/lib/substitute.h"
 
 extern userdom_struct current_user_info;
 
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 499334df03f..67d798fbb21 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -40,6 +40,7 @@
 #include "lib/util/string_wrappers.h"
 #include "lib/global_contexts.h"
 #include "source3/printing/rap_jobid.h"
+#include "source3/lib/substitute.h"
 
 extern userdom_struct current_user_info;
 
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);
diff --git a/source3/rpc_server/lsa/srv_lsa_nt.c b/source3/rpc_server/lsa/srv_lsa_nt.c
index 8d341b616b1..8d71b5252ab 100644
--- a/source3/rpc_server/lsa/srv_lsa_nt.c
+++ b/source3/rpc_server/lsa/srv_lsa_nt.c
@@ -53,6 +53,7 @@
 #include "librpc/rpc/dcesrv_core.h"
 #include "librpc/rpc/dcerpc_helper.h"
 #include "lib/param/loadparm.h"
+#include "source3/lib/substitute.h"
 
 #include "lib/crypto/gnutls_helpers.h"
 #include <gnutls/gnutls.h>
diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c
index 70105894f53..ac5d22ce74d 100644
--- a/source3/rpc_server/netlogon/srv_netlog_nt.c
+++ b/source3/rpc_server/netlogon/srv_netlog_nt.c
@@ -50,6 +50,7 @@
 #include "lib/param/param.h"
 #include "libsmb/dsgetdcname.h"
 #include "lib/util/util_str_escape.h"
+#include "source3/lib/substitute.h"


-- 
Samba Shared Repository



More information about the samba-cvs mailing list