[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Wed Feb 17 02:21:47 MST 2010


The branch, master has been updated
       via  986627c... s4-provision: freeze the DNS zone before creating the zone file
       via  fd25563... s4-dnsupdate: use samba_runcmd() in the dns update task
       via  8633d81... s4-param: added "rndc command" smb.conf option
       via  8756e13... util: added samba_runcmd()
       via  5c71614... examples: add bind9 patches for TSIG-GSS support
       via  72c0cd7... s4-provision: fix permissions on generated DNS zone file
      from  d14c375... s3:rpc streamline memory handling

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


- Log -----------------------------------------------------------------
commit 986627cd67f4ff48152fa5147977813e2b190a93
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Feb 17 19:43:26 2010 +1100

    s4-provision: freeze the DNS zone before creating the zone file
    
    This prevents bind from getting confused if it has a journal for the
    zone.

commit fd2556317f22ee02b341ca7ebbd02d7197fb1e4d
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Feb 17 19:29:37 2010 +1100

    s4-dnsupdate: use samba_runcmd() in the dns update task
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 8633d8126bdf5c31c079d64428492bf1ab2d4cb2
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Feb 17 18:18:28 2010 +1100

    s4-param: added "rndc command" smb.conf option

commit 8756e130098254564ebbfb878efdc9f2a24a0696
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Feb 17 18:18:05 2010 +1100

    util: added samba_runcmd()
    
    This allows us to run a child command in an async fashion, with
    control over logging of stdout and stderr (which appears in the Samba
    log file). This is useful for ensuring we don't miss important
    messages from rndc commands (for example).
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 5c716146e8aee16b46a2144c199b922c13fd00ba
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Feb 17 16:34:33 2010 +1100

    examples: add bind9 patches for TSIG-GSS support
    
    We will point at these from the Samba4 HOWTO

commit 72c0cd75e4b0aa5e59af6f54800f7a63d95da790
Author: Andrew Tridgell <tridge at samba.org>
Date:   Wed Feb 17 16:29:17 2010 +1100

    s4-provision: fix permissions on generated DNS zone file
    
    The zone file needs to be writeable by bind to allow for it to flush
    its journal on dynamic updates
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 ...-the-question-section-in-update-responses.patch |   29 +++
 ...t-a-valgrind-uninitialised-memory-warning.patch |   34 +++
 .../0003-don-t-compress-TSIG-names.patch           |   58 +++++
 ...api-initialisation-fails-then-heck-for-th.patch |   94 ++++++++
 ...sn-t-return-valid-GSSAPI-sequence-numbers.patch |   30 +++
 examples/bind9-patches/README                      |    5 +
 lib/util/config.mk                                 |    5 +
 lib/util/util.h                                    |   17 ++
 lib/util/util_runcmd.c                             |  253 ++++++++++++++++++++
 source4/dsdb/config.mk                             |    3 +-
 source4/dsdb/dns/dns_update.c                      |   51 +++--
 source4/param/loadparm.c                           |    4 +
 source4/param/param.h                              |    1 +
 source4/scripting/python/samba/provision.py        |   30 ++-
 14 files changed, 587 insertions(+), 27 deletions(-)
 create mode 100644 examples/bind9-patches/0001-leave-the-question-section-in-update-responses.patch
 create mode 100644 examples/bind9-patches/0002-prevent-a-valgrind-uninitialised-memory-warning.patch
 create mode 100644 examples/bind9-patches/0003-don-t-compress-TSIG-names.patch
 create mode 100644 examples/bind9-patches/0004-If-tkey-gssapi-initialisation-fails-then-heck-for-th.patch
 create mode 100644 examples/bind9-patches/0005-windows-doesn-t-return-valid-GSSAPI-sequence-numbers.patch
 create mode 100644 examples/bind9-patches/README
 create mode 100644 lib/util/util_runcmd.c


Changeset truncated at 500 lines:

diff --git a/examples/bind9-patches/0001-leave-the-question-section-in-update-responses.patch b/examples/bind9-patches/0001-leave-the-question-section-in-update-responses.patch
new file mode 100644
index 0000000..3716dd4
--- /dev/null
+++ b/examples/bind9-patches/0001-leave-the-question-section-in-update-responses.patch
@@ -0,0 +1,29 @@
+From 1d97835f07fd5142187629941422f87b33015414 Mon Sep 17 00:00:00 2001
+From: Andrew Tridgell <tridge at samba.org>
+Date: Wed, 17 Feb 2010 10:47:59 +1100
+Subject: [PATCH 1/5] leave the question section in update responses.
+
+This fixes TSIG-GSS updates from windows7 and w2k8r2, which require
+the question to be included in the initial refusal for the unsigned
+update.
+---
+ lib/dns/message.c |    3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/lib/dns/message.c b/lib/dns/message.c
+index b541635..ae4965f 100644
+--- a/lib/dns/message.c
++++ b/lib/dns/message.c
+@@ -2474,7 +2474,8 @@ dns_message_reply(dns_message_t *msg, isc_boolean_t want_question_section) {
+	if (!msg->header_ok)
+		return (DNS_R_FORMERR);
+	if (msg->opcode != dns_opcode_query &&
+-	    msg->opcode != dns_opcode_notify)
++	    msg->opcode != dns_opcode_notify &&
++	    msg->opcode != dns_opcode_update)
+		want_question_section = ISC_FALSE;
+	if (want_question_section) {
+		if (!msg->question_ok)
+--
+1.6.3.3
+
diff --git a/examples/bind9-patches/0002-prevent-a-valgrind-uninitialised-memory-warning.patch b/examples/bind9-patches/0002-prevent-a-valgrind-uninitialised-memory-warning.patch
new file mode 100644
index 0000000..22f0ce4
--- /dev/null
+++ b/examples/bind9-patches/0002-prevent-a-valgrind-uninitialised-memory-warning.patch
@@ -0,0 +1,34 @@
+From 31059dee4a706bb4f25f3dccaae7616451eabd8b Mon Sep 17 00:00:00 2001
+From: Andrew Tridgell <tridge at samba.org>
+Date: Wed, 17 Feb 2010 10:59:42 +1100
+Subject: [PATCH 2/5] prevent a valgrind uninitialised memory warning
+
+epoll uses a union, so to prevent passing uninitialised data in a
+syscall we need to zero it before use.
+---
+ lib/isc/unix/socket.c |    2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c
+index d09fe51..4796ee4 100644
+--- a/lib/isc/unix/socket.c
++++ b/lib/isc/unix/socket.c
+@@ -652,6 +652,7 @@ watch_fd(isc_socketmgr_t *manager, int fd, int msg) {
+		event.events = EPOLLIN;
+	else
+		event.events = EPOLLOUT;
++	memset(&event.data, 0, sizeof(event.data));
+	event.data.fd = fd;
+	if (epoll_ctl(manager->epoll_fd, EPOLL_CTL_ADD, fd, &event) == -1 &&
+	    errno != EEXIST) {
+@@ -719,6 +720,7 @@ unwatch_fd(isc_socketmgr_t *manager, int fd, int msg) {
+		event.events = EPOLLIN;
+	else
+		event.events = EPOLLOUT;
++	memset(&event.data, 0, sizeof(event.data));
+	event.data.fd = fd;
+	if (epoll_ctl(manager->epoll_fd, EPOLL_CTL_DEL, fd, &event) == -1 &&
+	    errno != ENOENT) {
+--
+1.6.3.3
+
diff --git a/examples/bind9-patches/0003-don-t-compress-TSIG-names.patch b/examples/bind9-patches/0003-don-t-compress-TSIG-names.patch
new file mode 100644
index 0000000..e92dce3
--- /dev/null
+++ b/examples/bind9-patches/0003-don-t-compress-TSIG-names.patch
@@ -0,0 +1,58 @@
+From ec22ed6c9797dbdcd820e352167bef8500ca00c6 Mon Sep 17 00:00:00 2001
+From: Andrew Tridgell <tridge at samba.org>
+Date: Wed, 17 Feb 2010 12:20:35 +1100
+Subject: [PATCH 3/5] don't compress TSIG names
+
+windows DNS servers will refuse TSIG-GSS requests with compressed
+names
+---
+ bin/nsupdate/nsupdate.c |    4 ++++
+ lib/dns/message.c       |    2 ++
+ lib/dns/tsig.c          |    3 +++
+ 3 files changed, 9 insertions(+), 0 deletions(-)
+
+diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c
+index 6cf4cf4..f7ce6db 100644
+--- a/bin/nsupdate/nsupdate.c
++++ b/bin/nsupdate/nsupdate.c
+@@ -1985,6 +1985,10 @@ send_update(dns_name_t *zonename, isc_sockaddr_t *master,
+		fprintf(stderr, "Sending update to %s\n", addrbuf);
+	}
+
++	/* windows doesn't like the tsig name to be compressed */
++	if (updatemsg->tsigname)
++		updatemsg->tsigname->attributes |= DNS_NAMEATTR_NOCOMPRESS;
++
+	result = dns_request_createvia3(requestmgr, updatemsg, srcaddr,
+					master, options, tsigkey, timeout,
+					udp_timeout, udp_retries, global_task,
+diff --git a/lib/dns/message.c b/lib/dns/message.c
+index ae4965f..cb4528f 100644
+--- a/lib/dns/message.c
++++ b/lib/dns/message.c
+@@ -1531,6 +1531,8 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
+		} else if (rdtype == dns_rdatatype_tsig && msg->tsig == NULL) {
+			msg->tsig = rdataset;
+			msg->tsigname = name;
++			/* TSIG names should not be compressed */
++			msg->tsigname->attributes |= DNS_NAMEATTR_NOCOMPRESS;
+			rdataset = NULL;
+			free_rdataset = ISC_FALSE;
+			free_name = ISC_FALSE;
+diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c
+index 74a7af3..3223942 100644
+--- a/lib/dns/tsig.c
++++ b/lib/dns/tsig.c
+@@ -889,6 +889,9 @@ dns_tsig_sign(dns_message_t *msg) {
+	msg->tsig = dataset;
+	msg->tsigname = owner;
+
++	/* windows does not like the tsig name being compressed */
++	msg->tsigname->attributes |= DNS_NAMEATTR_NOCOMPRESS;
++
+	return (ISC_R_SUCCESS);
+
+  cleanup_rdatalist:
+--
+1.6.3.3
+
diff --git a/examples/bind9-patches/0004-If-tkey-gssapi-initialisation-fails-then-heck-for-th.patch b/examples/bind9-patches/0004-If-tkey-gssapi-initialisation-fails-then-heck-for-th.patch
new file mode 100644
index 0000000..3130a05
--- /dev/null
+++ b/examples/bind9-patches/0004-If-tkey-gssapi-initialisation-fails-then-heck-for-th.patch
@@ -0,0 +1,94 @@
+From c73ceb48ffc518e171d1d40b82ae2b5f603fe038 Mon Sep 17 00:00:00 2001
+From: Andrew Tridgell <tridge at samba.org>
+Date: Wed, 17 Feb 2010 15:27:44 +1100
+Subject: [PATCH 4/5] If tkey-gssapi initialisation fails, then heck for the most common
+ configuration errors so that the admin doesn't spend all day trying to
+ work out why the config is broken.
+
+---
+ lib/dns/gssapictx.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 files changed, 48 insertions(+), 0 deletions(-)
+
+diff --git a/lib/dns/gssapictx.c b/lib/dns/gssapictx.c
+index 11eadb9..879393c 100644
+--- a/lib/dns/gssapictx.c
++++ b/lib/dns/gssapictx.c
+@@ -66,6 +66,7 @@
+  * we include SPNEGO's OID.
+  */
+ #if defined(GSSAPI)
++#include <krb5/krb5.h>
+
+ static unsigned char krb5_mech_oid_bytes[] = {
+	0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x01, 0x02, 0x02
+@@ -191,6 +192,50 @@ log_cred(const gss_cred_id_t cred) {
+ }
+ #endif
+
++#ifdef GSSAPI
++/*
++ * check for the most common configuration errors.
++ *
++ * The errors checked for are:
++ *   - tkey-gssapi-credential doesn't start with DNS/
++ *   - the default realm in /etc/krb5.conf and the
++ *     tkey-gssapi-credential bind config option don't match
++ */
++static void dst_gssapi_check_config(const char *gss_name)
++{
++	const char *p;
++	krb5_context krb5_ctx;
++	char *krb5_realm = NULL;
++
++	if (strncasecmp(gss_name, "DNS/", 4) != 0) {
++		gss_log(ISC_LOG_ERROR, "tkey-gssapi-credential (%s) should start with 'DNS/'");
++		return;
++	}
++
++	if (krb5_init_context(&krb5_ctx) != 0) {
++		gss_log(ISC_LOG_ERROR, "Unable to initialise krb5 context");
++		return;
++	}
++	if (krb5_get_default_realm(krb5_ctx, &krb5_realm) != 0) {
++		gss_log(ISC_LOG_ERROR, "Unable to get krb5 default realm");
++		krb5_free_context(krb5_ctx);
++		return;
++	}
++	if (!(p = strchr(gss_name, '/'))) {
++		gss_log(ISC_LOG_ERROR, "badly formatted tkey-gssapi-credentials (%s)", gss_name);
++		krb5_free_context(krb5_ctx);
++		return;
++	}
++	if (strcasecmp(p+1, krb5_realm) != 0) {
++		gss_log(ISC_LOG_ERROR,"default realm from krb5.conf (%s) does not match tkey-gssapi-credential (%s)",
++			krb5_realm, gss_name);
++		krb5_free_context(krb5_ctx);
++		return;
++	}
++	krb5_free_context(krb5_ctx);
++}
++#endif
++
+ isc_result_t
+ dst_gssapi_acquirecred(dns_name_t *name, isc_boolean_t initiate,
+		       gss_cred_id_t *cred)
+@@ -223,6 +268,8 @@ dst_gssapi_acquirecred(dns_name_t *name, isc_boolean_t initiate,
+		gret = gss_import_name(&minor, &gnamebuf,
+				       GSS_C_NO_OID, &gname);
+		if (gret != GSS_S_COMPLETE) {
++			dst_gssapi_check_config((char *)array);
++
+			gss_log(3, "failed gss_import_name: %s",
+				gss_error_tostring(gret, minor, buf,
+						   sizeof(buf)));
+@@ -254,6 +301,7 @@ dst_gssapi_acquirecred(dns_name_t *name, isc_boolean_t initiate,
+			initiate ? "initiate" : "accept",
+			(char *)gnamebuf.value,
+			gss_error_tostring(gret, minor, buf, sizeof(buf)));
++		dst_gssapi_check_config((char *)array);
+		return (ISC_R_FAILURE);
+	}
+
+--
+1.6.3.3
+
diff --git a/examples/bind9-patches/0005-windows-doesn-t-return-valid-GSSAPI-sequence-numbers.patch b/examples/bind9-patches/0005-windows-doesn-t-return-valid-GSSAPI-sequence-numbers.patch
new file mode 100644
index 0000000..a44813d
--- /dev/null
+++ b/examples/bind9-patches/0005-windows-doesn-t-return-valid-GSSAPI-sequence-numbers.patch
@@ -0,0 +1,30 @@
+From 0f6a49d9fb4a3b9f917ee9caed3a94e44db045a5 Mon Sep 17 00:00:00 2001
+From: Andrew Tridgell <tridge at samba.org>
+Date: Wed, 17 Feb 2010 15:28:51 +1100
+Subject: [PATCH 5/5] windows doesn't return valid GSSAPI sequence numbers on its
+ TSIG-GSS DNS update replies
+
+---
+ lib/dns/gssapictx.c |    5 ++++-
+ 1 files changed, 4 insertions(+), 1 deletions(-)
+
+diff --git a/lib/dns/gssapictx.c b/lib/dns/gssapictx.c
+index 879393c..69b66c5 100644
+--- a/lib/dns/gssapictx.c
++++ b/lib/dns/gssapictx.c
+@@ -536,8 +536,11 @@ dst_gssapi_initctx(dns_name_t *name, isc_buffer_t *intoken,
+		gintokenp = NULL;
+	}
+
++	/* note that we don't set GSS_C_SEQUENCE_FLAG as Windows DNS
++	 * servers don't like it
++	 */
+	flags = GSS_C_REPLAY_FLAG | GSS_C_MUTUAL_FLAG | GSS_C_DELEG_FLAG |
+-		GSS_C_SEQUENCE_FLAG | GSS_C_INTEG_FLAG;
++		GSS_C_INTEG_FLAG;
+
+	gret = gss_init_sec_context(&minor, GSS_C_NO_CREDENTIAL, gssctx,
+				    gname, GSS_SPNEGO_MECHANISM, flags,
+--
+1.6.3.3
+
diff --git a/examples/bind9-patches/README b/examples/bind9-patches/README
new file mode 100644
index 0000000..172d0e6
--- /dev/null
+++ b/examples/bind9-patches/README
@@ -0,0 +1,5 @@
+These patches fix the TSIG-GSS dynamic DNS updates in bind9 to allow
+dynamic updates to work with recent windows versions.
+
+The patches were developed against bind9 version 9.6.1, and were
+tested on Ubuntu Karmic.
diff --git a/lib/util/config.mk b/lib/util/config.mk
index b612556..7df5227 100644
--- a/lib/util/config.mk
+++ b/lib/util/config.mk
@@ -88,3 +88,8 @@ UTIL_TEVENT_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \
 PUBLIC_DEPENDENCIES = LIBLDB
 
 UTIL_LDB_OBJ_FILES = $(libutilsrcdir)/util_ldb.o
+
+[SUBSYSTEM::UTIL_RUNCMD]
+PUBLIC_DEPENDENCIES = LIBTEVENT
+
+UTIL_RUNCMD_OBJ_FILES = $(libutilsrcdir)/util_runcmd.o
diff --git a/lib/util/util.h b/lib/util/util.h
index da97761..795bd9b 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -875,5 +875,22 @@ bool add_uid_to_array_unique(TALLOC_CTX *mem_ctx, uid_t uid,
 bool add_gid_to_array_unique(TALLOC_CTX *mem_ctx, gid_t gid,
 			     gid_t **gids, size_t *num_gids);
 
+/*
+  run a command as a child process, with a timeout.
+
+  any stdout/stderr from the child will appear in the Samba logs with
+  the specified log levels
+
+  If callback is set then the callback is called on completion
+  with the return code from the command
+ */
+struct tevent_context;
+struct composite_context *samba_runcmd(struct tevent_context *ev,
+				       TALLOC_CTX *mem_ctx,
+				       struct timeval timeout,
+				       int stdout_log_level,
+				       int stderr_log_level,
+				       const char *arg0, ...);
+
 
 #endif /* _SAMBA_UTIL_H_ */
diff --git a/lib/util/util_runcmd.c b/lib/util/util_runcmd.c
new file mode 100644
index 0000000..80574c4
--- /dev/null
+++ b/lib/util/util_runcmd.c
@@ -0,0 +1,253 @@
+/*
+   Unix SMB/CIFS mplementation.
+
+   run a child command
+
+   Copyright (C) Andrew Tridgell 2010
+
+   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/>.
+
+*/
+
+/*
+  this runs a child command with stdout and stderr going to the Samba
+  log
+ */
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "lib/tevent/tevent.h"
+#include "libcli/composite/composite.h"
+
+struct samba_runcmd {
+	int stdout_log_level;
+	int stderr_log_level;
+	struct tevent_fd *fde_stdout;
+	struct tevent_fd *fde_stderr;
+	int fd_stdout, fd_stderr;
+	char *arg0;
+	pid_t pid;
+	char buf[1024];
+	uint16_t buf_used;
+};
+
+/*
+  called when a command times out
+ */
+static void runcmd_timeout(struct tevent_context *ev,
+			   struct tevent_timer *te,
+			   struct timeval current_time,
+			   void *private_data)
+{
+	struct composite_context *c = talloc_get_type_abort(private_data, struct composite_context);
+	struct samba_runcmd *r = talloc_get_type_abort(c->private_data, struct samba_runcmd);
+	kill(r->pid, SIGKILL);
+	waitpid(r->pid, NULL, 0);
+	talloc_free(r->fde_stderr);
+	talloc_free(r->fde_stdout);
+	composite_error(c, NT_STATUS_IO_TIMEOUT);
+}
+
+/*
+  handle stdout/stderr from the child
+ */
+static void runcmd_io_handler(struct tevent_context *ev,
+			      struct tevent_fd *fde,
+			      uint16_t flags,
+			      void *private_data)
+{
+	struct composite_context *c = talloc_get_type_abort(private_data, struct composite_context);
+	struct samba_runcmd *r = talloc_get_type_abort(c->private_data, struct samba_runcmd);
+	int level;
+	char *p;
+	int n, fd;
+
+	if (fde == r->fde_stdout) {
+		level = r->stdout_log_level;
+		fd = r->fd_stdout;
+	} else {
+		level = r->stderr_log_level;
+		fd = r->fd_stderr;
+	}
+
+	if (!(flags & TEVENT_FD_READ)) {
+		return;
+	}
+
+	n = read(fd, &r->buf[r->buf_used],
+		 sizeof(r->buf) - r->buf_used);
+	if (n > 0) {
+		r->buf_used += n;
+	} else if (n == 0) {
+		if (fde == r->fde_stdout) {
+			talloc_free(fde);
+			r->fde_stdout = NULL;
+		}
+		if (fde == r->fde_stderr) {
+			talloc_free(fde);
+			r->fde_stderr = NULL;
+		}
+		if (r->fde_stdout == NULL &&
+		    r->fde_stderr == NULL) {
+			int status;
+			/* the child has closed both stdout and
+			 * stderr, assume its dead */
+			pid_t pid = waitpid(r->pid, &status, 0);
+			if (pid != r->pid) {
+				DEBUG(0,("Error in waitpid() for child %s\n", r->arg0));
+				composite_error(c, map_nt_error_from_unix(errno));
+				return;
+			}
+			status = WEXITSTATUS(status);
+			DEBUG(3,("Child %s exited with status %d\n", r->arg0, status));
+			if (status == 0) {
+				composite_done(c);
+			} else {
+				composite_error(c, map_nt_error_from_unix(status));
+			}
+			return;
+		}
+		return;
+	}
+
+	while (r->buf_used > 0 &&
+	       (p = memchr(r->buf, '\n', r->buf_used)) != NULL) {
+		int n1 = (p - r->buf)+1;
+		int n2 = n1 - 1;
+		/* swallow \r from child processes */
+		if (n2 > 0 && r->buf[n2-1] == '\r') {
+			n2--;
+		}
+		DEBUG(level,("%s: %*.*s\n", r->arg0, n2, n2, r->buf));
+		memmove(r->buf, p+1, sizeof(r->buf) - n1);
+		r->buf_used -= n1;
+	}
+
+	/* the buffer could have completely filled - unfortunately we have
+	   no choice but to dump it out straight away */
+	if (r->buf_used == sizeof(r->buf)) {
+		DEBUG(level,("%s: %*.*s\n", r->arg0, r->buf_used, r->buf_used, r->buf));
+		r->buf_used = 0;
+	}
+}
+
+
+/*
+  run a command as a child process, with a timeout.
+
+  any stdout/stderr from the child will appear in the Samba logs with
+  the specified log levels
+ */
+struct composite_context *samba_runcmd(struct tevent_context *ev,
+				       TALLOC_CTX *mem_ctx,
+				       struct timeval timeout,
+				       int stdout_log_level,
+				       int stderr_log_level,
+				       const char *arg0, ...)
+{
+	struct samba_runcmd *r;
+	int p1[2], p2[2];
+	char **argv;
+	int ret;
+	va_list ap;
+	struct composite_context *c;
+
+	c = composite_create(mem_ctx, ev);
+	if (c == NULL) return NULL;
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list