[PATCH] Some cleanup patches

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Aug 20 09:42:55 MDT 2014


Hi!

Review&push would be appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From a8a56f8040a5877890d35b264da08c1ab71960b6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 19 Aug 2014 09:20:49 +0000
Subject: [PATCH 1/3] lib: Check socket length in ctdbd_connect

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/ctdbd_conn.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 3e5e838..3ba8385 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -214,6 +214,7 @@ static int ctdbd_connect(int *pfd)
 	struct sockaddr_un addr = { 0, };
 	int fd;
 	socklen_t salen;
+	size_t namelen;
 
 	fd = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (fd == -1) {
@@ -223,7 +224,14 @@ static int ctdbd_connect(int *pfd)
 	}
 
 	addr.sun_family = AF_UNIX;
-	snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", sockname);
+
+	namelen = strlcpy(addr.sun_path, sockname, sizeof(addr.sun_path));
+	if (namelen >= sizeof(addr.sun_path)) {
+		DEBUG(3, ("%s: Socket name too long: %s\n", __func__,
+			  sockname));
+		close(fd);
+		return ENAMETOOLONG;
+	}
 
 	salen = sizeof(struct sockaddr_un);
 
-- 
1.7.9.5


From 7d664d5e1492f67b7f6f086e8dc92dd2e5c5da87 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 18 Aug 2014 11:58:05 +0000
Subject: [PATCH 2/3] messaging3: Don't print a message if there's nothing to
 clean up

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/lib/messages_dgm.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index 2c43ec3..e2ee751 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -335,8 +335,10 @@ int messaging_dgm_cleanup(struct messaging_dgm_context *ctx, pid_t pid)
 	fd = open(lockfile_name, O_NONBLOCK|O_WRONLY, 0);
 	if (fd == -1) {
 		ret = errno;
-		DEBUG(10, ("%s: open(%s) failed: %s\n", __func__,
-			   lockfile_name, strerror(ret)));
+		if (ret != ENOENT) {
+			DEBUG(10, ("%s: open(%s) failed: %s\n", __func__,
+				   lockfile_name, strerror(ret)));
+		}
 		TALLOC_FREE(lockfile_name);
 		return ret;
 	}
-- 
1.7.9.5


From 0e2a964037b114510c5613dfecca2ed781ab501a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 18 Aug 2014 11:59:00 +0000
Subject: [PATCH 3/3] smbd: Only DEBUG errors from messaging_cleanup

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/server.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index bea25cb..1a0d3c9 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -421,8 +421,11 @@ static void remove_child_pid(struct smbd_parent_context *parent,
 	child_id = pid_to_procid(pid);
 
 	ret = messaging_cleanup(parent->msg_ctx, pid);
-	DEBUG(10, ("%s: messaging_cleanup returned %s\n",
-		   __func__, ret ? strerror(ret) : "ok"));
+
+	if ((ret != 0) && (ret != ENOENT)) {
+		DEBUG(10, ("%s: messaging_cleanup returned %s\n",
+			   __func__, ret ? strerror(ret) : "ok"));
+	}
 
 	for (child = parent->children; child != NULL; child = child->next) {
 		if (child->pid == pid) {
-- 
1.7.9.5



More information about the samba-technical mailing list