Davin McCall [Sun, 12 Mar 2017 23:16:15 +0000 (23:16 +0000)]
Fix trivial memory leak.
Davin McCall [Thu, 10 Nov 2016 02:34:32 +0000 (02:34 +0000)]
Run not-on-console services in a session (via setsid()).
This prevents them from receiving terminal control signals, if
dinit is running on a terminal (normally only if run in user
mode).
Davin McCall [Wed, 9 Nov 2016 20:29:01 +0000 (20:29 +0000)]
Update version : 0.04
Davin McCall [Wed, 9 Nov 2016 20:19:36 +0000 (20:19 +0000)]
Incorporate Dasynq changes (v0.02)
Davin McCall [Wed, 9 Nov 2016 15:17:54 +0000 (15:17 +0000)]
Check for state STARTING before calling started() when process status
fd closes.
A smooth-recovery process should not reported started when it recovers
(state is already STARTED). Furthermore, a service could be stopped
during smooth recovery, in which case the state will be STOPPING and
the service should certainly not transition to STARTED.
Davin McCall [Wed, 9 Nov 2016 14:28:48 +0000 (14:28 +0000)]
Combine start/stop queues, and add propagation queue.
The propagation queue is used to propagate changes other than
immediate start/stop requests. It might be possible to combine the
two queues at a later stage.
This commit eliminates all recursion from service.cc.
Davin McCall [Tue, 8 Nov 2016 23:15:52 +0000 (23:15 +0000)]
Check desired state == started before allowing service to begin
smooth recovery.
Davin McCall [Wed, 21 Sep 2016 07:23:30 +0000 (08:23 +0100)]
rootfscheck service: use the passed-from-parent control socket file descriptor
to issue reboot commands (--use-passed-cfd option to reboot).
This may be necessary since the control socket may not have been created yet, due
to the root filesystem being read-only at this point.
Davin McCall [Wed, 21 Sep 2016 07:17:28 +0000 (08:17 +0100)]
Add an option to shutdown to allow for receiving the control socket file
descriptor from the parent process (identified by DINIT_CS_FD).
Davin McCall [Thu, 30 Jun 2016 14:20:56 +0000 (15:20 +0100)]
Remove use of strcpy in favour of memcpy (save the relevant string lengths
when they are calculated beforehand, so that they can be used as the length
argument). This is slightly more efficient and will silence and OpenBSD linker
warning.
Davin McCall [Mon, 27 Jun 2016 12:02:18 +0000 (13:02 +0100)]
Fix a TODO comment
Davin McCall [Sun, 26 Jun 2016 18:21:10 +0000 (19:21 +0100)]
Add a "pass-cs-fd" service option, which passes a control socket file
descriptor directly to service processes, allowing them issue commands
even if the regular control socket has not been created (or if they
will not have permission to access it).
This has limited use cases and has security implications when used,
but allows early launching of a service which can pass events / issue
commands to dinit. In particular this could be useful for a device
watcher daemon which starts services as certain devices come online
(eg check and mount disks as they are detected by the kernel).
Davin McCall [Fri, 24 Jun 2016 15:30:27 +0000 (16:30 +0100)]
Remove activated state if a service stops naturally
(if auto-restart is enabled, it will restart instead).
Davin McCall [Fri, 24 Jun 2016 15:14:28 +0000 (16:14 +0100)]
Add release/wake commands to dinitctl
Davin McCall [Fri, 24 Jun 2016 12:39:13 +0000 (13:39 +0100)]
Use getWatchFd() from dasynq::FdWatcher rather than storing the fd in
a separate member variable, in various places.
Squashes some TODOs.
Davin McCall [Thu, 23 Jun 2016 22:40:28 +0000 (23:40 +0100)]
Clean up signal and fd handling around fork().
Mask signals while we are doing dup() since it is allowed to return
EINTR apparently.
Make sure we obtain fds for stdin/stdout/stderr before we exec().
Davin McCall [Thu, 23 Jun 2016 22:38:27 +0000 (23:38 +0100)]
Latest Dasynq updates
Davin McCall [Thu, 23 Jun 2016 20:25:36 +0000 (21:25 +0100)]
Ignore SIGTSTP (^Z) for run-on-console processes.
We don't want to be job control shell.
Davin McCall [Thu, 23 Jun 2016 11:33:36 +0000 (12:33 +0100)]
Implement "list services" command in control protocol, and use it in
"dinitctl list" command.
Davin McCall [Thu, 23 Jun 2016 10:33:30 +0000 (11:33 +0100)]
Ignore SIGPIPE to prevent sudden exit when control socket is closed
Davin McCall [Thu, 23 Jun 2016 10:00:32 +0000 (11:00 +0100)]
Fix bug in buffer pointer calculation
Davin McCall [Wed, 22 Jun 2016 16:22:05 +0000 (17:22 +0100)]
Report (instead of silently ignoring) various errors when reading service descriptions.
Squashes a bunch of TODO's.
Davin McCall [Wed, 22 Jun 2016 08:20:41 +0000 (09:20 +0100)]
Update Linux documentation
Davin McCall [Wed, 22 Jun 2016 08:08:29 +0000 (09:08 +0100)]
Remove redundant service settings.
Change "nosigterm" option to "no-sigterm".
Davin McCall [Tue, 21 Jun 2016 18:52:02 +0000 (19:52 +0100)]
Make SIGQUIT perform immediate shutdown ("shutdown --sytem"), rather than exec()int
the plain "shutdown" command, which would have tried to contact Dinit in order to
roll back services anyway.
Davin McCall [Tue, 21 Jun 2016 18:24:10 +0000 (19:24 +0100)]
Correct exit status checks (status 0 returned by wait() doesn't have to mean
"exited cleanly with 0 exit status", though it probably does on most real
systems).
Davin McCall [Tue, 21 Jun 2016 15:11:10 +0000 (16:11 +0100)]
Log some error conditions (kill some TODOs)
Davin McCall [Tue, 21 Jun 2016 13:25:19 +0000 (14:25 +0100)]
Update Dasynq
Davin McCall [Tue, 21 Jun 2016 08:32:16 +0000 (09:32 +0100)]
Clean up some TODOs
Davin McCall [Mon, 20 Jun 2016 22:12:45 +0000 (23:12 +0100)]
Scratch one TODO: default case in switch can't occur, function is only
called once command has been established, therefore there's no need
to handle other cases.
Davin McCall [Sun, 19 Jun 2016 22:01:28 +0000 (23:01 +0100)]
Add documentation: using Dinit as your system init on Linux
Davin McCall [Sun, 19 Jun 2016 19:14:36 +0000 (20:14 +0100)]
One less TODO
Davin McCall [Sun, 19 Jun 2016 19:13:09 +0000 (20:13 +0100)]
Merge branch 'master' of https://github.com/davmac314/dinit
Davin McCall [Sun, 19 Jun 2016 19:11:17 +0000 (20:11 +0100)]
Fix kqueue backend bug; wasn't disabling read/write channels of a
Bidi watcher appropriately when watcher added
Davin McCall [Sun, 19 Jun 2016 17:50:10 +0000 (18:50 +0100)]
Fix build problems with kqueue backend
Davin McCall [Sun, 19 Jun 2016 17:05:01 +0000 (18:05 +0100)]
Add root level Makefile, make "shutdown" be optionally built by "make all"
(BUILD_SHUTDOWN in mconfig)
Davin McCall [Sun, 19 Jun 2016 16:44:05 +0000 (17:44 +0100)]
Re-vamp shutdown
Davin McCall [Sun, 19 Jun 2016 16:00:12 +0000 (17:00 +0100)]
Update version in README (v0.03)
Davin McCall [Sun, 19 Jun 2016 14:30:04 +0000 (15:30 +0100)]
Add note that dinitctl isn't working on OpenBSD ATM.
Davin McCall [Sun, 19 Jun 2016 14:16:10 +0000 (15:16 +0100)]
next_for_console was not being set null when a service queued for
the console (and was not initialised).
Davin McCall [Sun, 19 Jun 2016 13:32:57 +0000 (14:32 +0100)]
Update README and TODO
Davin McCall [Sun, 19 Jun 2016 13:24:39 +0000 (14:24 +0100)]
Large refactoring of dinitctl.
Davin McCall [Sat, 18 Jun 2016 22:29:37 +0000 (23:29 +0100)]
Log correct information regarding reason for process termination:
did it exit, was it signalled?
Davin McCall [Sat, 18 Jun 2016 19:37:14 +0000 (20:37 +0100)]
Don't display "can't bind socket: read only file sytem" error on the
first attempt to bind the control socket (immediately after starting).
It's pretty normal for the filesystem to be mounted read-only at that
stage.
Davin McCall [Sat, 18 Jun 2016 19:25:17 +0000 (20:25 +0100)]
Separate the commencement of logging and the opening of the control socket
into two distinct functions.
Davin McCall [Sat, 18 Jun 2016 19:22:18 +0000 (20:22 +0100)]
Add a new service setting, "options", which can be used for various options
and which deprecates several other settings. Includes a new option, starts-log,
specifying that the service starts the syslog service.
Davin McCall [Sat, 18 Jun 2016 19:21:06 +0000 (20:21 +0100)]
Add a method to discard the console log buffer contents.
Davin McCall [Sat, 18 Jun 2016 17:05:01 +0000 (18:05 +0100)]
Fix calculation of buffer size for LISTEN_FDS environment variable.
(Fortunately, it still gave the correct result in all expected cases).
Davin McCall [Sat, 18 Jun 2016 16:51:10 +0000 (17:51 +0100)]
Small documentation updates.
Davin McCall [Sat, 18 Jun 2016 14:11:19 +0000 (15:11 +0100)]
Update Dasynq, again, and update Dinit code to reflect API changes.
Hopefully the Dasynq API is now fairly stable.
Davin McCall [Thu, 16 Jun 2016 22:54:54 +0000 (23:54 +0100)]
Yet another Dasynq update
Davin McCall [Thu, 16 Jun 2016 18:31:01 +0000 (19:31 +0100)]
Pull in latest Dasynq, which means a massive amount of renaming.
Davin McCall [Thu, 16 Jun 2016 17:33:46 +0000 (18:33 +0100)]
Update TODO
Davin McCall [Thu, 16 Jun 2016 07:27:22 +0000 (08:27 +0100)]
Update dasynq to latest HEAD
Davin McCall [Thu, 16 Jun 2016 07:26:09 +0000 (08:26 +0100)]
Use the start queue instead of starting services immediately.
Davin McCall [Wed, 15 Jun 2016 15:59:48 +0000 (16:59 +0100)]
Write log messages which cross the circular buffer boundary atomically,
using writev.
Davin McCall [Tue, 14 Jun 2016 22:02:40 +0000 (23:02 +0100)]
Ignore SIGPIPE.
Davin McCall [Tue, 14 Jun 2016 22:01:22 +0000 (23:01 +0100)]
Make control socket handling safer and fix an inverted logic bug.
queuePacket() now no longer deletes the connection, meaning its
use the service listener is now safe.
Davin McCall [Tue, 14 Jun 2016 18:05:00 +0000 (19:05 +0100)]
Missed processing start/stop queue in one place
Davin McCall [Tue, 14 Jun 2016 17:05:31 +0000 (18:05 +0100)]
Introduce a "stop queue" and "start queue" in ServiceSet, to better
manage service interactions and avoid recursion. Both are implemented
as a singly-linked list of services. The queues are processed one
at a time until empty.
Davin McCall [Tue, 14 Jun 2016 13:14:53 +0000 (14:14 +0100)]
Use _exit instead of exit after fork
Davin McCall [Mon, 13 Jun 2016 21:21:08 +0000 (22:21 +0100)]
Rework control protocol handling a little.
Davin McCall [Mon, 13 Jun 2016 21:20:28 +0000 (22:20 +0100)]
Update dasynq
Davin McCall [Sun, 12 Jun 2016 23:57:52 +0000 (00:57 +0100)]
Use a BidiFdWatcher for control connections. One step closer to
working with kqueue...
Davin McCall [Sun, 12 Jun 2016 23:57:20 +0000 (00:57 +0100)]
Update dasynq
Davin McCall [Sun, 12 Jun 2016 23:21:09 +0000 (00:21 +0100)]
Catch a broader range of exceptions when creating a ControlConn
Davin McCall [Sun, 12 Jun 2016 23:18:57 +0000 (00:18 +0100)]
Fix condition for detecting read failure in process_child_status().
Davin McCall [Sun, 12 Jun 2016 09:06:01 +0000 (10:06 +0100)]
Implement DINIT_CP_RELEASESERVICE command.
Davin McCall [Sun, 12 Jun 2016 09:00:49 +0000 (10:00 +0100)]
Code consistency and documentation update
Davin McCall [Sat, 11 Jun 2016 20:21:25 +0000 (21:21 +0100)]
Map dinit-log log levels to syslog log levels
Davin McCall [Sat, 11 Jun 2016 19:38:22 +0000 (20:38 +0100)]
Enable logging to syslog.
Davin McCall [Sat, 11 Jun 2016 18:24:02 +0000 (19:24 +0100)]
Incorporate latest bugfixes from dasynq
Davin McCall [Sat, 11 Jun 2016 14:59:46 +0000 (15:59 +0100)]
Fix (remove) noexcept specification for init_log().
Davin McCall [Sat, 11 Jun 2016 14:55:46 +0000 (15:55 +0100)]
Full support within the logging subsystem to an external source (fd).
Davin McCall [Sat, 11 Jun 2016 10:51:14 +0000 (11:51 +0100)]
More refactoring in preparation for proper logging support
Davin McCall [Sat, 11 Jun 2016 10:06:54 +0000 (11:06 +0100)]
Minor refactoring
Davin McCall [Tue, 7 Jun 2016 07:30:00 +0000 (08:30 +0100)]
Avoid hanging if a BGPROCESS is not a child of dinit, by probing
status with waitpid() and assuming the process is stopped if it
is not a child.
Davin McCall [Mon, 6 Jun 2016 23:30:20 +0000 (00:30 +0100)]
TODO updates.
Davin McCall [Mon, 6 Jun 2016 22:40:51 +0000 (23:40 +0100)]
Whitespace fixes
Davin McCall [Mon, 6 Jun 2016 22:12:18 +0000 (23:12 +0100)]
No need to link libev anymore.
Davin McCall [Mon, 6 Jun 2016 22:11:49 +0000 (23:11 +0100)]
Refactoring, and actually enable console log in enable_console_log()...
Davin McCall [Mon, 6 Jun 2016 19:40:39 +0000 (20:40 +0100)]
Remove obseleted TODO comment
Davin McCall [Mon, 6 Jun 2016 18:12:18 +0000 (19:12 +0100)]
Add console watch for logging once, then enable and disable as necessary,
rather than constantly adding and removing it.
Davin McCall [Mon, 6 Jun 2016 18:11:18 +0000 (19:11 +0100)]
Update dasynq
Davin McCall [Mon, 6 Jun 2016 15:31:00 +0000 (16:31 +0100)]
Code documentation - ServiceRecord and ServiceSet. Add a few lines on how
require/release operate and control service start/stop.
Davin McCall [Mon, 6 Jun 2016 07:31:48 +0000 (08:31 +0100)]
Suppress "invalid offsetof" warnings.
Davin McCall [Mon, 6 Jun 2016 07:30:38 +0000 (08:30 +0100)]
Release on failure to start.
(Ensures dependencies will stop if they are not otherwise required).
Davin McCall [Sun, 5 Jun 2016 20:25:53 +0000 (21:25 +0100)]
Fix condition in is_log_flushed
Davin McCall [Sun, 5 Jun 2016 20:05:40 +0000 (21:05 +0100)]
Make all log messages go via the log buffer.
Flush the log buffer before exit.
Davin McCall [Sun, 5 Jun 2016 18:31:15 +0000 (19:31 +0100)]
Refactorings.
Davin McCall [Sun, 5 Jun 2016 17:28:36 +0000 (18:28 +0100)]
Fix style inconsistency in CPBuffer: fillTo -> fill_to
There is generally inconsistent style throughout the codebase, but
at least this one class can be self-consistent...
Davin McCall [Sun, 5 Jun 2016 14:32:48 +0000 (15:32 +0100)]
OpenBSD: use __thrsigdivert as a replacement for sigtimedwait.
Davin McCall [Sun, 5 Jun 2016 09:31:00 +0000 (10:31 +0100)]
Make selection of epoll/kqueue backend automatic
Davin McCall [Sun, 5 Jun 2016 02:29:12 +0000 (03:29 +0100)]
Beginnings of kqueue support (far from complete)
Davin McCall [Sun, 5 Jun 2016 00:49:23 +0000 (01:49 +0100)]
Rip out libev, replace with dasynq (new library written for the purpose).
Davin McCall [Tue, 19 Jan 2016 19:13:18 +0000 (19:13 +0000)]
Refactoring. Move buffered output management (variables) into a
class.
Davin McCall [Tue, 19 Jan 2016 11:13:55 +0000 (11:13 +0000)]
Use non-blocking I/O and event notification for console logging.
(needs some cleanup).
Davin McCall [Sat, 16 Jan 2016 14:45:52 +0000 (14:45 +0000)]
Only enable console logging via the service layer (when no services
are using the console).
Davin McCall [Sat, 16 Jan 2016 14:17:20 +0000 (14:17 +0000)]
Introduce method to enable/disable console logging, instead of
using a global variable. (introduce "enable_console_log(bool)",
remove "log_to_console").
Davin McCall [Sat, 16 Jan 2016 13:47:08 +0000 (13:47 +0000)]
Add/correct some comments