Commit Graph

31 Commits

Author SHA1 Message Date
C. McEnroe
3769acfdc7 Fix inverted exec prepend logic
Well that's embarrassing.
2021-09-25 03:31:14 +00:00
C. McEnroe
e9901e30a2 Only prepend exec if command line doesn't contain ;&|() 2021-03-01 19:29:27 -05:00
C. McEnroe
cc8a88c059 Remove use of "%n"
https://cvsweb.openbsd.org/src/lib/libc/stdio/vfprintf.c?rev=1.79&content-type=text/x-cvsweb-markup

I think this is silly, as I've said elsewhere, and it's a shame
because that was clearly the best way to write this. Oh well.
2021-02-01 11:39:25 -05:00
C. McEnroe
7769a4f6e9 Log a message when stopping a service waiting to restart
It's a little annoying to have to special-case this, but otherwise there
is no confirmation in the log that the restart won't still happen.
2020-12-15 16:47:12 -05:00
C. McEnroe
d90a43d948 Humanize milliseconds if interval is less than 1s
The intervals are configurable in milliseconds so humanize should be
able to display at that precision.
2020-10-20 20:56:06 -04:00
C. McEnroe
1832301862 Humanize restart interval 2020-10-20 19:56:56 -04:00
C. McEnroe
e548219ebf Log service uptime in status 2020-08-17 22:39:54 -04:00
C. McEnroe
41f9a167e3 Properly handle command line truncation
Unlikely to happen since ARG_MAX is 256K, but...
2020-08-17 12:57:50 -04:00
C. McEnroe
6302579f22 Add drop command 2020-08-16 23:01:25 -04:00
C. McEnroe
f9cfab1e0d Only call setgroups as root
setgroups fails when already running as a user.
2020-08-16 22:20:14 -04:00
C. McEnroe
7d04a0f5e0 Add privileged services
This allows running things like kfcgi which do their own privilege
dropping and chrooting. Need to update the examples with something like
that.
2020-08-16 17:28:57 -04:00
C. McEnroe
e381f7bbe3 Clear groups list for services 2020-08-16 16:13:43 -04:00
C. McEnroe
3fbe9b5933 Use process groups for services
This lets us properly signal services with child processes of their own.
2020-08-16 00:27:08 -04:00
C. McEnroe
1c4dd05f40 Add 126 to hardcoded stop exits
> If a command is not found, the exit status shall be 127. If the
> command name is found, but it is not an executable utility, the exit
> status shall be 126. Applications that invoke utilities without using
> the shell should use these exit status values to report similar errors.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_08_02
2020-08-15 23:11:09 -04:00
C. McEnroe
a6b78bc827 Only log signals other than SIGTERM 2020-08-15 18:36:30 -04:00
C. McEnroe
8b9daf7d5d Fix resetting restart interval with explicit restart 2020-08-15 18:28:20 -04:00
C. McEnroe
497cafbf0f Add reset interval after which restart interval is reset 2020-08-15 18:25:40 -04:00
C. McEnroe
449b0918ce Use only LOG_NOTICE and LOG_WARNING
These are the two priorities that go to a normal place
(/var/log/messages) by default.
2020-08-15 16:14:21 -04:00
C. McEnroe
3a57df720e Make log messages consistent 2020-08-15 15:57:45 -04:00
C. McEnroe
e25813c0b2 Remove closelog call
It's unclear whether closelog is really safe to call in pre-exec
context, so just trust that the log is opened with CLOEXEC.
2020-08-15 15:37:37 -04:00
C. McEnroe
92d27e09c3 Implement service status 2020-08-15 15:29:58 -04:00
C. McEnroe
34c39437f2 Read service pipes
Changed line reading functions to return const char * because modifying
the strings by adding '\0' into them screws up the following call.
2020-08-15 14:54:33 -04:00
C. McEnroe
f39d916e3a Just use CLOCK_MONOTONIC and clean up includes
CLOCK_MONOTONIC exists everywhere.
2020-08-15 09:53:03 -04:00
C. McEnroe
ba2175979c Reap children 2020-08-15 01:08:01 -04:00
C. McEnroe
e68a29c15e Implement serviceSignal, serviceStop, serviceRestart 2020-08-14 18:11:14 -04:00
C. McEnroe
0ca3c5c103 Reset restartInterval and restartDeadline on start 2020-08-14 17:55:01 -04:00
C. McEnroe
5f47019106 Implement serviceStart 2020-08-14 17:36:31 -04:00
C. McEnroe
ecc818534c Flesh out Service struct 2020-08-14 16:51:32 -04:00
C. McEnroe
96e962a08c Build environment for services 2020-08-14 16:17:29 -04:00
C. McEnroe
e0dab12078 Implement spawntab parsing 2020-08-14 16:00:35 -04:00
C. McEnroe
3b38cfdbfe Implement user and group lookup 2020-08-14 16:00:35 -04:00