diff options
author | Mattias Andrée <maandree@kth.se> | 2017-10-24 17:34:31 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2017-10-24 17:44:26 +0200 |
commit | 9f9a554afa4c23284ee624e901e5841ab6636f0d (patch) | |
tree | ec2ab72871d1b7aaace9a7956df47f2d04107f7b /sbusd.c | |
parent | Update readme (diff) | |
download | sbus-9f9a554afa4c23284ee624e901e5841ab6636f0d.tar.gz sbus-9f9a554afa4c23284ee624e901e5841ab6636f0d.tar.bz2 sbus-9f9a554afa4c23284ee624e901e5841ab6636f0d.tar.xz |
Use / instead of .
This is more like file path and allows inclusion of
package names (and file paths too if you want that
for some reason) in the routing key.
Diffstat (limited to '')
-rw-r--r-- | sbusd.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -154,10 +154,10 @@ is_subscription_match(const char *sub, const char *key) if (!*key) return !*sub; if (!*sub) - return sub == sub_start || sub[-1] == '.'; + return sub == sub_start || sub[-1] == '/'; if (*sub == '*') { sub++; - while (*key && *key != '.') + while (*key && *key != '/') key++; continue; } @@ -181,21 +181,21 @@ is_subscription_acceptable(struct client *cl, const char *key) struct ucred cred; long long int tmp; const char *p; - if (!strncmp(key, "!.cred.", sizeof("!.cred.") - 1)) { + if (!strncmp(key, "!/cred/", sizeof("!/cred/") - 1)) { if (getsockopt(cl->fd, SOL_SOCKET, SO_PEERCRED, &cred, &(socklen_t){sizeof(cred)}) < 0) { weprintf("getsockopt <client> SOL_SOCKET SO_PEERCRED:"); return -1; } errno = 0; - p = &key[sizeof("!.cred.") - 1]; + p = &key[sizeof("!/cred/") - 1]; #define TEST_CRED(ID)\ if (!*p) {\ return 0;\ - } else if (*p++ != '.') {\ + } else if (*p++ != '/') {\ if (!isdigit(*p))\ return 0;\ tmp = strtoll(p, (void *)&p, 10);\ - if (errno || (*p && *p != '.') || (ID##_t)tmp != cred.ID)\ + if (errno || (*p && *p != '/') || (ID##_t)tmp != cred.ID)\ return 0;\ } TEST_CRED(gid); @@ -273,8 +273,8 @@ send_packet(struct client *cl, const char *buf, size_t n) static void handle_cmsg(struct client *cl, const char *msg, size_t n) { - if (!strcmp(msg, "CMSG !.cred.prefix")) { - n = sizeof("CMSG !.cred.prefix"); + if (!strcmp(msg, "CMSG !/cred/prefix")) { + n = sizeof("CMSG !/cred/prefix"); } else { return; } |