aboutsummaryrefslogtreecommitdiff
path: root/src/rc/supervise-daemon.c
AgeCommit message (Collapse)Author
2022-03-05switch 0x100 constants to enumsMike Frysinger
This should make the code easier to maintain without having to remember what the exact 0x100 constant means.
2022-03-05switch 0x80 to 0x103 for long optionsMike Frysinger
We use 0x100+ to avoid collisions in the 8 bit getopt interface, so switch 0x80 to align with the other existing 0x100 options we have.
2022-02-06linux: Add support for No New Privs flagLinkTed
This add No New Privs flag for start-stop-daemon and supervise-daemon by adding --no-new-privs flag. As a result, the user set the No New Privs flag for the program should run with. see PR_SET_NO_NEW_PRIVS prctl(2)
2022-02-06capabilities: Add support for securebits flagsLinkTed
This adds securebits flags for start-stop-daemon and supervise-daemon by adding --secbits option. As a result, the user can specify securebits the program should run with. see capabilities(7)
2021-12-23capabilities: Add support for Linux capabilities(7)LinkTed
This adds capabilities for start-stop-daemon by adding --capabilities option. As a result, the user can specify the inheritable, ambient and bounding set by define capabilities in the service script. This fixes #314.
2021-12-22add option for OOM score adjustmentMatt Whitlock
This commit adds a new --oom-score-adj option to start-stop-daemon and supervise-daemon, as well as an equivalent SSD_OOM_SCORE_ADJ environment variable. If either of these are specified (with the command-line option taking precedence), then the specified adjustment value is written to /proc/self/oom_score_adj after forking but prior to exec'ing the daemon (at the time when nice and ionice are applied). Additionally, per a suggestion by Mike Frysinger, the suggested values for the SSD_NICELEVEL, SSD_IONICELEVEL, and SSD_OOM_SCORE_ADJ variables in the example config file are now given as zeros, which are the kernel's default values of these process knobs for the init process at boot. Note that uncommenting any of these zero-valued suggestions will cause SSD/SD to set the corresponding process knob affirmatively to zero, whereas leaving the variable unset (and the equivalent command- line option unspecified) means SSD/SD will not change the corresponding process knob from its inherited value. See: https://github.com/OpenRC/openrc/pull/435#discussion_r688310672 This fixes #435.
2021-12-21code style: remove space after unary "not" operatorMatt Whitlock
There are no semantic changes in this commit. Suggested-by: Mike Frysinger <vapier@gentoo.org> See: https://github.com/OpenRC/openrc/pull/435#pullrequestreview-727035394
2021-12-20use HEAD in git URIs to point to the default branchMike Frysinger
This makes the URIs shorter and dynamic: whatever the default branch the repo uses will be used.
2021-12-20change getopt definition to elide pointer storageMike Frysinger
Make this a const pointer to the storage directly instead of a pointer variable that points to the storage. Makes the code slightly smaller.
2021-08-17supervise-daemon: implement SSD_IONICELEVELMatt Whitlock
supervise-daemon was apparently overlooked when support for the SSD_IONICELEVEL environment variable was added. This commit brings supervise-daemon up to parity with start-stop-daemon with respect to this environment variable.
2021-08-13move supervise-daemon out of experimental statuskyoreln
supervise-daemon is no longer experimental so remove the statements to that affect. This fixes #434.
2021-02-22supervise-daemon: Fix off by ones when checking for RC_* envvarsDisconnect3d
Fixes strncmp size argument off by one as the current implementation didn't match the `=` character. This fixes #361.
2020-11-29supervise-daemon: do not spawn a process if we are exitingWilliam Hubbs
This fixes #375 and allows us to not add another level of indentation in the supervisor loop.
2020-11-27start-stop-daemon, supervise-daemon: fix parsing of usernames passed via ↵Johannes Heimansberg
--user that start with a number start-stop-daemon and supervise-daemon parse usernames and group names passed via the --user argument as numeric UID/GID if they start with a number (e.g. user "4foo" will be treated as UID 4). This results in the process that is being started to run under a totally unexpected user if that UID exists. Even though the result of the sscanf calls are tested for a result of exactly 1, which means exactly one value was extracted, because sscanf's format string only contains only one placeholder, it will never return a value greater than 1, even if there are still characters left to be parsed. This causes start-stop-daemon and supervise-daemon to assume that usernames starting with a number are just that number. Adding a second placeholder "%1s" to the format string, which matches a string of length 1, makes sure that sscanf can distinguish between pure numbers (in which case it will return 1) and strings either starting with a number (in which case it will return 2) and any other string (in which case it will return 0). This fixes #379. This fixes #380.
2020-09-25supervise-daemon: only log debug logs when verbose mode is activeWilliam Hubbs
2020-01-11supervise-daemon: Fix segfault when executable does not existWolf
When executable is provided just by name (and therefore searched in a path), exec_file is reset to NULL every time. exists() handles it being NULL just fine, but dereferencing it in eerror does not work. Fixes #326 Fixes #327
2019-03-29supervise-daemon: allow --respawn-max to be zeroWilliam Hubbs
2018-12-24src/rc/supervise-daemon.c: formatting fixesphilhofer
Fix misleading indentation and other erroneous whitespace. This fixes #273.
2018-12-23src/rc/supervise-daemon.c: do not pass NULL to strcmpphilhofer
The following will cause a segfault due to NULL being passed to strcmp(3) $ RC_SVCNAME=foo supervise-daemon Fix the bounds check on argc in main. If argc<=1, then it is not safe to dereference argv[1].
2018-12-21fix compiler warningsWilliam Hubbs
2018-12-20supervise-daemon: do not use the exec_service() functionWilliam Hubbs
In order to run healthcheck() and the unhealthy() function, add an exec_command call to the supervisor. Another difference is This function also logs errors instead of attempting to display them. This is for #271.
2018-12-06supervise-daemon: fix busy loopWilliam Hubbs
This fixes #264.
2018-12-04supervise-daemon: redirect std{in,out,err} to /dev/null after demonizingAlexander Zubkov
This fixes #239.
2018-12-03src/rc/supervise-daemon.c: fix style issueAustin English
This is for #263.
2018-12-03supervise-daemon: use a default pid file if one is not specifiedWilliam Hubbs
Since the pid file is internal to us, start moving toward deprecating it by not requiring the user to specify it. In the next release, I plan on working on code to start phasing out the use of a pid file if this is possible.
2018-12-02supervise-daemon: mark a service failed if it respawns too many timesWilliam Hubbs
2018-12-02supervise-daemon: make respawn-max and respawn-period independent settingsWilliam Hubbs
2018-12-02supervise-daemon: add support for a fifoWilliam Hubbs
This will allow us to signal the daemon we are supervising as well as send other commands to the supervisor in the future. This fixes #227.
2018-12-02supervise-daemon: rework signal handling and main loopWilliam Hubbs
This is needed in preparation for adding support for a fifo to allow us to communicate with the supervisor to ask it to signal the child it is supervising.
2018-11-28supervise-daemon: fix type of exiting flagWilliam Hubbs
2018-11-15supervise-daemon: make the pidfile an implementation detailWilliam Hubbs
The pidfile of the supervisor doesn't need to be adjustable by the service script. It is only used so the supervisor can stop itself when the --stop option is used.
2018-11-05supervise-daemon: reap zombiesWilliam Hubbs
We need to make sure to reap zombies so that we can shut down successfully. Fixes #252. Possibly related to #250.
2018-10-23supervise-daemon: add health checksWilliam Hubbs
Health checks are a way to monitor a service and make sure it stays healthy. If a service is not healthy, it will be automatically restarted after running the unhealthy() function to clean up.
2018-10-15supervise-daemon: fix respawn_max off by oneZac Medico
Fix the comparison between respawn_count and respawn_max so that respawn_max = 1 will allow for one respawn. Since respawn_count is incremented before the comparison, use a 'greater than' comparison so that respawn will be triggered when respawn_count is equal to respawn_max. Fixes: https://github.com/OpenRC/openrc/issues/247 Fixes: https://github.com/OpenRC/openrc/issues/248
2018-10-13misc: whitespace fixesAustin English
2018-10-06supervise-daemon: use nanosleep() instead of sleep()William Hubbs
We will be using sigalrm in this process for health checking, and sigalrm cannot be used with sleep() safely.
2018-06-27supervise-daemon.c: clean up memory leaksWilliam Hubbs
2018-06-19supervise-daemon: convert snprintf calls to xasprintfWilliam Hubbs
2018-03-14supervise-daemon: fix off-by-one errorWilliam Hubbs
2018-02-27supervise-daemon: make an error message more verboseWilliam Hubbs
2018-02-22supervise-daemon: zero out the cmdline buffer when it is allocatedWilliam Hubbs
2018-02-21supervise-daemon: remove references to PATH_MAXWilliam Hubbs
2017-11-27fix FreeBSD buildWilliam Hubbs
This is for #186.
2017-10-30fix issue with --reexec callWilliam Hubbs
2017-10-27supervise-daemon: use RC_SVCNAME as the first argument to the daemonWilliam Hubbs
This makes ps show which service the supervisor is monitoring.
2017-10-27supervise-daemon: fix logging for reexec and the child command lineWilliam Hubbs
2017-10-27log as supervise-daemon not the serviceWilliam Hubbs
2017-10-26supervise-daemon: clarify a log messageWilliam Hubbs
2017-10-26supervise-daemon: log the command line we run to spawn the child processWilliam Hubbs
2017-10-26supervise-daemon: log with the service name instead of "supervise-daemon"William Hubbs