[SCM] Samba Shared Repository - branch v4-4-stable updated

Karolin Seeger kseeger at samba.org
Wed Oct 26 07:14:56 UTC 2016


The branch, v4-4-stable has been updated
       via  b2d2088 VERSION: Disable git snapshots for the 4.4.7 release.
       via  e0ebfb9 WHATSNEW: Add release notes for Samba 4.4.7.
       via  5a0b28a lib: Fix bug 12291
       via  46780e3 s3:libads: don't use MEMORY:ads_sasl_spnego_bind nor set "KRB5CCNAME"
       via  f2a0f86 s3:libads: don't use MEMORY:ads_sasl_gssapi_do_bind nor set "KRB5CCNAME"
       via  3b98cde HEIMDAL:lib/krb5: destroy a memory ccache on reinit
       via  60ffbab s3-printing: fix migrate printer code (bug 8618)
       via  cc3b76b s3: cldap: cldap_multi_netlogon_send() fails with one bad IPv6 address.
       via  9ecc6ac s3-utils: Fix loading smb.conf in smbcquotas
       via  ab1c3d4 ctdb-scripts: Fix incorrect variable reference
       via  bf7e0fb ctdb-scripts: Avoid dividing by zero in memory calculation
       via  0fcbce8 s3/winbindd: using default domain with user at domain.com format fails
       via  0790769 Add a blackbox tests for id & getent to test domain at realm type credentials
       via  6e12cac s3-lib: Fix %G substitution in AD member environment
       via  dba617a torture/ioctl: test compression responses when unsupported
       via  3af480f smbd/ioctl: match WS2016 ReFS get compression behaviour
       via  15a8ee6 vfs_glusterfs: Fix a memory leak in connect path
       via  17e61a1 spoolss: Fix caching of printername->sharename
       via  49d4c63 s4:samba_spnupdate: do not attempt to parse log level, use parsed value
       via  4c54612 python/join: do not attempt to parse log level, use parsed value
       via  430e9d2 python/drs_utils: do not attempt to parse log level, use parsed value
       via  4fe66b5 tests/param add a test for LoadParm.log_level
       via  cfa3e0f s4:param add log_level function to retrieve log level in Python code
       via  ad96251 glusterfs: Avoid tevent_internal.h
       via  3170f53 s3: events. Move events.c to util_event.c
       via  fc82907 s3: server: s3_tevent_context_init() -> samba_tevent_context_init()
       via  a60c9ce s3: winbind: Remove dump_event_list() calls.
       via  ed6b8bc s3: nmbd: Final changeover to stock tevent for nmbd.
       via  95401c5 s3: nmbd: Change over to using tevent functions from direct poll.
       via  e9cf61d s3: nmbd: Add a talloc_stackframe().
       via  f8d8ed5 s3: nmbd: Add (currently unused) timeout and fd handlers.
       via  1ccbb07 s3: nmbd: Now attrs array mirrors fd's array use it in preference.
       via  b8ae31c s3: nmbd: Ensure attrs array mirrors fd's array for dns.
       via  5d160ee s3: nmbd: Add fd, triggered elements to struct socket_attributes.
       via  e4c48c9 s3:nmbd: fix talloc_zero_array() check in nmbd_packets.c
       via  257644f s3: winbind: Ensure we store name2sid with the correct cache sequence number.
       via  47ab4a0 s3: winbind: Trust name2sid mappings from the PAC.
       via  1d28a24 s3: winbind: refresh_sequence_number is only ever called with 'false'.
       via  275ae03 s3: auth: Use wbcAuthenticateUserEx to prime the caches.
       via  2dfbdc5 s3: winbind: Make WBC_AUTH_USER_LEVEL_PAC prime the name2sid cache.
       via  ba1356d ctdb-scripts: ctdbd_wrapper should never remove the PID file
       via  0708007 Merge tag 'samba-4.4.6' into v4-4-test
       via  816c764 ctdb-daemon: Log when removing stale Unix domain socket
       via  c3bddc1 ctdb-daemon: Drop attempt to connect to Unix domain socket
       via  1c13a4c ctdb-daemon: Don't try to reopen TDB files
       via  87632d2 ctdb-daemon: Bind to Unix domain socket after PID file creation
       via  df236e0 ctdb-daemon: Use PID file abstraction
       via  a6a439c ctdb-common: Add routines to manage PID file
       via  514e6c7 s3-spoolss: fix winreg_printer_ver_to_qword
       via  368170c nsswitch: Also set h_errnop for nss_wins functions
       via  c849e59 nsswitch: Add missing arguments to wins gethostbyname*
       via  01fa691 s3/smbd: set FILE_ATTRIBUTE_DIRECTORY as necessary
       via  5793362 gencache: Bail out of stabilize if we can not get the allrecord lock
       via  d1d5716 VERSION: VERSION: Bump version up to 4.4.7...
      from  99ced63 Revert "script/release.sh: use 8 byte gpg key ids"

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-4-stable


- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 VERSION                                         |   2 +-
 WHATSNEW.txt                                    | 105 ++++-
 ctdb/common/pidfile.c                           | 143 +++++++
 ctdb/common/pidfile.h                           |  51 +++
 ctdb/config/ctdbd_wrapper                       |   1 -
 ctdb/config/events.d/05.system                  |   6 +-
 ctdb/server/ctdb_daemon.c                       |  67 ++--
 ctdb/tests/cunit/pidfile_test_001.sh            |   8 +
 ctdb/tests/src/ctdbd_test.c                     |   1 +
 ctdb/tests/src/pidfile_test.c                   | 241 ++++++++++++
 ctdb/wscript                                    |   3 +-
 libcli/cldap/cldap.c                            |   5 +
 nsswitch/wins.c                                 |  60 ++-
 python/samba/drs_utils.py                       |   2 +-
 python/samba/join.py                            |   4 +-
 python/samba/tests/param.py                     |   6 +
 script/release.sh                               |  12 +-
 selftest/knownfail                              |   1 +
 selftest/target/Samba.pm                        |   1 +
 selftest/target/Samba4.pm                       |  36 +-
 source3/auth/auth_generic.c                     |  49 ++-
 source3/include/includes.h                      |   4 +-
 source3/include/{event.h => util_event.h}       |  16 +-
 source3/lib/events.c                            | 486 ------------------------
 source3/lib/gencache.c                          |   2 +-
 source3/lib/msghdr.c                            |   2 +-
 source3/lib/server_contexts.c                   |   2 +-
 source3/lib/substitute.c                        |  24 +-
 source3/lib/util_event.c                        | 101 +++++
 source3/libads/cldap.c                          |  17 +-
 source3/libads/sasl.c                           |  11 -
 source3/modules/vfs_glusterfs.c                 |   4 +-
 source3/nmbd/nmbd_packets.c                     | 162 +++++---
 source3/printing/nt_printing_migrate.c          |  27 ++
 source3/rpc_client/cli_winreg_spoolss.c         |   7 +-
 source3/rpc_server/rpc_ncacn_np.c               |   8 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c     |   4 +-
 source3/smbd/dosmode.c                          |   6 +-
 source3/smbd/process.c                          |   4 +-
 source3/smbd/server.c                           |   1 -
 source3/smbd/smb2_ioctl_filesys.c               |  29 +-
 source3/utils/smbcquotas.c                      |  15 +-
 source3/winbindd/winbindd_cache.c               |  62 ++-
 source3/winbindd/winbindd_dual.c                |   5 +-
 source3/winbindd/winbindd_pam.c                 |  35 +-
 source3/winbindd/winbindd_proto.h               |   5 +
 source3/winbindd/winbindd_util.c                |   5 +-
 source3/wscript_build                           |   2 +-
 source4/heimdal/lib/krb5/mcache.c               |  52 ++-
 source4/param/pyparam.c                         |   9 +
 source4/scripting/bin/samba_spnupdate           |   2 +-
 source4/selftest/tests.py                       |   7 +
 source4/torture/smb2/ioctl.c                    |  76 ++++
 testprogs/blackbox/{nsstest.sh => dom_parse.sh} |  13 +-
 54 files changed, 1270 insertions(+), 739 deletions(-)
 create mode 100644 ctdb/common/pidfile.c
 create mode 100644 ctdb/common/pidfile.h
 create mode 100755 ctdb/tests/cunit/pidfile_test_001.sh
 create mode 100644 ctdb/tests/src/pidfile_test.c
 rename source3/include/{event.h => util_event.h} (64%)
 delete mode 100644 source3/lib/events.c
 create mode 100644 source3/lib/util_event.c
 copy testprogs/blackbox/{nsstest.sh => dom_parse.sh} (56%)


Changeset truncated at 500 lines:

diff --git a/VERSION b/VERSION
index c75e0f9..0770a98 100644
--- a/VERSION
+++ b/VERSION
@@ -25,7 +25,7 @@
 ########################################################
 SAMBA_VERSION_MAJOR=4
 SAMBA_VERSION_MINOR=4
-SAMBA_VERSION_RELEASE=6
+SAMBA_VERSION_RELEASE=7
 
 ########################################################
 # If a official release has a serious bug              #
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 7970201..7268196 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,4 +1,105 @@
                    =============================
+                   Release Notes for Samba 4.4.7
+                         October 26, 2016
+                   =============================
+
+
+This is the latest stable release of Samba 4.4.
+
+Major enhancements in Samba 4.4.7 include:
+
+o  Let winbindd discard expired kerberos tickets when built against
+   (internal) heimdal (BUG #12369).
+o  REGRESSION: smbd segfaults on startup, tevent context being freed
+   (BUG #12283).
+
+
+Changes since 4.4.6:
+--------------------
+
+o  Jeremy Allison <jra at samba.org>
+   * BUG 11259: smbd contacts a domain controller for each session.
+   * BUG 12283: REGRESSION: smbd segfaults on startup, tevent context being
+     freed.
+   * BUG 12291: source3/lib/msghdr: Fix syntax error before or at: ;.
+   * BUG 12381: s3: cldap: cldap_multi_netlogon_send() fails with one bad IPv6
+     address.
+
+o  Christian Ambach <ambi at samba.org>
+   * BUG 9945: Setting specific logger levels in smb.conf makes 'samba-tool drs
+     showrepl' crash.
+
+o  Björn Baumbach <bb at sernet.de>
+   * BUG 8618: s3-printing: Fix migrate printer code.
+
+o  Ralph Boehme <slow at samba.org>
+   * BUG 12261: s3/smbd: Set FILE_ATTRIBUTE_DIRECTORY as necessary.
+
+o  Günther Deschner <gd at samba.org>
+   * BUG 12285: "DriverVersion" registry backend parsing incorrect in spoolss.
+
+o  David Disseldorp <ddiss at samba.org>
+   * BUG 12144: smbd/ioctl: Match WS2016 ReFS get compression behaviour.
+
+o  Amitay Isaacs <amitay at gmail.com>
+   * BUG 12287: CTDB PID file handling is too weak.
+
+o  Volker Lendecke <vl at samba.org>
+   * BUG 12045: gencache: Bail out of stabilize if we can not get the allrecord
+     lock.
+   * BUG 12283: glusterfs: Avoid tevent_internal.h.
+   * BUG 12374: spoolss: Fix caching of printername->sharename.
+
+o  Stefan Metzmacher <metze at samba.org>
+   * BUG 12283: REGRESSION: smbd segfaults on startup, tevent context being
+     freed.
+   * BUG 12369: Let winbindd discard expired kerberos tickets when built against
+     (internal) heimdal.
+
+o  Noel Power <noel.power at suse.com>
+   * BUG 12298: s3/winbindd: Using default domain with user at domain.com format
+     fails.
+
+o  Jose A. Rivera <jarrpa at samba.org>
+   * BUG 12362: ctdb-scripts: Avoid dividing by zero in memory calculation.
+
+o  Anoop C S <anoopcs at redhat.com>
+   * BUG 12377: vfs_glusterfs: Fix a memory leak in connect path.
+
+o  Andreas Schneider <asn at samba.org>
+   * BUG 12269: nss_wins has incorrect function definitions for gethostbyname*.
+   * BUG 12276: s3-lib: Fix %G substitution in AD member environment.
+   * BUG 12364: s3-utils: Fix loading smb.conf in smbcquotas.
+
+o  Martin Schwenke <martin at meltin.net>
+   * BUG 12287: CTDB PID file handling is too weak.
+   * BUG 12362: ctdb-scripts: Fix incorrect variable reference.
+
+
+#######################################
+Reporting bugs & Development Discussion
+#######################################
+
+Please discuss this release on the samba-technical mailing list or by
+joining the #samba-technical IRC channel on irc.freenode.net.
+
+If you do report problems then please try to send high quality
+feedback. If you don't provide vital information to help us track down
+the problem then you will probably be ignored.  All bug reports should
+be filed under the "Samba 4.1 and newer" product in the project's Bugzilla
+database (https://bugzilla.samba.org/).
+
+
+======================================================================
+== Our Code, Our Bugs, Our Responsibility.
+== The Samba Team
+======================================================================
+
+
+Release notes for older releases follow:
+----------------------------------------
+
+                   =============================
                    Release Notes for Samba 4.4.6
                         September 22, 2016
                    =============================
@@ -142,8 +243,8 @@ database (https://bugzilla.samba.org/).
 ======================================================================
 
 
-Release notes for older releases follow:
-----------------------------------------
+----------------------------------------------------------------------
+
 
                    =============================
                    Release Notes for Samba 4.4.5
diff --git a/ctdb/common/pidfile.c b/ctdb/common/pidfile.c
new file mode 100644
index 0000000..b3f29e3
--- /dev/null
+++ b/ctdb/common/pidfile.c
@@ -0,0 +1,143 @@
+/*
+   Create and remove pidfile
+
+   Copyright (C) Amitay Isaacs  2016
+
+   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 "replace.h"
+#include "system/filesys.h"
+
+#include <talloc.h>
+
+#include "common/pidfile.h"
+
+struct pidfile_context {
+	const char *pidfile;
+	int fd;
+	pid_t pid;
+};
+
+static int pidfile_context_destructor(struct pidfile_context *pid_ctx);
+
+int pidfile_create(TALLOC_CTX *mem_ctx, const char *pidfile,
+		   struct pidfile_context **result)
+{
+	struct pidfile_context *pid_ctx;
+	struct flock lck;
+	char tmp[64];
+	int fd, ret = 0;
+	int len;
+	ssize_t nwritten;
+
+	pid_ctx = talloc_zero(mem_ctx, struct pidfile_context);
+	if (pid_ctx == NULL) {
+		return ENOMEM;
+	}
+
+	pid_ctx->pidfile = talloc_strdup(pid_ctx, pidfile);
+	if (pid_ctx->pidfile == NULL) {
+		ret = ENOMEM;
+		goto fail;
+	}
+
+	pid_ctx->pid = getpid();
+
+	fd = open(pidfile, O_CREAT|O_WRONLY|O_NONBLOCK, 0644);
+	if (fd == -1) {
+		ret = errno;
+		goto fail;
+	}
+
+	pid_ctx->fd = fd;
+
+	lck = (struct flock) {
+		.l_type = F_WRLCK,
+		.l_whence = SEEK_SET,
+	};
+
+	do {
+		ret = fcntl(fd, F_SETLK, &lck);
+	} while ((ret == -1) && (errno == EINTR));
+
+	if (ret != 0) {
+		ret = errno;
+		goto fail;
+	}
+
+	do {
+		ret = ftruncate(fd, 0);
+	} while ((ret == -1) && (errno == EINTR));
+
+	if (ret == -1) {
+		ret = EIO;
+		goto fail_unlink;
+	}
+
+	len = snprintf(tmp, sizeof(tmp), "%u\n", pid_ctx->pid);
+	if (len < 0) {
+		ret = EIO;
+		goto fail_unlink;
+	}
+
+	do {
+		nwritten = write(fd, tmp, len);
+	} while ((nwritten == -1) && (errno == EINTR));
+
+	if ((nwritten == -1) || (nwritten != len)) {
+		ret = EIO;
+		goto fail_unlink;
+	}
+
+	talloc_set_destructor(pid_ctx, pidfile_context_destructor);
+
+	*result = pid_ctx;
+	return 0;
+
+fail_unlink:
+	unlink(pidfile);
+	close(fd);
+
+fail:
+	talloc_free(pid_ctx);
+	return ret;
+}
+
+static int pidfile_context_destructor(struct pidfile_context *pid_ctx)
+{
+	struct flock lck;
+	int ret;
+
+	if (getpid() != pid_ctx->pid) {
+		return 0;
+	}
+
+	lck = (struct flock) {
+		.l_type = F_UNLCK,
+		.l_whence = SEEK_SET,
+	};
+
+	(void) unlink(pid_ctx->pidfile);
+
+	do {
+		ret = fcntl(pid_ctx->fd, F_SETLK, &lck);
+	} while ((ret == -1) && (errno == EINTR));
+
+	do {
+		ret = close(pid_ctx->fd);
+	} while ((ret == -1) && (errno == EINTR));
+
+	return 0;
+}
diff --git a/ctdb/common/pidfile.h b/ctdb/common/pidfile.h
new file mode 100644
index 0000000..1450134
--- /dev/null
+++ b/ctdb/common/pidfile.h
@@ -0,0 +1,51 @@
+/*
+   Create and remove pidfile
+
+   Copyright (C) Amitay Isaacs  2016
+
+   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 __CTDB_PIDFILE_H__
+#define __CTDB_PIDFILE_H__
+
+#include <talloc.h>
+
+/**
+ * @file pidfile.h
+ *
+ * @brief Routines to manage PID file
+ */
+
+/**
+ * @brief Abstract struct to store pidfile details
+ */
+struct pidfile_context;
+
+/**
+ * @brief Create a PID file
+ *
+ * This creates a PID file, locks it, and writes PID.
+ *
+ * @param[in] mem_ctx Talloc memory context
+ * @param[in] pidfile Path of PID file
+ * @param[out] result Pidfile context
+ * @return 0 on success, errno on failure
+ *
+ * Freeing the pidfile_context, will delete the pidfile.
+ */
+int pidfile_create(TALLOC_CTX *mem_ctx, const char *pidfile,
+		   struct pidfile_context **result);
+
+#endif /* __CTDB_PIDFILE_H__ */
diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index be251e6..7d4304a 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -181,7 +181,6 @@ kill_ctdbd ()
 
     if [ -n "$_session" ] ; then
 	pkill -9 -s "$_session" 2>/dev/null
-	rm -f "$pidfile"
     fi
 }
 
diff --git a/ctdb/config/events.d/05.system b/ctdb/config/events.d/05.system
index 69fcec2..603f941 100755
--- a/ctdb/config/events.d/05.system
+++ b/ctdb/config/events.d/05.system
@@ -47,7 +47,7 @@ check_thresholds ()
         fi
     fi
 
-    if validate_percentage "$_warn_threshold" "$_what" ; then
+    if validate_percentage "$_warn_threshold" "$_thing" ; then
         if [ "$_usage" -ge "$_warn_threshold" ] ; then
 	    if [ -r "$_cache" ] ; then
 		read _prev <"$_cache"
@@ -144,8 +144,8 @@ $1 == "SwapFree:"     { swapfree  = $2 }
 $1 == "SwapTotal:"    { swaptotal = $2 }
 END {
     if (memavail != 0) { memfree = memavail ; }
-    print int((memtotal -  memfree)  / memtotal * 100),
-          int((swaptotal - swapfree) / swaptotal * 100)
+    if (memtotal != 0) { print int((memtotal - memfree) / memtotal * 100) ; } else { print 0 ; }
+    if (swaptotal != 0) { print int((swaptotal - swapfree) / swaptotal * 100) ; } else { print 0 ; }
 }')
     _mem_usage="$1"
     _swap_usage="$2"
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 1fe792c..1cc74a0 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -43,6 +43,7 @@
 #include "common/system.h"
 #include "common/common.h"
 #include "common/logging.h"
+#include "common/pidfile.h"
 
 struct ctdb_client_pid_list {
 	struct ctdb_client_pid_list *next, *prev;
@@ -52,6 +53,7 @@ struct ctdb_client_pid_list {
 };
 
 const char *ctdbd_pidfile = NULL;
+static struct pidfile_context *ctdbd_pidfile_ctx = NULL;
 
 static void daemon_incoming_packet(void *, struct ctdb_req_header *);
 
@@ -983,6 +985,7 @@ static void ctdb_accept_client(struct tevent_context *ev,
 static int ux_socket_bind(struct ctdb_context *ctdb)
 {
 	struct sockaddr_un addr;
+	int ret;
 
 	ctdb->daemon.sd = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (ctdb->daemon.sd == -1) {
@@ -993,17 +996,16 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
 	addr.sun_family = AF_UNIX;
 	strncpy(addr.sun_path, ctdb->daemon.name, sizeof(addr.sun_path)-1);
 
-	/* First check if an old ctdbd might be running */
-	if (connect(ctdb->daemon.sd,
-		    (struct sockaddr *)&addr, sizeof(addr)) == 0) {
-		DEBUG(DEBUG_CRIT,
-		      ("Something is already listening on ctdb socket '%s'\n",
-		       ctdb->daemon.name));
-		goto failed;
-	}
-
 	/* Remove any old socket */
-	unlink(ctdb->daemon.name);
+	ret = unlink(ctdb->daemon.name);
+	if (ret == 0) {
+		DEBUG(DEBUG_WARNING,
+		      ("Removed stale socket %s\n", ctdb->daemon.name));
+	} else if (errno != ENOENT) {
+		DEBUG(DEBUG_ERR,
+		      ("Failed to remove stale socket %s\n", ctdb->daemon.name));
+		return -1;
+	}
 
 	set_close_on_exec(ctdb->daemon.sd);
 	set_nonblocking(ctdb->daemon.sd);
@@ -1127,32 +1129,21 @@ static void ctdb_tevent_trace(enum tevent_trace_point tp,
 
 static void ctdb_remove_pidfile(void)
 {
-	/* Only the main ctdbd's PID matches the SID */
-	if (ctdbd_pidfile != NULL && getsid(0) == getpid()) {
-		if (unlink(ctdbd_pidfile) == 0) {
-			DEBUG(DEBUG_NOTICE, ("Removed PID file %s\n",
-					     ctdbd_pidfile));
-		} else {
-			DEBUG(DEBUG_WARNING, ("Failed to Remove PID file %s\n",
-					      ctdbd_pidfile));
-		}
-	}
+	TALLOC_FREE(ctdbd_pidfile_ctx);
 }
 
-static void ctdb_create_pidfile(pid_t pid)
+static void ctdb_create_pidfile(TALLOC_CTX *mem_ctx)
 {
 	if (ctdbd_pidfile != NULL) {
-		FILE *fp;
-
-		fp = fopen(ctdbd_pidfile, "w");
-		if (fp == NULL) {
-			DEBUG(DEBUG_ALERT,
-			      ("Failed to open PID file %s\n", ctdbd_pidfile));
+		int ret = pidfile_create(mem_ctx, ctdbd_pidfile,
+					 &ctdbd_pidfile_ctx);
+		if (ret != 0) {
+			DEBUG(DEBUG_ERR,
+			      ("Failed to create PID file %s\n",
+			       ctdbd_pidfile));
 			exit(11);
 		}
 
-		fprintf(fp, "%d\n", pid);
-		fclose(fp);
 		DEBUG(DEBUG_NOTICE, ("Created PID file %s\n", ctdbd_pidfile));
 		atexit(ctdb_remove_pidfile);
 	}
@@ -1214,19 +1205,10 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 	int res, ret = -1;
 	struct tevent_fd *fde;
 
-	/* create a unix domain stream socket to listen to */
-	res = ux_socket_bind(ctdb);
-	if (res!=0) {
-		DEBUG(DEBUG_ALERT,("Cannot continue.  Exiting!\n"));
-		exit(10);
-	}
-
 	if (do_fork && fork()) {
 		return 0;
 	}
 
-	tdb_reopen_all(false);
-
 	if (do_fork) {
 		if (setsid() == -1) {
 			ctdb_die(ctdb, "Failed to setsid()\n");
@@ -1243,7 +1225,14 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 	ctdb->ctdbd_pid = getpid();
 	DEBUG(DEBUG_ERR, ("Starting CTDBD (Version %s) as PID: %u\n",
 			  CTDB_VERSION_STRING, ctdb->ctdbd_pid));
-	ctdb_create_pidfile(ctdb->ctdbd_pid);
+	ctdb_create_pidfile(ctdb);
+
+	/* create a unix domain stream socket to listen to */


-- 
Samba Shared Repository



More information about the samba-cvs mailing list