Commit Graph
23 Commits
Author SHA1 Message Date
Joachim Wiberg 912a281ee2 Fix #299: add support for service readiness notification
This patch adds service readiness notification to support daemons
employing systemd and s6 notification.  Complementing the native
Finit readiness support using PID files that exist already.

The two have slightly different ways of implementing readiness:

 - https://www.freedesktop.org/software/systemd/man/sd_notify.html
 - https://skarnet.org/software/s6/notifywhenup.html

Finit now provides both a NOTIFY_SOCKET environemnt variable, for
systemd, and a way to start s6 daemons with a descriptor argument.

For details on the syntax, see the `service` documentation.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-10-16 20:06:26 +02:00
Joachim Wiberg 6e863a7872 client_connect(): ensure socket is also reset to -1 on error
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-10-16 20:01:29 +02:00
Joachim Wiberg 37e3be9a0d Refactor to share err/warn log API between daemon and client code
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-09-05 09:57:45 +02:00
Joachim Wiberg 10437887fc Minor, staticify local function
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-08-29 07:49:40 +02:00
Joachim Wiberg 9a76f0862c initctl: let -q silence all commands
This patch introduces ERR(), ERRX(), WARN(), and WARNX() as replacements
to their lower case counterparts.  These log macros respect the 'quiet'
flag to initctl, leaving only the return code as indicator to user.

Fixes #266

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 10:34:36 +02:00
Joachim Wiberg f8bed5c7af Minor, fix local shadowing of scope global variable
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-05-15 09:38:05 +02:00
Joachim Wiberg 0c4a9b62c2 initctl: allow client_connect() to return error
This lets any callers of client_connect() decide what to do wrt. error
recovery and fallback mechanisms.  E.g., reboot may want to check if
it's in sulogin mode, or fall back to sending signals to PID 1.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-25 21:44:33 +02:00
Joachim Wiberg 108bbf56dd Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-04-19 19:35:49 +02:00
Joachim Wiberg b994858907 initctl: exit immediately on signal (from Finit)
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-02-13 22:45:47 +01:00
Joachim Wiberg 0acbc60ec1 initctl: drop confusing 'errno 0' from "Timed out" message
errno is not set when we timeout waiting for a reply from Finit.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-05-30 11:26:41 +02:00
Joachim Wiberg 1845b7be54 The unix(7) man page recommends using SOCK_SEQPACKET
Since Linux 2.6.4 the SOCK_SEQPACKET socket type is available for UNIX
domain sockets on Linux.  It is intended for; "a sequenced-packet socket
that is connection-oriented, preserves message boundaries, and delivers
messages in the order that they were sent." which sounds like us.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-25 17:26:55 +01:00
Joachim Wiberg 9c2f0b2dc8 initctl: finit may be busy, wait for it ...
When calling initctl early in the boot process, e.g. just when Finit is
switching to the final runlevel, it may take a few milliseconds for it
to actually be ready to process our request.

This patch adds poll() to both the write(REQ) and the read(RSP) steps
to prevent from getting weird errors when Finit is busy.  The timeout
is currently 2 sec in both directions, which should be enough.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-25 17:18:50 +01:00
Joachim Wiberg 1edc4356a6 initctl: improve error message for unprivileged users
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-12 13:26:16 +01:00
Joachim Wiberg e80edbb401 If Finit API call fails (NACK), return non-zero to client
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 10:47:48 +01:00
Joachim Wiberg b175b4a2ae initctl: add PID and IDENT to 'cond dump' command
Instead of just walking /run/finit/cond, also show the source of each
condition.  The hook and net conditions are hard-coded to init[1] atm.
and unknown conditions are shown as unknown[0].

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-13 12:07:20 +01:00
Joachim Wiberg a5714a058c Update copyright years
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-09 22:07:03 +01:00
Joachim Wiberg 24a78d3246 Update copyright years and author last name
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2020-09-02 23:38:11 +02:00
Robert Andersson d371b85c47 fix C++ compilation issues
Signed-off-by: Robert Andersson <robert.m.andersson@se.atlascopco.com>
2018-10-22 12:51:58 +02:00
Joachim Nilsson c0515d112e New client side API to access svc_t entries without shared memory
This change is one of the required intermediate steps to remove the
shared memory store for all svc_t, this in turn to avoid any external
programs manipulating the internal memory of PID 1.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-18 11:06:19 +01:00
Joachim Nilsson cae61ad6df initctl refactor, break out domain socket/client API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-16 12:15:28 +01:00
Joachim Nilsson 27e4af5ed8 Rename, client.c --> telinit.c
We need the name client.c for the client side of api.c, so let's rename
the client to its traditional name.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-15 14:00:11 +01:00
Joachim Nilsson 60df2f2ea9 Minor, cleanup old requirement for clients to set silent
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:41:23 +02:00
Joachim Nilsson fff68b7b06 Relocate source files to an src/ subdirectory
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-01-16 01:31:02 +01:00