agent-at: Move field separator from : to ; 78/23278/1 8.99.3 icefish/8.99.3 icefish_8.99.3
authorJose Bollo <jose.bollo@iot.bzh>
Fri, 6 Dec 2019 14:12:36 +0000 (15:12 +0100)
committerJose Bollo <jose.bollo@iot.bzh>
Fri, 6 Dec 2019 14:18:48 +0000 (15:18 +0100)
Because Smack labels and permissions of AGL
all contain the character colon (:), it is better
have a distinct field separator for agent-at.

Bug-AGL: SPEC-2968

Change-Id: I378eefcd7b29e424acccced62abe48b35ad8736e
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
agent.md
cynagora.initial
src/agent-at.c

index 4e19d45..0f3e07f 100644 (file)
--- a/agent.md
+++ b/agent.md
@@ -32,7 +32,7 @@ The file `cynagora.initial` that provides a default initialisation file
 has the following lines:
 
        *  *  @ADMIN  *  yes                forever
-       *  *  0       *  @:%c:%s:@ADMIN:%p  forever
+       *  *  0       *  @:%c;%s;@ADMIN;%p  forever
 
 The first line defines a special user `@ADMIN` that always has the permission.
 The special user can be seen as a group: the admin group. Remember that strings
@@ -44,15 +44,15 @@ admin. To achieve that it uses the agent-AT mecanism.
 
 So if no other rule was selected for the user `0` then cynagora find at least
 the rule that requires to query the predefined agent `@` (AT) with the value
-`%c:%s:@ADMIN:%p`.
+`%c;%s;@ADMIN;%p`.
 
 The agent is asked with the following values:
 
-  - `%c:%s:@ADMIN:%p`  the value
+  - `%c;%s;@ADMIN;%p`  the value
   - `CLIENT`, `SESSION`, `USER` and `PERMISSION`, the values of original request
 
-The AT-agent use the value `%c:%s:@ADMIN:%p` to compose a check query.
-it interpret the value as a colon separated rule query of cynagora, in the
+The AT-agent use the value `%c;%s;@ADMIN;%p` to compose a check query.
+it interpret the value as a semi-colon separated rule query of cynagora, in the
 order: client, session, user, permission. Then it replaces any occurency of:
 
   - `%c` with value of `CLIENT` of original request
@@ -60,7 +60,7 @@ order: client, session, user, permission. Then it replaces any occurency of:
   - `%u` with value of `USER` of original request
   - `%p` with value of `PERMISSION` of original request
   - `%%` with `%`
-  - `%:` with `:`
+  - `%;` with `;`
 
 So for the given value, the result at the end is the result of querying
 cynagora for the result of:
@@ -73,5 +73,3 @@ cynagora for the result of:
 The query to cynagora with CLIENT SESSION @ADMIN PERMMISSION must be done using
 sub-query of agents.
 
-
-
index c0430cd..a8a4a2e 100644 (file)
@@ -10,6 +10,6 @@
 #--------------------------------------------------------------------
 # User "0" and clients "System" is in the group "@ADMIN"
 #--------------------------------------------------------------------
-*      * 0 * @:%c:%s:@ADMIN:%p forever
-System * * * @:%c:%s:@ADMIN:%p forever
+*      * 0 * @:%c;%s;@ADMIN;%p forever
+System * * * @:%c;%s;@ADMIN;%p forever
 
index 89e78d3..f0731f3 100644 (file)
@@ -29,6 +29,9 @@
 #include "data.h"
 #include "cyn.h"
 
+static const char separator = ';';
+static const char escape = '%';
+
 /**
  * Parse the spec to extract the derived key to ask.
  *
@@ -58,12 +61,12 @@ parse(
                /* compute value of the derived field */
                inf = iout;
                while(*spec) {
-                       if (*spec == ':' && ikey < 3) {
+                       if (*spec == separator && ikey < 3) {
                                /* : is the separator of key's items */
                                spec++;
                                break; /* next key */
                        }
-                       if (!(*spec == '%' && spec[1])) {
+                       if (!(*spec == escape && spec[1])) {
                                /* not a % substitution mark */
                                if (iout < szbuf)
                                        buffer[iout] = *spec;
@@ -95,10 +98,10 @@ parse(
                                }
                                if (!sub) {
                                        /* no substitution */
-                                       if (spec[1] != ':' && spec[1] != '%') {
+                                       if (spec[1] != separator && spec[1] != escape) {
                                                /* only escape % and : */
                                                if (iout < szbuf)
-                                                       buffer[iout] = '%';
+                                                       buffer[iout] = escape;
                                                iout++;
                                        }
                                        if (iout < szbuf)