Repository: qpid-dispatch
Updated Branches:
  refs/heads/crolke-DISPATCH-188-1 de2ff34b1 -> 5b214a9b7


Workaround PROTON-1133: port number included in AMQP Open hostname.
Enable Proton clients up to and including 0.12.1 to work with dispatch policy.


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/5b214a9b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/5b214a9b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/5b214a9b

Branch: refs/heads/crolke-DISPATCH-188-1
Commit: 5b214a9b7dd116ff6c636186b22abe0b0c1e9a63
Parents: de2ff34
Author: Chuck Rolke <[email protected]>
Authored: Thu Mar 24 15:39:58 2016 -0400
Committer: Chuck Rolke <[email protected]>
Committed: Thu Mar 24 15:39:58 2016 -0400

----------------------------------------------------------------------
 src/policy.c                                   | 15 ++++++++++++---
 tests/policy-1/management-access.json          |  4 ++--
 tests/policy-2/test-router-with-policy.json.in |  2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/5b214a9b/src/policy.c
----------------------------------------------------------------------
diff --git a/src/policy.c b/src/policy.c
index 3094aa2..83bfca0 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -294,6 +294,15 @@ bool qd_policy_open_lookup_user(
     uint64_t    conn_id,
     qd_policy_settings_t *settings)
 {
+    // TODO: crolke 2016-03-24 - Workaround for PROTON-1133: Port number is 
included in Open hostname
+    // Strip the ':NNNN', if any, from the app name so that policy will work 
with proton 0.12
+    char appname[HOST_NAME_MAX + 1];
+    strncpy(appname, app, HOST_NAME_MAX);
+    appname[HOST_NAME_MAX] = 0;
+    char * colonp = strstr(appname, ":");
+    if (colonp) {
+        *colonp = 0;
+    }
     // Lookup the user/host/app for allow/deny and to get settings name
     bool res = false;
     qd_python_lock_state_t lock_state = qd_python_lock();
@@ -303,7 +312,7 @@ bool qd_policy_open_lookup_user(
         if (lookup_user) {
             PyObject *result = PyObject_CallFunction(lookup_user, "(OssssK)",
                                                      (PyObject 
*)policy->py_policy_manager,
-                                                     username, hostip, app, 
conn_name, conn_id);
+                                                     username, hostip, 
appname, conn_name, conn_id);
             if (result) {
                 const char *res_string = PyString_AsString(result);
                 strncpy(name_buf, res_string, name_buf_size);
@@ -335,7 +344,7 @@ bool qd_policy_open_lookup_user(
             if (lookup_settings) {
                 PyObject *result2 = PyObject_CallFunction(lookup_settings, 
"(OssO)",
                                                         (PyObject 
*)policy->py_policy_manager,
-                                                        app, name_buf, 
upolicy);
+                                                        appname, name_buf, 
upolicy);
                 if (result2) {
                     settings->maxFrameSize         = 
qd_entity_opt_long((qd_entity_t*)upolicy, "maxFrameSize", 0);
                     settings->maxMessageSize       = 
qd_entity_opt_long((qd_entity_t*)upolicy, "maxMessageSize", 0);
@@ -369,7 +378,7 @@ bool qd_policy_open_lookup_user(
     qd_log(policy->log_source, 
            POLICY_LOG_LEVEL, 
            "Policy AMQP Open lookup_user: %s, hostip: %s, app: %s, connection: 
%s. Usergroup: '%s'%s",
-           username, hostip, app, conn_name, name_buf, (res ? "" : " Internal 
error."));
+           username, hostip, appname, conn_name, name_buf, (res ? "" : " 
Internal error."));
 
     return res;
 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/5b214a9b/tests/policy-1/management-access.json
----------------------------------------------------------------------
diff --git a/tests/policy-1/management-access.json 
b/tests/policy-1/management-access.json
index 6eb2057..960c4a1 100644
--- a/tests/policy-1/management-access.json
+++ b/tests/policy-1/management-access.json
@@ -18,10 +18,10 @@
 ##
 
 # A policy to allow unrestricted access to management
-# through port 22000
+# from host 0.0.0.0
 [
   ["policyRuleset", {
-      "applicationName": "0.0.0.0:22000",
+      "applicationName": "0.0.0.0",
       "maxConnections": 50,
       "maxConnPerUser": 5,
       "maxConnPerHost": 20,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/5b214a9b/tests/policy-2/test-router-with-policy.json.in
----------------------------------------------------------------------
diff --git a/tests/policy-2/test-router-with-policy.json.in 
b/tests/policy-2/test-router-with-policy.json.in
index e28d75c..5f96fdf 100644
--- a/tests/policy-2/test-router-with-policy.json.in
+++ b/tests/policy-2/test-router-with-policy.json.in
@@ -146,7 +146,7 @@
       }
   }],
   ["policyRuleset", {
-      "applicationName": "0.0.0.0:21000",
+      "applicationName": "0.0.0.0",
       "maxConnections": 50,
       "maxConnPerUser": 5,
       "maxConnPerHost": 20,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to