oweals/dinit.git
8 years agoUpdate version : 0.04
Davin McCall [Wed, 9 Nov 2016 20:29:01 +0000 (20:29 +0000)]
Update version : 0.04

8 years agoIncorporate Dasynq changes (v0.02) v0.04
Davin McCall [Wed, 9 Nov 2016 20:19:36 +0000 (20:19 +0000)]
Incorporate Dasynq changes (v0.02)

8 years agoCheck for state STARTING before calling started() when process status
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.

8 years agoCombine start/stop queues, and add propagation queue.
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.

8 years agoCheck desired state == started before allowing service to begin
Davin McCall [Tue, 8 Nov 2016 23:15:52 +0000 (23:15 +0000)]
Check desired state == started before allowing service to begin
smooth recovery.

8 years agorootfscheck service: use the passed-from-parent control socket file descriptor
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.

8 years agoAdd an option to shutdown to allow for receiving the control socket file
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).

8 years agoRemove use of strcpy in favour of memcpy (save the relevant string lengths
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.

8 years agoFix a TODO comment
Davin McCall [Mon, 27 Jun 2016 12:02:18 +0000 (13:02 +0100)]
Fix a TODO comment

8 years agoAdd a "pass-cs-fd" service option, which passes a control socket file
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).

8 years agoRemove activated state if a service stops naturally
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).

8 years agoAdd release/wake commands to dinitctl
Davin McCall [Fri, 24 Jun 2016 15:14:28 +0000 (16:14 +0100)]
Add release/wake commands to dinitctl

8 years agoUse getWatchFd() from dasynq::FdWatcher rather than storing the fd in
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.

8 years agoClean up signal and fd handling around fork().
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().

8 years agoLatest Dasynq updates
Davin McCall [Thu, 23 Jun 2016 22:38:27 +0000 (23:38 +0100)]
Latest Dasynq updates

8 years agoIgnore SIGTSTP (^Z) for run-on-console processes.
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.

8 years agoImplement "list services" command in control protocol, and use it in
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.

8 years agoIgnore SIGPIPE to prevent sudden exit when control socket is closed
Davin McCall [Thu, 23 Jun 2016 10:33:30 +0000 (11:33 +0100)]
Ignore SIGPIPE to prevent sudden exit when control socket is closed

8 years agoFix bug in buffer pointer calculation
Davin McCall [Thu, 23 Jun 2016 10:00:32 +0000 (11:00 +0100)]
Fix bug in buffer pointer calculation

8 years agoReport (instead of silently ignoring) various errors when reading service descriptions.
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.

8 years agoUpdate Linux documentation
Davin McCall [Wed, 22 Jun 2016 08:20:41 +0000 (09:20 +0100)]
Update Linux documentation

8 years agoRemove redundant service settings.
Davin McCall [Wed, 22 Jun 2016 08:08:29 +0000 (09:08 +0100)]
Remove redundant service settings.
Change "nosigterm" option to "no-sigterm".

8 years agoMake SIGQUIT perform immediate shutdown ("shutdown --sytem"), rather than exec()int
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.

8 years agoCorrect exit status checks (status 0 returned by wait() doesn't have to mean
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).

8 years agoLog some error conditions (kill some TODOs)
Davin McCall [Tue, 21 Jun 2016 15:11:10 +0000 (16:11 +0100)]
Log some error conditions (kill some TODOs)

8 years agoUpdate Dasynq
Davin McCall [Tue, 21 Jun 2016 13:25:19 +0000 (14:25 +0100)]
Update Dasynq

8 years agoClean up some TODOs
Davin McCall [Tue, 21 Jun 2016 08:32:16 +0000 (09:32 +0100)]
Clean up some TODOs

8 years agoScratch one TODO: default case in switch can't occur, function is only
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.

8 years agoAdd documentation: using Dinit as your system init on Linux
Davin McCall [Sun, 19 Jun 2016 22:01:28 +0000 (23:01 +0100)]
Add documentation: using Dinit as your system init on Linux

8 years agoOne less TODO
Davin McCall [Sun, 19 Jun 2016 19:14:36 +0000 (20:14 +0100)]
One less TODO

8 years agoMerge branch 'master' of https://github.com/davmac314/dinit
Davin McCall [Sun, 19 Jun 2016 19:13:09 +0000 (20:13 +0100)]
Merge branch 'master' of https://github.com/davmac314/dinit

8 years agoFix kqueue backend bug; wasn't disabling read/write channels of a
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

8 years agoFix build problems with kqueue backend
Davin McCall [Sun, 19 Jun 2016 17:50:10 +0000 (18:50 +0100)]
Fix build problems with kqueue backend

8 years agoAdd root level Makefile, make "shutdown" be optionally built by "make all"
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)

8 years agoRe-vamp shutdown
Davin McCall [Sun, 19 Jun 2016 16:44:05 +0000 (17:44 +0100)]
Re-vamp shutdown

8 years agoUpdate version in README (v0.03) v0.03
Davin McCall [Sun, 19 Jun 2016 16:00:12 +0000 (17:00 +0100)]
Update version in README (v0.03)

8 years agoAdd note that dinitctl isn't working on OpenBSD ATM.
Davin McCall [Sun, 19 Jun 2016 14:30:04 +0000 (15:30 +0100)]
Add note that dinitctl isn't working on OpenBSD ATM.

8 years agonext_for_console was not being set null when a service queued for
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).

8 years agoUpdate README and TODO
Davin McCall [Sun, 19 Jun 2016 13:32:57 +0000 (14:32 +0100)]
Update README and TODO

8 years agoLarge refactoring of dinitctl.
Davin McCall [Sun, 19 Jun 2016 13:24:39 +0000 (14:24 +0100)]
Large refactoring of dinitctl.

8 years agoLog correct information regarding reason for process termination:
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?

8 years agoDon't display "can't bind socket: read only file sytem" error on the
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.

8 years agoSeparate the commencement of logging and the opening of the control socket
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.

8 years agoAdd a new service setting, "options", which can be used for various options
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.

8 years agoAdd a method to discard the console log buffer contents.
Davin McCall [Sat, 18 Jun 2016 19:21:06 +0000 (20:21 +0100)]
Add a method to discard the console log buffer contents.

8 years agoFix calculation of buffer size for LISTEN_FDS environment variable.
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).

8 years agoSmall documentation updates.
Davin McCall [Sat, 18 Jun 2016 16:51:10 +0000 (17:51 +0100)]
Small documentation updates.

8 years agoUpdate Dasynq, again, and update Dinit code to reflect API changes.
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.

8 years agoYet another Dasynq update
Davin McCall [Thu, 16 Jun 2016 22:54:54 +0000 (23:54 +0100)]
Yet another Dasynq update

8 years agoPull in latest Dasynq, which means a massive amount of renaming.
Davin McCall [Thu, 16 Jun 2016 18:31:01 +0000 (19:31 +0100)]
Pull in latest Dasynq, which means a massive amount of renaming.

8 years agoUpdate TODO
Davin McCall [Thu, 16 Jun 2016 17:33:46 +0000 (18:33 +0100)]
Update TODO

8 years agoUpdate dasynq to latest HEAD
Davin McCall [Thu, 16 Jun 2016 07:27:22 +0000 (08:27 +0100)]
Update dasynq to latest HEAD

8 years agoUse the start queue instead of starting services immediately.
Davin McCall [Thu, 16 Jun 2016 07:26:09 +0000 (08:26 +0100)]
Use the start queue instead of starting services immediately.

8 years agoWrite log messages which cross the circular buffer boundary atomically,
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.

8 years agoIgnore SIGPIPE.
Davin McCall [Tue, 14 Jun 2016 22:02:40 +0000 (23:02 +0100)]
Ignore SIGPIPE.

8 years agoMake control socket handling safer and fix an inverted logic bug.
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.

8 years agoMissed processing start/stop queue in one place
Davin McCall [Tue, 14 Jun 2016 18:05:00 +0000 (19:05 +0100)]
Missed processing start/stop queue in one place

8 years agoIntroduce a "stop queue" and "start queue" in ServiceSet, to better
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.

8 years agoUse _exit instead of exit after fork
Davin McCall [Tue, 14 Jun 2016 13:14:53 +0000 (14:14 +0100)]
Use _exit instead of exit after fork

8 years agoRework control protocol handling a little.
Davin McCall [Mon, 13 Jun 2016 21:21:08 +0000 (22:21 +0100)]
Rework control protocol handling a little.

8 years agoUpdate dasynq
Davin McCall [Mon, 13 Jun 2016 21:20:28 +0000 (22:20 +0100)]
Update dasynq

8 years agoUse a BidiFdWatcher for control connections. One step closer to
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...

8 years agoUpdate dasynq
Davin McCall [Sun, 12 Jun 2016 23:57:20 +0000 (00:57 +0100)]
Update dasynq

8 years agoCatch a broader range of exceptions when creating a ControlConn
Davin McCall [Sun, 12 Jun 2016 23:21:09 +0000 (00:21 +0100)]
Catch a broader range of exceptions when creating a ControlConn

8 years agoFix condition for detecting read failure in process_child_status().
Davin McCall [Sun, 12 Jun 2016 23:18:57 +0000 (00:18 +0100)]
Fix condition for detecting read failure in process_child_status().

8 years agoImplement DINIT_CP_RELEASESERVICE command.
Davin McCall [Sun, 12 Jun 2016 09:06:01 +0000 (10:06 +0100)]
Implement DINIT_CP_RELEASESERVICE command.

8 years agoCode consistency and documentation update
Davin McCall [Sun, 12 Jun 2016 09:00:49 +0000 (10:00 +0100)]
Code consistency and documentation update

8 years agoMap dinit-log log levels to syslog log levels
Davin McCall [Sat, 11 Jun 2016 20:21:25 +0000 (21:21 +0100)]
Map dinit-log log levels to syslog log levels

8 years agoEnable logging to syslog. v0.02
Davin McCall [Sat, 11 Jun 2016 19:38:22 +0000 (20:38 +0100)]
Enable logging to syslog.

8 years agoIncorporate latest bugfixes from dasynq
Davin McCall [Sat, 11 Jun 2016 18:24:02 +0000 (19:24 +0100)]
Incorporate latest bugfixes from dasynq

8 years agoFix (remove) noexcept specification for init_log().
Davin McCall [Sat, 11 Jun 2016 14:59:46 +0000 (15:59 +0100)]
Fix (remove) noexcept specification for init_log().

8 years agoFull support within the logging subsystem to an external source (fd).
Davin McCall [Sat, 11 Jun 2016 14:55:46 +0000 (15:55 +0100)]
Full support within the logging subsystem to an external source (fd).

8 years agoMore refactoring in preparation for proper logging support
Davin McCall [Sat, 11 Jun 2016 10:51:14 +0000 (11:51 +0100)]
More refactoring in preparation for proper logging support

8 years agoMinor refactoring
Davin McCall [Sat, 11 Jun 2016 10:06:54 +0000 (11:06 +0100)]
Minor refactoring

8 years agoAvoid hanging if a BGPROCESS is not a child of dinit, by probing
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.

8 years agoTODO updates.
Davin McCall [Mon, 6 Jun 2016 23:30:20 +0000 (00:30 +0100)]
TODO updates.

8 years agoWhitespace fixes v0.01
Davin McCall [Mon, 6 Jun 2016 22:40:51 +0000 (23:40 +0100)]
Whitespace fixes

8 years agoNo need to link libev anymore.
Davin McCall [Mon, 6 Jun 2016 22:12:18 +0000 (23:12 +0100)]
No need to link libev anymore.

8 years agoRefactoring, and actually enable console log in enable_console_log()...
Davin McCall [Mon, 6 Jun 2016 22:11:49 +0000 (23:11 +0100)]
Refactoring, and actually enable console log in enable_console_log()...

8 years agoRemove obseleted TODO comment
Davin McCall [Mon, 6 Jun 2016 19:40:39 +0000 (20:40 +0100)]
Remove obseleted TODO comment

8 years agoAdd console watch for logging once, then enable and disable as necessary,
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.

8 years agoUpdate dasynq
Davin McCall [Mon, 6 Jun 2016 18:11:18 +0000 (19:11 +0100)]
Update dasynq

8 years agoCode documentation - ServiceRecord and ServiceSet. Add a few lines on how
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.

8 years agoSuppress "invalid offsetof" warnings.
Davin McCall [Mon, 6 Jun 2016 07:31:48 +0000 (08:31 +0100)]
Suppress "invalid offsetof" warnings.

8 years agoRelease on failure to start.
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).

8 years agoFix condition in is_log_flushed
Davin McCall [Sun, 5 Jun 2016 20:25:53 +0000 (21:25 +0100)]
Fix condition in is_log_flushed

8 years agoMake all log messages go via the log buffer.
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.

8 years agoRefactorings.
Davin McCall [Sun, 5 Jun 2016 18:31:15 +0000 (19:31 +0100)]
Refactorings.

8 years agoFix style inconsistency in CPBuffer: fillTo -> fill_to
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...

8 years agoOpenBSD: use __thrsigdivert as a replacement for sigtimedwait.
Davin McCall [Sun, 5 Jun 2016 14:32:48 +0000 (15:32 +0100)]
OpenBSD: use __thrsigdivert as a replacement for sigtimedwait.

8 years agoMake selection of epoll/kqueue backend automatic
Davin McCall [Sun, 5 Jun 2016 09:31:00 +0000 (10:31 +0100)]
Make selection of epoll/kqueue backend automatic

8 years agoBeginnings of kqueue support (far from complete)
Davin McCall [Sun, 5 Jun 2016 02:29:12 +0000 (03:29 +0100)]
Beginnings of kqueue support (far from complete)

8 years agoRip out libev, replace with dasynq (new library written for the purpose).
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).

8 years agoRefactoring. Move buffered output management (variables) into a
Davin McCall [Tue, 19 Jan 2016 19:13:18 +0000 (19:13 +0000)]
Refactoring. Move buffered output management (variables) into a
class.

8 years agoUse non-blocking I/O and event notification for console logging.
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).

8 years agoOnly enable console logging via the service layer (when no services
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).

8 years agoIntroduce method to enable/disable console logging, instead of
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").

8 years agoAdd/correct some comments
Davin McCall [Sat, 16 Jan 2016 13:47:08 +0000 (13:47 +0000)]
Add/correct some comments

8 years agoMake CPBuffer a template, parameterized by buffer size
Davin McCall [Sat, 16 Jan 2016 12:54:05 +0000 (12:54 +0000)]
Make CPBuffer a template, parameterized by buffer size

8 years agoMakefile improvements (fix clean target), and build with -fno-rtti
Davin McCall [Fri, 15 Jan 2016 19:26:16 +0000 (19:26 +0000)]
Makefile improvements (fix clean target), and build with -fno-rtti
for reduced binary size.