libink/finit: properties, and org.finit on the system bus

Runlevel and version are state, not actions, so they belong behind
org.freedesktop.DBus.Properties rather than another method each.

Finit also claims org.finit on the system bus when it finds one, so
ordinary D-Bus clients can reach it without knowing about
/run/finit/bus.  Opportunistic on purpose: no dbus-daemon is a normal
state for the systems Finit runs on, not an error to report.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-08-13 09:28:14 +02:00
1 parent dd1390a6c2
commit ebc0ef62e6
22 files changed
+1474 -154

No files matched your search

+61
View File
@@ -102,6 +102,14 @@ void __w_string(struct link_writer *w, const char *s) { write_lenprefixed(w, s,
void __w_path (struct link_writer *w, const char *s) { write_lenprefixed(w, s, 0); }
void __w_sig (struct link_writer *w, const char *s) { write_lenprefixed(w, s, 1); }
/* Variant "v" containing a string. Wire form:
* 1-byte sig length (1), 's', NUL, then the string per __w_string. */
void __w_variant_string(struct link_writer *w, const char *s)
{
__w_sig (w, "s");
__w_string(w, s);
}
static size_t element_align(char c)
{
switch (c) {
@@ -254,7 +262,60 @@ static int read_string_like(struct link_reader *r, const char **out)
int __r_string(struct link_reader *r, const char **out) { return read_string_like(r, out); }
int __r_path (struct link_reader *r, const char **out) { return read_string_like(r, out); }
/* Read a variant "v" expected to contain a string. Fails if the
* inner signature is anything other than "s" (returns -1, *out set
* to NULL). */
int __r_variant_string(struct link_reader *r, const char **out)
{
uint8_t sig_len;
uint32_t slen;
*out = NULL;
/* signature is "g" wire form: 1-byte length, bytes, NUL */
if (r_skip_align(r, 1) < 0 || r->off + 1 > r->cap) { r->err = 1; return -1; }
sig_len = r->base[r->off++];
if (sig_len != 1 || r->off + 2 > r->cap) { r->err = 1; return -1; }
if (r->base[r->off] != 's' || r->base[r->off + 1] != 0) { r->err = 1; return -1; }
r->off += 2;
/* now a normal string */
if (__r_u32(r, &slen) < 0) return -1;
if (r->off + (size_t)slen + 1 > r->cap || r->base[r->off + slen] != 0) {
r->err = 1;
return -1;
}
*out = (const char *)(r->base + r->off);
r->off += (size_t)slen + 1;
return 0;
}
int __r_done(const struct link_reader *r)
{
return !r->err && r->off == r->cap;
}
int __r_align(struct link_reader *r, size_t n)
{
return r_skip_align(r, n);
}
/* Begin reading an "a<T>" array. Reads the u32 byte-length prefix
* and sets *out_end to the absolute reader offset at which the array
* ends. Caller loops while r->off < *out_end. Returns -1 on a
* truncated or oversized array length. */
int __r_array_begin(struct link_reader *r, size_t *out_end)
{
uint32_t array_bytes;
size_t end;
if (__r_u32(r, &array_bytes) < 0)
return -1;
end = r->off + (size_t)array_bytes;
if (end > r->cap) {
r->err = 1;
return -1;
}
*out_end = end;
return 0;
}