[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Tue Feb 28 05:35:03 MST 2012


The branch, master has been updated
       via  d12bad7 torture: added samba4-ntvfs target
       via  e2e2e60 s3fs: when samba is logging to stdout, ask smbd to also do so
       via  1da318d smbd: detect EOF on stdin in --foreground mode
       via  645fcc5 selftest: added a pipe on stdin in s3 child processes
       via  8db121b s3fs: added file_server directory
       via  63c96b3 s4-smb_server Remove inetd-mode samba3 hook
      from  0c4d1d6 upgradedns: Missing rename from upgradedns to samba_upgradedns

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


- Log -----------------------------------------------------------------
commit d12bad72ba4c6492b137fb6fa04b595e64e6d993
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Feb 9 14:33:09 2012 +1100

    torture: added samba4-ntvfs target
    
    this will be used for the samba4 server with the ntvfs backend
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User: Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date: Tue Feb 28 13:34:44 CET 2012 on sn-devel-104

commit e2e2e60b619f1df8beccbe27cf40b4dcbd82ff57
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Feb 9 14:07:00 2012 +1100

    s3fs: when samba is logging to stdout, ask smbd to also do so
    
    this prevents make test getting spurious errors about opening log
    files in the install prefix

commit 1da318d97da6c7f9e8d5d389fc06619b423fcda0
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Nov 30 14:08:28 2011 +1100

    smbd: detect EOF on stdin in --foreground mode
    
    if EOF is detected on stdin then exit

commit 645fcc5375325b700ac58cb25c498f6f7b91421b
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue Jan 3 16:48:29 2012 +1100

    selftest: added a pipe on stdin in s3 child processes
    
    this adds a pipe for STDIN in smbd, nmbd and winbindd when run in
    selftest. This allows those processes to detect when they should exit
    by looking for EOF on stdin.

commit 8db121be4265bc4de3b34c6eab1b5ae2fd882957
Author: Andrew Tridgell <tridge at samba.org>
Date:   Tue May 3 09:35:07 2011 +1000

    s3fs: added file_server directory
    
    this contains a file server backend that forks and starts smbd
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 63c96b3a58accffba21981563b8b53c33f8b8f37
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Sep 6 11:34:35 2011 +1000

    s4-smb_server Remove inetd-mode samba3 hook

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

Summary of changes:
 file_server/file_server.c                          |  126 ++++++++++++++
 .../dns_update.h => file_server/file_server.h      |   14 +-
 file_server/wscript_build                          |   10 +
 selftest/target/Samba3.pm                          |   17 ++
 source3/smbd/server.c                              |   25 +++
 source4/smb_server/service_smb.c                   |    1 +
 source4/smb_server/smb_samba3.c                    |  181 --------------------
 source4/smb_server/wscript_build                   |   10 -
 source4/torture/smbtorture.c                       |    3 +
 wscript_build                                      |    1 +
 10 files changed, 190 insertions(+), 198 deletions(-)
 create mode 100644 file_server/file_server.c
 copy source4/dns_server/dns_update.h => file_server/file_server.h (80%)
 create mode 100644 file_server/wscript_build
 delete mode 100644 source4/smb_server/smb_samba3.c


Changeset truncated at 500 lines:

diff --git a/file_server/file_server.c b/file_server/file_server.c
new file mode 100644
index 0000000..3f5ca77
--- /dev/null
+++ b/file_server/file_server.c
@@ -0,0 +1,126 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   run s3 file server within Samba4
+
+   Copyright (C) Andrew Tridgell	2011
+
+   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/>.
+*/
+
+#include "includes.h"
+#include "talloc.h"
+#include "tevent.h"
+#include "system/filesys.h"
+#include "lib/param/param.h"
+#include "source4/smbd/service.h"
+#include "source4/smbd/process_model.h"
+#include "file_server/file_server.h"
+#include "dynconfig.h"
+
+/*
+  generate a smbd config file for the file server
+ */
+static const char *generate_smb_conf(struct task_server *task)
+{
+	int fd;
+	struct loadparm_context *lp_ctx = task->lp_ctx;
+	const char *path = smbd_tmp_path(task, lp_ctx, "fileserver.conf");
+
+	if (path == NULL) {
+		return NULL;
+	}
+
+	fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+	if (fd == -1) {
+		DEBUG(0,("Failed to create %s", path));
+		return NULL;
+	}
+
+	fdprintf(fd, "# auto-generated config for fileserver\n");
+	fdprintf(fd, "auth methods = guest samba4\n");
+	fdprintf(fd, "passdb backend = samba4\n");
+        fdprintf(fd, "rpc_server:default = external\n");
+        fdprintf(fd, "rpc_server:dssetup = disabled\n");
+	fdprintf(fd, "rpc_server:spoolss = embedded\n");
+	fdprintf(fd, "rpc_daemon:spoolssd = disabled\n");
+	fdprintf(fd, "rpc_server:tcpip = no\n");
+
+	fdprintf(fd, "include = %s\n", lpcfg_configfile(lp_ctx));
+	close(fd);
+	return path;
+}
+
+/*
+  called if smbd exits
+ */
+static void file_server_smbd_done(struct tevent_req *subreq)
+{
+	int sys_errno;
+	int ret;
+
+	ret = samba_runcmd_recv(subreq, &sys_errno);
+	if (ret != 0) {
+		DEBUG(0,("file_server smbd daemon died with exit status %d\n", sys_errno));
+	} else {
+		DEBUG(0,("file_server smbd daemon exited normally\n"));
+	}
+}
+
+
+/*
+  startup a copy of smbd as a child daemon
+*/
+static void s3fs_task_init(struct task_server *task)
+{
+	const char *fileserver_conf;
+	struct tevent_req *req;
+	const char *smbd_path;
+	const char *smbd_cmd[2] = { NULL, NULL };
+
+	task_server_set_title(task, "task[s3fs_parent]");
+
+	/* create a smb.conf for smbd to use */
+	fileserver_conf = generate_smb_conf(task);
+
+	smbd_path = talloc_asprintf(task, "%s/smbd", dyn_SBINDIR);
+	smbd_cmd[0] = smbd_path;
+
+	/* start it as a child process */
+	req = samba_runcmd_send(task, task->event_ctx, timeval_zero(), 1, 0,
+				smbd_cmd,
+				"--configfile", fileserver_conf,
+				"--foreground",
+				debug_get_output_is_stdout()?"--log-stdout":NULL,
+				NULL);
+	if (req == NULL) {
+		DEBUG(0, ("Failed to start smbd as child daemon\n"));
+		goto failed;
+	}
+
+	tevent_req_set_callback(req, file_server_smbd_done, task);
+
+	DEBUG(1,("Started file server smbd with config %s\n", fileserver_conf));
+	return;
+failed:
+	task_server_terminate(task, "Failed to startup s3fs smb task", true);
+}
+
+/* called at smbd startup - register ourselves as a server service */
+NTSTATUS server_service_s3fs_init(void);
+
+NTSTATUS server_service_s3fs_init(void)
+{
+	return register_server_service("s3fs", s3fs_task_init);
+}
diff --git a/source4/dns_server/dns_update.h b/file_server/file_server.h
similarity index 80%
copy from source4/dns_server/dns_update.h
copy to file_server/file_server.h
index 71ff85e..7da9437 100644
--- a/source4/dns_server/dns_update.h
+++ b/file_server/file_server.h
@@ -1,9 +1,9 @@
 /*
    Unix SMB/CIFS implementation.
 
-   DNS update settings
+   run s3 file server within Samba4
 
-   Copyright (C) 2011 Kai Blin  <kai at samba.org>
+   Copyright (C) Andrew Tridgell	2011
 
    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
@@ -18,8 +18,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-enum dns_update_settings {
-	DNS_UPDATE_OFF=0,
-	DNS_UPDATE_ON=1,
-	DNS_UPDATE_SIGNED=2
-};
+
+/*
+  open the s3 smb server sockets
+*/
+void s3_smbd_task_init(struct task_server *task);
diff --git a/file_server/wscript_build b/file_server/wscript_build
new file mode 100644
index 0000000..f76c847
--- /dev/null
+++ b/file_server/wscript_build
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+bld.SAMBA_MODULE('service_s3fs',
+                 source='file_server.c',
+                 autoproto='file_server_proto.h',
+                 subsystem='service',
+                 init_function='server_service_s3fs_init',
+                 deps='samba-hostconfig service talloc UTIL_RUNCMD',
+                 internal_module=False
+                 )
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 45705c0..4b0b725 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -590,6 +590,11 @@ sub read_pid($$)
 sub check_or_start($$$$$) {
 	my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
 
+	# use a pipe for stdin in the child processes. This allows
+	# those processes to monitor the pipe for EOF to ensure they
+	# exit when the test script exits
+	pipe(STDIN_READER, $env_vars->{STDIN_PIPE});
+
 	unlink($env_vars->{NMBD_TEST_LOG});
 	print "STARTING NMBD...";
 	my $pid = fork();
@@ -631,6 +636,9 @@ sub check_or_start($$$$$) {
 			@preargs = split(/ /, $ENV{NMBD_VALGRIND});
 		}
 
+		close($env_vars->{STDIN_PIPE});
+		open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
+
 		exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
 	}
 	write_pid($env_vars, "nmbd", $pid);
@@ -679,6 +687,9 @@ sub check_or_start($$$$$) {
 
 		print "Starting winbindd with config $env_vars->{SERVERCONFFILE}\n";
 
+		close($env_vars->{STDIN_PIPE});
+		open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
+
 		exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
 	}
 	write_pid($env_vars, "winbindd", $pid);
@@ -722,11 +733,17 @@ sub check_or_start($$$$$) {
 		if(defined($ENV{SMBD_VALGRIND})) {
 			@preargs = split(/ /,$ENV{SMBD_VALGRIND});
 		}
+
+		close($env_vars->{STDIN_PIPE});
+		open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!";
+
 		exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "--log-stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
 	}
 	write_pid($env_vars, "smbd", $pid);
 	print "DONE\n";
 
+	close(STDIN_READER);
+
 	return 0;
 }
 
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index f89bfd4..986eb21 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -857,6 +857,23 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
 	return true;
 }
 
+
+/*
+  handle stdin becoming readable when we are in --foreground mode
+ */
+static void smbd_stdin_handler(struct tevent_context *ev,
+			       struct tevent_fd *fde,
+			       uint16_t flags,
+			       void *private_data)
+{
+	char c;
+	if (read(0, &c, 1) != 1) {
+		/* we have reached EOF on stdin, which means the
+		   parent has exited. Shutdown the server */
+		exit_server_cleanly("EOF on stdin");
+	}
+}
+
 static void smbd_parent_loop(struct tevent_context *ev_ctx,
 			     struct smbd_parent_context *parent)
 {
@@ -1409,6 +1426,14 @@ extern void build_options(bool screen);
 	/* make sure we always have a valid stackframe */
 	frame = talloc_stackframe();
 
+	if (!Fork) {
+		/* if we are running in the foreground then look for
+		   EOF on stdin, and exit if it happens. This allows
+		   us to die if the parent process dies
+		*/
+		tevent_add_fd(ev_ctx, parent, 0, TEVENT_FD_READ, smbd_stdin_handler, NULL);
+	}
+
 	smbd_parent_loop(ev_ctx, parent);
 
 	exit_server_cleanly(NULL);
diff --git a/source4/smb_server/service_smb.c b/source4/smb_server/service_smb.c
index cbbd2cd..c910b0f 100644
--- a/source4/smb_server/service_smb.c
+++ b/source4/smb_server/service_smb.c
@@ -33,6 +33,7 @@
 #include "param/share.h"
 #include "dsdb/samdb/samdb.h"
 #include "param/param.h"
+#include "file_server/file_server.h"
 
 /*
   open the smb server sockets
diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c
deleted file mode 100644
index 1a99be6..0000000
--- a/source4/smb_server/smb_samba3.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
-   Unix SMB/CIFS implementation.
-
-   process incoming connections and fork a samba3 in inetd mode
-
-   Copyright (C) Stefan Metzmacher	2008
-
-   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/>.
-*/
-
-#include "includes.h"
-#include "smbd/service.h"
-#include "libcli/smb2/smb2.h"
-#include "system/network.h"
-#include "lib/socket/netif.h"
-#include "param/param.h"
-#include "dynconfig/dynconfig.h"
-#include "smbd/process_model.h"
-
-NTSTATUS server_service_samba3_smb_init(void);
-
-/*
-  initialise a server_context from a open socket and register a event handler
-  for reading from that socket
-*/
-static void samba3_smb_accept(struct stream_connection *conn)
-{
-	int i;
-	int fd = socket_get_fd(conn->socket);
-	const char *prog;
-	char *argv[2];
-	char *reason;
-
-	close(0);
-	close(1);
-	dup2(fd, 0);
-	dup2(fd, 1);
-	dup2(fd, 2);
-	for (i=3;i<256;i++) {
-		close(i);
-	}
-
-	prog = lpcfg_parm_string(conn->lp_ctx, NULL, "samba3", "smbd");
-
-	if (prog == NULL) {
-		argv[0] = talloc_asprintf(conn, "%s/%s", dyn_BINDIR, "smbd3");
-	}
-	else {
-		argv[0] = talloc_strdup(conn, prog);
-	}
-
-	if (argv[0] == NULL) {
-		stream_terminate_connection(conn, "out of memory");
-		return;
-	}
-	argv[1] = NULL;
-
-	execv(argv[0], argv);
-
-	/*
-	 * Should never get here
-	 */
-	reason = talloc_asprintf(conn, "Could not execute %s", argv[0]);
-	if (reason == NULL) {
-		stream_terminate_connection(conn, "out of memory");
-		return;
-	}
-	stream_terminate_connection(conn, reason);
-	talloc_free(reason);
-}
-
-static const struct stream_server_ops samba3_smb_stream_ops = {
-	.name			= "samba3",
-	.accept_connection	= samba3_smb_accept,
-};
-
-/*
-  setup a listening socket on all the SMB ports for a particular address
-*/
-static NTSTATUS samba3_add_socket(struct task_server *task,
-				  struct tevent_context *event_context,
-				  struct loadparm_context *lp_ctx,
-				  const struct model_ops *model_ops,
-				  const char *address)
-{
-	const char **ports = lpcfg_smb_ports(lp_ctx);
-	int i;
-	NTSTATUS status;
-
-	for (i=0;ports[i];i++) {
-		uint16_t port = atoi(ports[i]);
-		if (port == 0) continue;
-		status = stream_setup_socket(task, event_context, lp_ctx,
-					     model_ops, &samba3_smb_stream_ops,
-					     "ip", address, &port,
-					     lpcfg_socket_options(lp_ctx),
-					     NULL);
-		NT_STATUS_NOT_OK_RETURN(status);
-	}
-
-	return NT_STATUS_OK;
-}
-
-
-/*
-  open the smb server sockets
-*/
-static void samba3_smb_task_init(struct task_server *task)
-{
-	NTSTATUS status;
-	const struct model_ops *model_ops;
-
-	model_ops = process_model_startup("standard");
-
-	if (model_ops == NULL) {
-		goto failed;
-	}
-
-	task_server_set_title(task, "task[samba3_smb]");
-
-	if (lpcfg_interfaces(task->lp_ctx)
-	    && lpcfg_bind_interfaces_only(task->lp_ctx)) {
-		int num_interfaces;
-		int i;
-		struct interface *ifaces;
-
-		load_interface_list(task, task->lp_ctx, &ifaces);
-
-		num_interfaces = iface_list_count(ifaces);
-
-		/* We have been given an interfaces line, and been
-		   told to only bind to those interfaces. Create a
-		   socket per interface and bind to only these.
-		*/
-		for(i = 0; i < num_interfaces; i++) {
-			const char *address = iface_list_n_ip(ifaces, i);
-			status = samba3_add_socket(task,
-						   task->event_ctx,
-						   task->lp_ctx,
-						   model_ops, address);
-			if (!NT_STATUS_IS_OK(status)) goto failed;
-		}
-	} else {
-		const char **wcard;
-		int i;
-		wcard = iface_list_wildcard(task, task->lp_ctx);
-		if (wcard == NULL) {
-			DEBUG(0,("No wildcard addresses available\n"));
-			goto failed;
-		}
-		for (i=0; wcard[i]; i++) {
-			status = samba3_add_socket(task,
-						   task->event_ctx, task->lp_ctx,
-						   model_ops,
-						   wcard[i]);
-			if (!NT_STATUS_IS_OK(status)) goto failed;
-		}
-		talloc_free(wcard);
-	}
-
-	return;
-failed:
-	task_server_terminate(task, "Failed to startup samba3 smb task", true);
-}
-
-/* called at smbd startup - register ourselves as a server service */
-NTSTATUS server_service_samba3_smb_init(void)
-{
-	return register_server_service("samba3_smb", samba3_smb_task_init);
-}
diff --git a/source4/smb_server/wscript_build b/source4/smb_server/wscript_build
index 8622388..5bf004a 100644
--- a/source4/smb_server/wscript_build
+++ b/source4/smb_server/wscript_build
@@ -9,16 +9,6 @@ bld.SAMBA_MODULE('service_smb',
 	internal_module=False,
 	)
 
-
-bld.SAMBA_MODULE('service_samba3_smb',
-	source='smb_samba3.c',
-	subsystem='service',
-	init_function='server_service_samba3_smb_init',
-	deps='talloc',
-	internal_module=False,
-	)
-
-
 bld.SAMBA_SUBSYSTEM('SMB_SERVER',
 	source='handle.c tcon.c session.c blob.c management.c smb_server.c',
 	autoproto='smb_server_proto.h',
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 934e0a7..04ba94d 100644


-- 
Samba Shared Repository


More information about the samba-cvs mailing list