[PATCH] make smbcontrol smbd ping work proper checking for arguments

Olaf Flebbe flebbe at nix.science-computing.de
Thu Aug 20 05:49:55 MDT 2009


---
 source/lib/util.c         |   17 +++++++++++------
 source/utils/smbcontrol.c |   19 +++++++------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/source/lib/util.c b/source/lib/util.c
index e3a346b..ffa4684 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -3070,14 +3070,15 @@ bool procid_is_me(const struct server_id *pid)
 
 struct server_id interpret_pid(const char *pid_string)
 {
+  	struct server_id result;
 #ifdef CLUSTER_SUPPORT
-	unsigned int vnn, pid;
-	struct server_id result;
-	if (sscanf(pid_string, "%u:%u", &vnn, &pid) == 2) {
+	pid_t pid;
+	unsigned int vnn;
+	if (sscanf(pid_string, "%u:%d", &vnn, &pid) == 2) {
 		result.vnn = vnn;
 		result.pid = pid;
 	}
-	else if (sscanf(pid_string, "%u", &pid) == 1) {
+	else if (sscanf(pid_string, "%d", &pid) == 1) {
 		result.vnn = NONCLUSTER_VNN;
 		result.pid = pid;
 	}
@@ -3085,10 +3086,14 @@ struct server_id interpret_pid(const char *pid_string)
 		result.vnn = NONCLUSTER_VNN;
 		result.pid = -1;
 	}
-	return result;
 #else
-	return pid_to_procid(atoi(pid_string));
+	if (sscanf(pid_string, "%d", &result.pid) != 1)
+	  result.pid = -1;
 #endif
+	/* Map negative pid to -1: i.e. error */
+	if (result.pid < 0)
+	  result.pid = -1;
+	return result;
 }
 
 char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid)
diff --git a/source/utils/smbcontrol.c b/source/utils/smbcontrol.c
index db2eefe..05fa2eb 100644
--- a/source/utils/smbcontrol.c
+++ b/source/utils/smbcontrol.c
@@ -1242,9 +1242,9 @@ static struct server_id parse_dest(const char *dest)
 	struct server_id result = {-1};
 	pid_t pid;
 
-	/* Zero is a special return value for broadcast smbd */
+	/* Zero is a special return value for broadcast */
 
-	if (strequal(dest, "smbd")) {
+	if (strequal(dest, "all")) {
 		return interpret_pid(MSG_BROADCAST_PID_STR);
 	}
 
@@ -1259,18 +1259,13 @@ static struct server_id parse_dest(const char *dest)
 		dest = "winbindd";
 	}
 
-	
-	if (!(strequal(dest, "winbindd") || strequal(dest, "nmbd"))) {
-		/* Check for numeric pid number */
-
-		result = interpret_pid(dest);
+	/* Check for numeric pid number */
+	result = interpret_pid(dest);
 
-		/* Zero isn't valid if not smbd. */
-		if (result.pid && procid_valid(&result)) {
-			return result;
-		}
+	/* Zero isn't valid if not "all". */
+	if (result.pid && procid_valid(&result)) {
+		return result;
 	}
-
 	/* Look up other destinations in pidfile directory */
 
 	if ((pid = pidfile_pid(dest)) != 0) {
-- 
1.6.0.2


--------------080404040702030509040506
Content-Type: text/x-vcard; charset=utf-8;
 name="o_flebbe.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="o_flebbe.vcf"

begin:vcard
fn:Olaf Flebbe
n:Flebbe;Olaf
org;quoted-printable:science+computing ag;IT Services T=C3=BCbingen
adr;quoted-printable:;;Hagellocher Weg 73;T=C3=BCbingen;;72070;Germany
email;internet:o.flebbe at science-computing.de
title:Chief Software Architect
tel;work:+49 7071 9457 254
tel;fax:+49 7071 9457 511
x-mozilla-html:FALSE
url:http://www.science-computing.de
version:2.1
end:vcard


--------------080404040702030509040506--




More information about the samba-technical mailing list