aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-02-22 14:50:58 +0100
committerMattias Andrée <m@maandree.se>2026-02-22 14:51:04 +0100
commiteb9e314611b33c67add6bb2725efd5b3f27f775a (patch)
treea59a23c3c43ebba97d6b308b3ac4904c80c1d516
parentUpdate e-mail (diff)
downloadsbus-eb9e314611b33c67add6bb2725efd5b3f27f775a.tar.gz
sbus-eb9e314611b33c67add6bb2725efd5b3f27f775a.tar.bz2
sbus-eb9e314611b33c67add6bb2725efd5b3f27f775a.tar.xz
misc fixesHEADmaster
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--README46
-rw-r--r--config.mk6
-rw-r--r--libsbus.c2
3 files changed, 28 insertions, 26 deletions
diff --git a/README b/README
index 5703c46..700211f 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-sbus is simple message bus based on unix domain, sequenced-packet sockets.
+sbus is a simple message bus based on unix domain, sequenced-packet sockets.
Features:
Support for multi-user buses.
@@ -23,14 +23,14 @@ Non-features:
implemented as a separate service or at application level.
No support for server-verified credentials, can be implemented at
application level by using '!/cred/' routing keys.
- No acknowledgement of when messages have been processes, can be
+ No acknowledgement of when messages have been processed, can be
implemented at application level by sending yourself a message
and wait for it to return.
No remote procedure call support.
Routing keys:
Routing keys are used to filter received messages. A routing key
- may contain any byte other than the NUL, whoever there are three
+ may contain any byte other than the NUL, however there are three
bytes with special meaning: '*', '/', and '!'. '*' should not be
in routing keys, but only in routing key patterns, it matches until
the next '/' or end if there are not more '/'s. Additionally if a
@@ -44,9 +44,9 @@ Routing keys:
way or simply ignore such messages.
Protocol:
- Communication is done over unix domain, sequenced-packet sockets.
+ Communication is done over UNIX-domain, sequenced-packet sockets.
Each packet is interpreted as a complete message. A packet cannot
- contain multiple message, and a message cannot be split over
+ contain multiple messages, and a message cannot be split over
multiple packets. There are 4 types of messages:
Subscribe:
@@ -100,21 +100,21 @@ Protocol:
^CMSG \([^\x00]*\)\(\x00\(.*\)\)$
where \1 is the routing key for the message and \3
- is the message payload. \2 may be om be omitted if
+ is the message payload. \2 may be omitted if
sent by the client.
Secret messages:
Routing keys starting with '!/cred/' can only be subscribed to
by clients with matching credentials. These routing keys must
- match regular expression
+ match the regular expression
^!/cred/\([0-9]*\)/\([0-9]*\)/\([0-9]*\)/\(.*\)$
where \1 is the group ID, \2 is the user ID, \3 is the process
ID, and \4 the rest of routing key which may also use this
- pattern a process it communicates. Client can only subscribe
- to the routing key \1, \2, and \3 match it's credentials.
- If \1, \2, or \3 are empty, they will match the clients it's
+ pattern a process it communicates. A client can only subscribe
+ to the routing key if \1, \2, and \3 match its credentials.
+ If \1, \2, or \3 are empty, they will match the client's
credentials when subscribing. However, the server will not
accept '*' for \1, \2, or \3, or truncated routing keys.
@@ -122,7 +122,7 @@ Secret messages:
to be prefixed with the credentials for the servers the message
goes through, or use the credentials of the a program running
on a different master machine. Therefore, a client cannot
- simply just use its GID, UID, and PID, but must ask what's its
+ simply use its GID, UID, and PID, but must ask what its
credentials are by sending an empty control message (CMSG) with
the routing key '!/cred/whoami'. The server will reply with a
control message with the same routing key and the message will
@@ -132,7 +132,7 @@ Secret messages:
so the received control message is guaranteed to come from the
server.
- Example of how two client can prove their identities to each oter:
+ Example of how two clients can prove their identities to each other:
A: Send A's credentials to B.
B: Send B's credentials with routing key private to A.
@@ -144,17 +144,17 @@ Flood control:
choose the server behaviour when messages cannot be delivered
without blocking. All control messages are optional and server
may choose to ignore them at any time, even if previously
- honoured. Most recently sent control message that precedence.
+ honoured. The most recently sent control message takes precedence.
^CMSG blocking/soft/queue\(\x00.*\)*$
- Delivering is preferable, the server should queue up
- message that cannot be sent.
+ Delivering is preferable, the server should queue
+ messages that cannot be sent.
^CMSG blocking/soft/discard\(\x00.*\)*$
Delivering is unimportant, the server should discard
- message that cannot be sent.
+ messages that cannot be sent.
^CMSG blocking/soft/block\(\x00.*\)*$
@@ -163,23 +163,23 @@ Flood control:
^CMSG blocking/soft/error\(\x00.*\)*$
- The server may treat a client as misbehaving if message
+ The server may treat a client as misbehaving if a message
cannot be sent.
^CMSG blocking/hard/discard\(\x00.*\)*$
- If the server has queued up too many message it should
- start discarding new message instead of queuing them.
+ If the server has queued up too many messages it should
+ start discarding new messages instead of queuing them.
^CMSG blocking/hard/block\(\x00.*\)*$
- If the server has queued up too many message it should
+ If the server has queued up too many messages it should
start blocking communication until it can start queuing
messages again.
^CMSG blocking/hard/error\(\x00.*\)*$
- If the server has queued up too many message it should
+ If the server has queued up too many messages it should
start treating clients that are blocking as misbehaving.
^CMSG order/queue\(\x00.*\)*$
@@ -203,7 +203,7 @@ Echos:
subscribed to, that client will receive that message. The server
may however choose to implement control messages for selecting
whether this happens. Disabling echoing is useful for implementing
- slave servers that only send messages upwords in the server
+ slave servers that only send messages upwards in the server
hierarchy when necessary. The control messages for controlling
echoing are
@@ -213,4 +213,4 @@ Echos:
^CMSG echo/on\(\x00.*\)*$
- Reenable echoing.
+ Re-enable echoing.
diff --git a/config.mk b/config.mk
index 44b4bfc..1733e62 100644
--- a/config.mk
+++ b/config.mk
@@ -1,6 +1,8 @@
-PREFIX = /usr/local
+PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
-CFLAGS = -std=c99 -Wall -Wextra -O2 -fPIC
+CC = c99
+
+CFLAGS = -Wall -Wextra -O2 -fPIC
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
LDFLAGS = -s
diff --git a/libsbus.c b/libsbus.c
index ab8d3fe..e4c8f44 100644
--- a/libsbus.c
+++ b/libsbus.c
@@ -99,7 +99,7 @@ libsbus_receive(int fd, int flags, char *buf, union libsbus_packet *packet)
if (!p++)
goto unknown;
packet->type = LIBSBUS_CONTROL_MESSAGE;
- packet->message.key = &buf[4];
+ packet->message.key = &buf[5];
packet->message.msg = p;
packet->message.n = (size_t)(r - (p - buf));
} else {