summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorOlaf Flebbe <flebbe@nix.science-computing.de>2009-08-17 17:31:01 +0200
committerVolker Lendecke <vl@samba.org>2009-08-24 16:17:43 +0200
commit5359e397ff190c35414f6961be61a5110e237dd5 (patch)
tree9949ab09ebbf91738a3c20f4543d252b1de04725 /source3
parentb1ee4c14d49aa2dc0df90694d7403620951de137 (diff)
downloadsamba-5359e397ff190c35414f6961be61a5110e237dd5.tar.gz
samba-5359e397ff190c35414f6961be61a5110e237dd5.tar.bz2
samba-5359e397ff190c35414f6961be61a5110e237dd5.zip
make smbcontrol smbd ping work proper checking for arguments handle short pid_t correctly
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util.c22
-rw-r--r--source3/utils/smbcontrol.c13
2 files changed, 21 insertions, 14 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 835e4c00da..74b792180a 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2692,14 +2692,15 @@ bool procid_is_me(const struct server_id *pid)
struct server_id interpret_pid(const char *pid_string)
{
-#ifdef CLUSTER_SUPPORT
- unsigned int vnn, pid;
struct server_id result;
- if (sscanf(pid_string, "%u:%u", &vnn, &pid) == 2) {
+ int pid;
+#ifdef CLUSTER_SUPPORT
+ 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 = get_my_vnn();
result.pid = pid;
}
@@ -2707,10 +2708,19 @@ 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", &pid) != 1) {
+ result.pid = -1;
+ } else {
+ result.pid = pid;
+ }
#endif
+ /* Assigning to result.pid may have overflowed
+ 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/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index fc7d0aa360..7fab6eb4b2 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1247,15 +1247,12 @@ static struct server_id parse_dest(const char *dest)
dest = "winbindd";
}
- if (!(strequal(dest, "winbindd") || strequal(dest, "nmbd"))) {
- /* Check for numeric pid number */
+ /* Check for numeric pid number */
+ result = interpret_pid(dest);
- 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 */