Commit Graph
50 Commits
Author SHA1 Message Date
Joachim Wiberg 980152fd53 Add support for non-root users to use initctl, e.g. group wheel
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-11-30 11:44:22 +01:00
Joachim Wiberg 522a06f864 Merge pull request #181 from yangfl/typo
Fix typo
2021-06-25 07:43:08 +02:00
yangfl fa14ed1649 Fix typo
with the love from codespell
2021-06-25 13:08:14 +08:00
Joachim Wiberg 2a71f35005 Reduce log level of watchdog handover, this is not an error condition
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-06-22 17:20:17 +02:00
Joachim Wiberg dd437bf0a5 Follow-up to 18ab7d3: restore start of built-in watchdogd
This patch restores the start of the built-in/bundled watchdogd.  It is
tracked in the `wdog` variable and handled as an exception at shutdown.

This is also a follow-up to 7b74c99, ensuring that we only kill/stop the
built-in watchdog, not any external.  External ones can register to be
the controlling watchdogd in the system -- Finit is not the arbiter for
singletons, this is up to the system engineer.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-19 11:05:07 +02:00
Jacques de Laval 7b74c9900f Revert "Only track built-in watchdogd, not external ones"
This reverts commit 9eb8e8dd99.
2021-04-15 11:34:07 +02:00
Joachim Wiberg 3c4eca60b7 initctl: fix restart of run/tasks, stuck in DONE state
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-09 19:51:03 +02:00
Joachim Wiberg c0716d7f63 Minor optimization, drop expensive memset() ops
No need to zero out whole buffer for strlcat(), or other string check
ops.  Also drop a few completely useless memset() calls.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-07 11:58:41 +02:00
Joachim Wiberg 90f7ff1c23 initctl: new command 'reload NAME:ID' and new semantics for restart
This patch corrects a logical glitch, or design flaw, in initctl.  The
'restart FOO' command did not stop+start FOO only send SIGHUP (provided
FOO supports SIGHUP).  Hence, a new command 'reload FOO' is introduced,
which does exactly that, and 'restart FOO' now stops and restarts FOO.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-04-04 12:35:35 +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 9f06a2db99 Silence developer API debug message
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-12 13:25:50 +01:00
Joachim Wiberg f4f773b4c7 Initialize fallback svc_t in client comms, found by Coverity Scan
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-03-05 10:35:12 +01:00
Joachim Wiberg 649a269526 Add reboot/halt/poweroff/suspend commands to Finit API
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-21 10:49:13 +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
Jacques de Laval cb64c068e3 Fix #136: drop old init client tool
The SysV API compatibility layer gives too little value to be worth
the effort of maintaining it. Users are encouraged to use the
`initctl` tool instead.

Signed-off-by: Jacques de Laval <jacques@de-laval.se>
2021-02-11 17:52:08 +01:00
Joachim Wiberg e88a9b14ff Fix #101: remove built-in inetd from finit
This patch removes the built-in inetd support from Finit.  We recommend
using an external inetd instead, e.g. xinetd.

If you liked the feature set our inetd provided; filtering per interface
and port redirection, then please let us know or use the code in this
patch (MIT licensed) to recreate it.  We are open to reintroducing it,
but then as a stand-alone daemon like the bundled watchdogd and getty.

So long for now, old friend.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2021-02-11 12:46:40 +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
Joachim Nilsson 9eb8e8dd99 Only track built-in watchdogd, not external ones
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-05-03 12:01:41 +02:00
Joachim Nilsson 212083b922 Introduce strterm(), hard-add terminating '\0' at end of buffer
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-07 03:02:39 +01:00
Joachim Nilsson fe017642de Refactor do_query() to same calling convention used elsewhere
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-07 02:51:15 +01:00
Joachim Nilsson 744719219e initctl: Remove experimental cond set/clear commands
The commands are both unsafe (insecure) and send the wrong message,
that initctl can be used to script conditions.  Only plugins are
officially supported to manage conditions.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-07 00:35:13 +01:00
Joachim Nilsson 7bf2fcb6e3 Fix Coverity CID 265222, guard init_request::data member
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-06 23:56:59 +01:00
Joachim Nilsson ae9ed20d94 Revert "Attempt to fix Coverity CID 265222"
This reverts commit 238f63c0d3.
2020-01-06 23:54:32 +01:00
Joachim Nilsson 238f63c0d3 Attempt to fix Coverity CID 265222
When reading data from (presumably) initctl over the UNIX domain socket
we might actually be receiving corrupt data from a malicious attacker.

This patch is an attempt at, the very least, guarding against C string
functions reading out of bounds due to non-NULL terminated strings.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-06 21:58:03 +01:00
Jonas Johansson f5f1a55747 Add support to specify service ID as a string
Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
2018-12-11 16:43:05 +01: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 510b36645b Fix potential buffer overruns found by GCC 8.2
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-10-15 22:56:23 +02:00
Joachim Nilsson a487a30814 Refactor wdog tracking and hand-over to use svc_t instead of PID
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-07-09 23:49:04 +02:00
Joachim Nilsson 40db4f4f58 Minor, refactor to avoid namespace confusion with service.c API
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-07-09 23:49:04 +02:00
Joachim Nilsson 3b2f2690e7 initctl: start and restart should behave the same if svc has crashed
Found by Mattias Walström, Westermo.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-06-18 18:33:49 +02:00
Joachim Nilsson af41fcd35e api_exit(): Must stop libuEv watcher before closing descriptor
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-01-18 13:34:28 +01:00
Joachim Nilsson b6bd10d960 Follow-up to c1344e8, never shutdown() API socket, or segfault
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-31 13:27:25 +01:00
Joachim Nilsson c1344e89ff api_exit(): Only shutdown() of API socket at runtime
Not needed at shutdown/reboot.  Also, it may segfault at that stage.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-28 20:48:44 +01:00
Joachim Nilsson 9e8a01669e api: Fix possible descriptor leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-24 10:02:49 +01:00
Joachim Nilsson 8992e7bf2b Refactor svc_iterator() into a proper iterator, add first flag
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-22 23:56:14 +01:00
Joachim Nilsson c59f7d23f4 Add and improve debug messages, clean out old dev. comments
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-22 12:40:43 +01:00
Joachim Nilsson 61a9926442 Minor, staticify
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-20 00:13:21 +01:00
Joachim Nilsson 0f1f51b5ad Refactor, change from static array of svc_t to linked list
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-18 17:50:02 +01: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 f06a0fcb71 initctl: Support printing previous runlevel
This patch adds support for "PREVLEVEL RUNLEVEL" output to the initctl
runlevel command.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-17 10:54:06 +01:00
Joachim Nilsson e0fb2b036d Improve debug of initctl api
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-19 16:45:07 +01:00
Joachim Nilsson 9a75813350 api.c: Handle domain socket errors more gracefully, restart socket
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 15:00:05 +01:00
Joachim Nilsson 6826d7ee3f Handle event loop watcher failure modes
When alibuEv event watcher callback has `UEV_ERROR` in the events mask
we must handle the error.  Unfortunately, in most cases there is not
much we can do but ignore it or log the error.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 11:18:12 +01:00
Joachim Nilsson 920df09cd5 Fix GCC 7 warning, convert "Fall through" to "fallthrough" comment
In GCC 7 the -Wextra infers the new -Wimplicit-fallthrough which can be
suppressed by adding a simple comment

    /* fallthrough */

Which we had, but was too verbose (and misspelled) for GCC to notice.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson 30822f0d68 Remove UNUSED() macro and disable the compiler warning instead
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 21:59:23 +02:00
Joachim Nilsson 260335a19f Usability, a servivce stopped by a user is stopped, not blocked
The generic term for a non-running service is blocked, but a service may
be blocked for several different reasons.  When a user stops a service
with `initctl stop` the intuitive expected output from `initctl show` is
"stopped" not "blocked".

When the user later restarts the service with `initctl start` it may of
course be blocked due to wrong runlevel or a missing condition.  As can
be expected from the service's configuration.

The rest of the patch refactors the internal API names a bit to reflect
this change.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 15:42:44 +02:00
Joachim Nilsson 8ce330bcdb log.c: Rename log_toggle_debug() --> log_debug()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:28:16 +02:00
Joachim Nilsson d1df837d04 Refactor, move debug toggle to log.c:log_toggle_debug()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-01 20:34:37 +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