Compare commits

...

70 Commits
vapier ... 0.48

Author SHA1 Message Date
William Hubbs
92662ddc44 version 0.48 2023-07-05 16:28:44 -05:00
William Hubbs
1b6a35488d update news for 0.48 release 2023-07-05 16:25:28 -05:00
Petr Vaněk
1eccb7f5e6 man: Remove Duplicate Description of -2/--stderr Flag
This commit removes the secondary mention of the -2/--stderr flag in the
start-stop-daemon man page. The flag's functionality was already
sufficiently described in an earlier section of the text.

Signed-off-by: Petr Vaněk <arkamar@atlas.cz>
2023-05-21 10:57:53 -04:00
Oskari Pirhonen
fe37fc9322 einfo: fix vewend applet args
Fix typo preventing the args for the vewend applet from being handled.
2023-05-14 00:50:03 -04:00
Sam James
edf5f830e3 librc: allow overriding rc_interactive on kernel command line
This was originally introduced in 14625346c0 with
an example list (just one for rc_parallel) of options. Let's add in rc_interactive
as it's a pretty obvious thing one might want to override.

See https://forums.gentoo.org/viewtopic-p-8694588.html.
2023-05-10 21:39:25 -04:00
Dominique Martinet
863e1a5c87 openrc-run: fix rc_parallel race in svc_exec
svc_exec waits until SIGCHLD comes in to close its input, but in
rc_parallel case the SIGCHLD might be unrelated.

Checking the proper pid is found in signal handler and only signaling
signal_pipe the status code directly avoids this problem.
2023-04-24 22:06:53 -05:00
Dominique Martinet
0b9c3c0803 openrc-run: silence lock failures with --no-deps
work around scary warnings described in previous commit
2023-04-24 22:06:41 -05:00
Dominique Martinet
a3c721b682 openrc-run: remove kludge in restart --no-deps
restarting a service with --no-deps ran into a "hairy workaround", which
had a few problems discussed in [1]:
 - it ignores --dry-run, really restarting the requested service
 - if the service was stopped, the program is started but the service
status stays stopped. This makes long-lived services impossible to
(re)start again (pid already exists and running), and the service also
won't stop on shutdown.

The kludge had a long comment describing the following situation:
 - openvpn needs net and dns
 - net restarts dns
 - dns needs net

If the restart in net handled deps, openrc would deadlock waiting for
net in dns' restart, as net won't be started until that is done.

Restarting with --nodeps works around the deadlock, but can display
errors without the kludge (note that the services did start properly
anyway, the problem is that the default service path tries to lock dns
twice from openvn's dep's start and net's start's restart):
---
alpine:~# rc-service openvn start
openvn                   | * Caching service dependencies ...                                                                                                      [ ok ]
net                      |net starting
net                      |dns                       | * Call to flock failed: Resource temporarily unavailable
net                      |dns                       | * ERROR: dns stopped by something else
net                      |net started
dns                      |dns started
openvn                   |openvn started
alpine:~# rc-status | grep s[1-3]
 net                                                               [  started  ]
 dns                                                               [  started  ]
 openvn                                                            [  started  ]
---

Locking again in restart --nodep can fail in two patterns:
 - openvpn's need dependency start was first, and the restart in net
failed (case above): we can just silence locking failures and exit quietly
with restart --no-deps, which is not worse than trying to restart while
another process hold the lock.
 - the restart in net's start was first, and openvpn's need dependency
start failed: not much can be done here short of adding a new status
that a no-deps restart is in progress as in the comment, but this case
can actually just be solved by adjusting dependencies -- and it actually
has already been fixed: the current openvpn init script in alpine only
'use dns', so it will not try to start it, and that will start just
fine with openvpn -> net -> dns only each starting each other once
sequentially.

Another failure pattern is just starting dns directly: that will start
net, which will try to restart dns while we are starting it.
Silencing messages on restart also solves this.

Link: https://github.com/OpenRC/openrc/issues/224 [1]
2023-04-24 22:06:41 -05:00
NRK
3f82d5b1a3 rc: use LIST_FOREACH_SAFE in cleanup()
according to the linux manpage, the "safe" variant may not be available
on all platform. however we bundle our own `queue.h` so this should not
be an issue.
2023-04-24 19:20:19 -05:00
NRK
0b4732520f rc: block SIGCHLD during pid list operations
the pid list will be accessed inside the SIGCHLD signal handler. so we
must ensure SIGCHLD handler doesn't get invoked while the list is at an
inconsistent state making it unsafe to interact with.

Co-authored-by: Dominique MARTINET <dominique.martinet@atmark-techno.com>
Bug: https://github.com/OpenRC/openrc/issues/589#issuecomment-1406588576
2023-04-24 19:20:19 -05:00
NRK
bbd3acfc67 rc: avoid calling free inside SIGCHLD handler
`free` is not async-signal-safe and calling it inside a signal handler
can have bad effects, as reported in the musl ML:
https://www.openwall.com/lists/musl/2023/01/23/1

the solution:

- keep track of weather remove_pid() is being called from inside a
  signal handler or not.
- if it's inside a signal handler then DO NOT call free - instead put
  that pointer into a "to be freed later" list.
- if it's not inside a signal handler then take the "to be freed later"
  list and free anything in it.

Bug: https://github.com/OpenRC/openrc/issues/589
Reported-by: Dominique MARTINET <dominique.martinet@atmark-techno.com>
2023-04-24 19:20:19 -05:00
NRK
910e3e2a0e fstabinfo: deal with EINTR in waitpid call 2023-04-24 19:18:18 -05:00
NRK
5f04dcc951 fstabinfo: replace vfork with posix_spawnp
problem:
* vfork has been removed from POSIX [0].
* clang-tidy flags the `strerror` and `eerror` call inside the vfork-ed
  child as undefined behavior.

solution: use posix_spawnp, which is serves similar purpose and is
specified in posix. and as an added bonus, it's also easier to use and
less lines of code.

[0]: https://www.man7.org/linux/man-pages/man2/vfork.2.html#CONFORMING_TO
2023-04-24 19:18:18 -05:00
Oskari Pirhonen
8f52c64c37 einfo.h: fix EINFO_RESTRICT macro usage
Make function declarations use the EINFO_RESTRICT macro instead of
__EINFO_RESTRICT which gets treated as the name of the argument.
2023-04-23 16:11:15 -04:00
Sam James
09d405fb3e shared: fix pointer type in UNCONST
Thanks to vapier for noticing.
2023-04-20 07:50:49 -04:00
Sam James
36e4e04ba9 meson.build: add -Werror=... for modern C issues
Clang 16 makes these warnings fatal and GCC 14 is likely to as well.
2023-04-19 16:44:51 -04:00
Sam James
eb8831a141 Rename attribute macros to namespaced RC_*
This conflicts with linux-headers which uses __unused for some padding members
on ppc64le at least.

Closes: https://github.com/OpenRC/openrc/issues/622
2023-04-19 16:44:51 -04:00
William Hubbs
0b5cb3abcb version 0.47 2023-04-18 00:14:28 -05:00
William Hubbs
f6ed2c660c update news 2023-04-18 00:13:16 -05:00
Doug Freed
002bcf0b67 rc.conf: note SSD_* vars need exporting 2023-04-17 23:53:18 -05:00
William Hubbs
b9241988a7 init.d/rc.conf: make unicode default to yes 2023-03-07 00:48:43 -06:00
psykose
5ae4d4edb5 rc.conf: default to unicode console
it's the high year of 2023, after all.

closes #607
2023-03-06 22:41:36 -05:00
NRK
95b2948e6e seedrng: fix copyright year
this was mistakenly changed to 2023 instead of 2022-2023 in 63a5ee3d
2023-02-16 07:54:17 -05:00
anon
b73d326387 rc-status: comment consistecy 2023-02-15 22:51:40 -05:00
anon
476272be0c rc-status: all flags respect '-f' 2023-02-15 22:51:40 -05:00
NRK
63a5ee3d8c seedrng: fix memory leak reported by clang-tidy
`seed_dir` gets allocated via xstrdup but never gets freed - which
clang-tidy flags as a memory leak.

instead of free-ing the allocation, just don't allocate to begin with
since there's no need for it.

also bump the copyright year.
2023-02-05 00:38:20 -05:00
NRK
36cc40a9d6 bash-completions/rc-service: don't use grep
Co-authored-by: Mike Frysinger <vapier@gentoo.org>
Closes: https://github.com/OpenRC/openrc/issues/344
2023-02-02 19:37:09 -05:00
NRK
ae5e38dce5 start-stop-daemon: avoid malloc inside sig-handler
same rational as 459783bb

Bug: https://github.com/OpenRC/openrc/issues/589
2023-01-30 22:54:20 -05:00
NRK
5858f980c8 openrc-run: avoid malloc inside sig-handler
same rational as 459783bb

Bug: https://github.com/OpenRC/openrc/issues/589
2023-01-30 22:54:20 -05:00
Sam James
db96295e00 value: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
f5ed484920 swclock: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
00f90f2b0e supervise-daemon: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
b405681926 start-stop-daemon: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
d5700d036a shell_var: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
616f756ca8 shared: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
17cfb41d81 service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
1bc87b7a7c seedrng: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
f3be11a00d rc-update: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
406ab2a4ca rc-status: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
7878a53542 rc-service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
084e6b5e20 rc-depend: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
a7bd13145b rc-abort: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
28ecb38515 openrc-shutdown: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
91737be1ab openrc-run: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
fb6ffc5713 openrc: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
01acbe3c27 openrc-init: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
aa5c3ccd0b mountinfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
d795ea183f mark_service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
5af3944440 librc: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
01bcdb43b6 libeinfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
bcd1975fe7 kill_all: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
57e194df4f is_older_than: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
dacd0ab189 is_newer_than: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
7cfe93d032 fstabinfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
893df75e30 einfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
c80d6bb2ed checkpath: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
bfe38c98a8 src: shared: schedules: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
Sam James
e8a76ad6e6 src: shared: plugin: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
Sam James
7d63049adb src: shared: misc: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
Sam James
dc0b3157a9 src: shared: helpers: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
Sam James
2f6b5b7ef4 openrc: rc-logger: add missing includes to header
Needed for clang-tidy prep work, as it requires headers to work standalone
(which is useful anyway).
2023-01-28 22:14:30 -06:00
NRK
eb3635dd1f swclock: fix codeql warning and upgrade to futimens
this was reported by codeql's scan as a TOCTOU bug. while that's true in
theory, i don't believe it would've had any practical effect.

a better justification for this change might be the fact that it
upgrades from `utime` (which is depreciated by POSIX [0]) to `futimens`.

[0]: https://www.man7.org/linux/man-pages/man3/utime.3p.html#FUTURE_DIRECTIONS
2023-01-28 16:19:33 -05:00
NRK
459783bbad openrc: avoid unnecessary malloc inside sig-handler
malloc (called by xasprintf) is not async-signal-safe. beside, the
string here is constant, so there's no need to malloc it all.

eerrorx isn't async-signal-safe either (due to calling fprintf and exit)
but consequence of them are _typically_ not as grave as calling malloc
while it's internal state is inconsistent.

Bug: https://github.com/OpenRC/openrc/issues/589
2023-01-28 13:08:00 -05:00
Sam James
a28bdc7e5c openrc-shutdown: mark handler as noreturn, use _unused macro 2023-01-25 01:11:25 -05:00
Sam James
bcae7d03b4 openrc: mark handle_bad_signal as noreturn
For -Wmissing-noreturn.
2023-01-25 00:51:13 -05:00
Sam James
ccc2b71145 supervise-daemon: mark various functions as noreturn
For -Wmissing-noreturn.
2023-01-25 00:50:43 -05:00
Sam James
78c0693c50 openrc-shutdown: mark stop_shutdown as noreturn, fix typo/indentation
For -Wmissing-noreturn.
2023-01-25 00:50:15 -05:00
Sam James
ddf4a3a7a0 shared: move _noreturn definition into helpers.h 2023-01-25 00:49:47 -05:00
Sam James
a6568c304f libeinfo: fix -Wunused-but-set-variable 2023-01-25 00:49:22 -05:00
Sam James
d6a5264a9d librc: fix 'init' memory leak
From scan-build w/ clang-16.0.0_pre20230107:
```
../src/librc/librc.c:759:14: warning: Potential leak of memory pointed to by 'init' [unix.Malloc]
                                                return false;
                                                       ^~~~~
```
2023-01-25 00:48:26 -05:00
56 changed files with 404 additions and 403 deletions

View File

@@ -4,6 +4,15 @@ OpenRC NEWS
This file will contain a list of notable changes for each release. Note
the information in this file is in reverse order.
## OpenRC 0.48
This release is a maintenance release; it has no user-facing changes.
## OpenRC 0.47
This release is primarily an internal cleanup release.
The only user-visible difference is that unicode is now on by default.
## OpenRC 0.46
The path for the reference file for the swclock service is now

View File

@@ -85,9 +85,9 @@ _rc_service()
else
# no option was typed
if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed
words="$(rc-service --list | grep ^${cur})" # complete for init scripts
COMPREPLY=($(for i in ${words} ; do \
[[ ${i} == ${cur}* ]] && echo ${i} ; \
# complete for init scripts
COMPREPLY=($(for i in $(rc-service --list) ; do \
[[ ${i} == "${cur}"* ]] && echo ${i} ; \
done))
return 0
elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
@@ -105,9 +105,8 @@ _rc_service()
fi
if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
[[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then
words="$(rc-service --list | grep ^${cur})"
COMPREPLY=($(for i in ${words} ; do \
[[ ${i} == ${cur}* ]] && echo ${i} ; \
COMPREPLY=($(for i in $(rc-service --list) ; do \
[[ ${i} == "${cur}"* ]] && echo ${i} ; \
done))
return 0
fi

View File

@@ -88,8 +88,8 @@
# MISC CONFIGURATION VARIABLES
# There variables are shared between many init scripts
# Set unicode to YES to turn on unicode support for keyboards and screens.
#unicode="NO"
# Set unicode to NO to turn off unicode support for keyboards and screens.
#unicode="YES"
# This is how long fuser should wait for a remote server to respond. The
# default is 60 seconds, but it can be adjusted here.
@@ -116,12 +116,13 @@
# Some daemons are started and stopped via start-stop-daemon.
# We can set some things on a per service basis, like the nicelevel.
#SSD_NICELEVEL="0"
# These need to be exported
#export SSD_NICELEVEL="0"
# Or the ionice level. The format is class[:data] , just like the
# --ionice start-stop-daemon parameter.
#SSD_IONICELEVEL="0:0"
#export SSD_IONICELEVEL="0:0"
# Or the OOM score adjustment.
#SSD_OOM_SCORE_ADJ="0"
#export SSD_OOM_SCORE_ADJ="0"
# Pass ulimit parameters
# If you are using bash in POSIX mode for your shell, note that the

View File

@@ -42,7 +42,7 @@ start()
fi
local wkeys= kmode="-a" msg="ASCII"
if yesno $unicode; then
if yesno ${unicode:-yes}; then
kmode="-u"
msg="UTF-8"
fi

View File

@@ -25,7 +25,7 @@ start()
# Save the encoding for use immediately at boot
if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
if yesno ${unicode:-${UNICODE}}; then
if yesno ${unicode:-yes}; then
echo "" > "$RC_LIBEXECDIR"/console/unicode
else
rm -f "$RC_LIBEXECDIR"/console/unicode

View File

@@ -28,7 +28,7 @@ start()
# Set terminal encoding to either ASCII or UNICODE.
# See utf-8(7) for more information.
local termencoding="%@" termmsg="ASCII"
if yesno ${unicode}; then
if yesno ${unicode:-yes}; then
termencoding="%G"
termmsg="UTF-8"
fi
@@ -43,7 +43,7 @@ start()
# Save the encoding for use immediately at boot
if checkpath -W "$RC_LIBEXECDIR"; then
mkdir -p "$RC_LIBEXECDIR"/console
if yesno ${unicode:-${UNICODE}}; then
if yesno ${unicode:-yes}; then
echo "" > "$RC_LIBEXECDIR"/console/unicode
else
rm -f "$RC_LIBEXECDIR"/console/unicode

View File

@@ -183,10 +183,6 @@ Wait
after starting and check that daemon is still running.
Useful for daemons that check configuration after forking or stopping race
conditions where the pidfile is written out after forking.
.It Fl 2 , -stderr Ar logfile
The same thing as
.Fl 1 , -stdout
but with the standard error output.
.El
.Pp
These options are only used for stopping daemons:

View File

@@ -1,5 +1,5 @@
project('OpenRC', 'c',
version : '0.46',
version : '0.48',
license: 'BSD-2',
default_options : [
'c_std=c99',
@@ -176,7 +176,10 @@ cc_warning_flags_test = [
'-Wsequence-point',
'-Wshadow',
'-Wwrite-strings',
'-Werror=implicit-int',
'-Werror=implicit-function-declaration',
'-Werror=int-conversion',
'-Werror=incompatible-function-pointer-types',
]
cc_warning_flags = cc.get_supported_arguments(cc_warning_flags_test)
cc_flags = [cc_debug_flags, cc_os_flags, cc_warning_flags]

View File

@@ -17,25 +17,24 @@
*/
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
#include <libgen.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "einfo.h"
#include "rc.h"
#include "misc.h"
#include "selinux.h"
#include "_usage.h"
#include "helpers.h"
typedef enum {
inode_unknown = 0,

View File

@@ -12,20 +12,17 @@
#define SYSLOG_NAMES
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include <strings.h>
#include "einfo.h"
#include "helpers.h"
@@ -81,7 +78,7 @@ int main(int argc, char **argv)
if (strcmp(applet, "eend") == 0 ||
strcmp(applet, "ewend") == 0 ||
strcmp(applet, "veend") == 0 ||
strcmp(applet, "vweend") == 0 ||
strcmp(applet, "vewend") == 0 ||
strcmp(applet, "ewaitfile") == 0)
{
errno = 0;

View File

@@ -16,13 +16,14 @@
*/
#include <sys/wait.h>
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <spawn.h>
/* Yay for linux and its non liking of POSIX functions.
Okay, we could use getfsent but the man page says use getmntent instead
@@ -30,6 +31,7 @@
#ifdef __linux__
# define HAVE_GETMNTENT
# include <mntent.h>
# define ENT mntent
# define START_ENT fp = setmntent ("/etc/fstab", "r");
# define GET_ENT getmntent (fp)
@@ -43,6 +45,7 @@
#else
# define HAVE_GETFSENT
# include <fstab.h>
# define ENT fstab
# define START_ENT
# define GET_ENT getfsent ()
@@ -58,8 +61,10 @@
#include "einfo.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
extern char **environ;
const char *applet = NULL;
const char *extraopts = NULL;
@@ -110,7 +115,7 @@ do_mount(struct ENT *ent, bool remount)
{
char *argv[10];
pid_t pid;
int status;
int status, err;
argv[0] = UNCONST("mount");
argv[1] = UNCONST("-o");
@@ -135,23 +140,14 @@ do_mount(struct ENT *ent, bool remount)
argv[8] = NULL;
#endif
}
switch (pid = vfork()) {
case -1:
eerrorx("%s: vfork: %s", applet, strerror(errno));
/* NOTREACHED */
case 0:
execvp(argv[0], argv);
eerror("%s: execvp: %s", applet, strerror(errno));
_exit(EXIT_FAILURE);
/* NOTREACHED */
default:
waitpid(pid, &status, 0);
if (WIFEXITED(status))
return WEXITSTATUS(status);
else
return -1;
/* NOTREACHED */
}
err = posix_spawnp(&pid, argv[0], NULL, NULL, argv, environ);
if (err)
eerrorx("%s: posix_spawnp: %s", applet, strerror(err));
while (waitpid(pid, &status, 0) < 0 && errno == EINTR);
if (WIFEXITED(status))
return WEXITSTATUS(status);
else
return -1;
}
#define OUTPUT_FILE (1 << 1)

View File

@@ -10,13 +10,9 @@
* except according to the terms contained in the LICENSE file.
*/
#include <errno.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include "rc.h"
#include "misc.h"
int main(int argc, char **argv)
{

View File

@@ -10,13 +10,9 @@
* except according to the terms contained in the LICENSE file.
*/
#include <errno.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include "rc.h"
#include "misc.h"
int main(int argc, char **argv)
{

View File

@@ -19,7 +19,6 @@
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -28,11 +27,12 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdbool.h>
#include "einfo.h"
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
const char *applet = NULL;
const char *extraopts = "[signal number]";

View File

@@ -13,13 +13,8 @@
#ifndef __EINFO_H__
#define __EINFO_H__
#if defined(__GNUC__)
# define EINFO_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
# define EINFO_XPRINTF(a, b) __attribute__((__noreturn__,__format__(__printf__, a, b)))
#else
# define EINFO_PRINTF(a, b)
# define EINFO_XPRINTF(a, b)
#endif
#define EINFO_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
#define EINFO_XPRINTF(a, b) __attribute__((__noreturn__, __format__(__printf__, a, b)))
#include <sys/types.h>
#include <stdbool.h>
@@ -74,22 +69,22 @@ void elog(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
* The x suffix means function will exit() returning failure.
*/
/*@{*/
int einfon(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int eerrorn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int einfo(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
void ewarnx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
int eerror(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
void eerrorx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
int einfon(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int eerrorn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int einfo(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
void ewarnx(const char * EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
int eerror(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
void eerrorx(const char * EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
int einfovn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ebeginvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int eendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int ewendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int einfov(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnv(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int einfovn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnvn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ebeginvn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int eendvn(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int ewendvn(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int einfov(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnv(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
/*@}*/
/*! @ingroup ebegin

View File

@@ -15,16 +15,12 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -677,15 +673,14 @@ ewarn(const char *EINFO_RESTRICT fmt, ...)
void
ewarnx(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (fmt && !is_quiet()) {
va_start(ap, fmt);
elogv(LOG_WARNING, fmt, ap);
retval = _ewarnvn(fmt, ap);
_ewarnvn(fmt, ap);
va_end(ap);
retval += fprintf(stderr, "\n");
fprintf(stderr, "\n");
}
exit(EXIT_FAILURE);
}

View File

@@ -15,10 +15,21 @@
* except according to the terms contained in the LICENSE file.
*/
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "queue.h"
#include "librc.h"
#include "helpers.h"
#if defined(__linux__) || (defined (__FreeBSD_kernel__) && defined(__GLIBC__)) \
|| defined(__GNU__)

View File

@@ -16,9 +16,22 @@
*/
#include <sys/utsname.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "queue.h"
#include "librc.h"
#include "helpers.h"
#include "misc.h"
#define GENDEP RC_LIBEXECDIR "/sh/gendepends.sh"

View File

@@ -16,11 +16,21 @@
*/
#include <fnmatch.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/stat.h>
#include "queue.h"
#include "librc.h"
#include "helpers.h"
#include "misc.h"
bool
rc_yesno(const char *value)
@@ -117,7 +127,7 @@ rc_getline(char **line, size_t *len, FILE *fp)
}
char *
rc_proc_getent(const char *ent _unused)
rc_proc_getent(const char *ent RC_UNUSED)
{
#ifdef __linux__
FILE *fp;
@@ -277,6 +287,7 @@ static RC_STRINGLIST *rc_config_kcl(RC_STRINGLIST *config)
overrides = rc_stringlist_new();
/* A list of variables which may be overridden on the kernel command line */
rc_stringlist_add(overrides, "rc_interactive");
rc_stringlist_add(overrides, "rc_parallel");
TAILQ_FOREACH(override, overrides, entries) {

View File

@@ -15,8 +15,14 @@
* except according to the terms contained in the LICENSE file.
*/
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "queue.h"
#include "librc.h"
#include "helpers.h"
RC_STRINGLIST *
rc_stringlist_new(void)

View File

@@ -15,9 +15,26 @@
* except according to the terms contained in the LICENSE file.
*/
#include <helpers.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#include <regex.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include "queue.h"
#include "librc.h"
#include <helpers.h>
#include "misc.h"
#include "rc.h"
#ifdef __FreeBSD__
# include <sys/sysctl.h>
#endif
@@ -232,7 +249,7 @@ detect_prefix(const char *systype)
}
static const char *
detect_container(const char *systype _unused)
detect_container(const char *systype RC_UNUSED)
{
#ifdef __FreeBSD__
if (systype) {
@@ -296,7 +313,7 @@ detect_container(const char *systype _unused)
}
static const char *
detect_vm(const char *systype _unused)
detect_vm(const char *systype RC_UNUSED)
{
#ifdef __NetBSD__
if (systype) {
@@ -755,8 +772,10 @@ rc_service_mark(const char *service, const RC_SERVICE state)
RC_SVCDIR "/%s/%s",
rc_parse_service_state(RC_SERVICE_WASINACTIVE),
base);
if (symlink(init, was) == -1)
if (symlink(init, was) == -1) {
free(init);
return false;
}
skip_wasinactive = true;
}
if (unlink(file) == -1) {

View File

@@ -25,7 +25,6 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>

View File

@@ -10,24 +10,18 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include "einfo.h"
#include "rc.h"
#include "misc.h"
#include "helpers.h"
const char *applet = NULL;

View File

@@ -15,15 +15,14 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/param.h>
#if defined(__DragonFly__) || defined(__FreeBSD__)
# include <sys/ucred.h>
# include <sys/mount.h>
# define F_FLAGS f_flags
#elif defined(BSD) && !defined(__GNU__)
# include <sys/statvfs.h>
# define statfs statvfs
# define F_FLAGS f_flag
#elif defined(__linux__) || (defined(__FreeBSD_kernel__) && \
@@ -33,17 +32,19 @@
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include <regex.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "einfo.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
const char *applet = NULL;
const char *procmounts = "/proc/mounts";

View File

@@ -27,16 +27,16 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/reboot.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <utmp.h>
#ifdef HAVE_SELINUX
# include <selinux/selinux.h>
#endif
#include "helpers.h"
#include "rc.h"
#include "plugin.h"
#include "wtmp.h"

View File

@@ -15,28 +15,26 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <getopt.h>
#include <libgen.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <stdbool.h>
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) \
|| defined(__GNU__)
@@ -54,6 +52,7 @@
#include "plugin.h"
#include "selinux.h"
#include "_usage.h"
#include "helpers.h"
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
@@ -108,8 +107,9 @@ static RC_STRINGLIST *deptypes_mwua; /* need+want+use+after deps for stopping */
static void
handle_signal(int sig)
{
int serrno = errno;
char *signame = NULL;
int serrno = errno, status;
pid_t pid;
const char *signame = NULL;
struct winsize ws;
switch (sig) {
@@ -118,12 +118,13 @@ handle_signal(int sig)
break;
case SIGCHLD:
if (signal_pipe[1] > -1) {
if (write(signal_pipe[1], &sig, sizeof(sig)) == -1)
eerror("%s: send: %s",
service, strerror(errno));
} else
rc_waitpid(-1);
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
if (signal_pipe[1] > -1 && pid == service_pid) {
if (write(signal_pipe[1], &status, sizeof(status)) == -1)
eerror("%s: send: %s",
service, strerror(errno));
}
}
break;
case SIGWINCH:
@@ -135,20 +136,19 @@ handle_signal(int sig)
case SIGINT:
if (!signame)
xasprintf(&signame, "SIGINT");
signame = "SIGINT";
/* FALLTHROUGH */
case SIGTERM:
if (!signame)
xasprintf(&signame, "SIGTERM");
signame = "SIGTERM";
/* FALLTHROUGH */
case SIGQUIT:
if (!signame)
xasprintf(&signame, "SIGQUIT");
signame = "SIGQUIT";
/* Send the signal to our children too */
if (service_pid > 0)
kill(service_pid, sig);
eerror("%s: caught %s, aborting", applet, signame);
free(signame);
exit(EXIT_FAILURE);
/* NOTREACHED */
@@ -440,6 +440,7 @@ svc_exec(const char *arg1, const char *arg2)
if (errno != EINTR) {
eerror("%s: poll: %s",
service, strerror(errno));
ret = -1;
break;
}
}
@@ -450,9 +451,20 @@ svc_exec(const char *arg1, const char *arg2)
write_prefix(buffer, bytes, &prefixed);
}
/* Only SIGCHLD signals come down this pipe */
if (fd[0].revents & (POLLIN | POLLHUP))
/* signal_pipe receives service_pid's exit status */
if (fd[0].revents & (POLLIN | POLLHUP)) {
if ((s = read(signal_pipe[0], &ret, sizeof(ret))) != sizeof(ret)) {
eerror("%s: receive failed: %s", service,
s < 0 ? strerror(errno) : "short read");
ret = -1;
break;
}
ret = WEXITSTATUS(ret);
if (ret != 0 && errno == ECHILD)
/* killall5 -9 could cause this */
ret = 0;
break;
}
}
}
@@ -475,11 +487,6 @@ svc_exec(const char *arg1, const char *arg2)
master_tty = -1;
}
ret = rc_waitpid(service_pid);
ret = WEXITSTATUS(ret);
if (ret != 0 && errno == ECHILD)
/* killall5 -9 could cause this */
ret = 0;
service_pid = 0;
return ret;
@@ -614,7 +621,7 @@ svc_start_check(void)
}
if (exclusive_fd == -1)
exclusive_fd = svc_lock(applet);
exclusive_fd = svc_lock(applet, !deps);
if (exclusive_fd == -1) {
if (errno == EACCES)
eerrorx("%s: superuser access required", applet);
@@ -866,7 +873,7 @@ svc_stop_check(RC_SERVICE *state)
exit(EXIT_FAILURE);
if (exclusive_fd == -1)
exclusive_fd = svc_lock(applet);
exclusive_fd = svc_lock(applet, !deps);
if (exclusive_fd == -1) {
if (errno == EACCES)
eerrorx("%s: superuser access required", applet);
@@ -1043,26 +1050,6 @@ svc_stop(void)
static void
svc_restart(void)
{
/* This is hairy and a better way needs to be found I think!
* The issue is this - openvpn need net and dns. net can restart
* dns via resolvconf, so you could have openvpn trying to restart
* dnsmasq which in turn is waiting on net which in turn is waiting
* on dnsmasq.
* The work around is for resolvconf to restart its services with
* --nodeps which means just that.
* The downside is that there is a small window when our status is
* invalid.
* One workaround would be to introduce a new status,
* or status locking. */
if (!deps) {
RC_SERVICE state = rc_service_state(service);
if (state & RC_SERVICE_STARTED || state & RC_SERVICE_INACTIVE)
svc_exec("stop", "start");
else
svc_exec("start", NULL);
return;
}
if (!(rc_service_state(service) & RC_SERVICE_STOPPED)) {
get_started_services();
svc_stop();

View File

@@ -12,24 +12,23 @@
* This file may not be copied, modified, propagated, or distributed
* except according to the terms contained in the LICENSE file.
*/
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <stdio.h>
#include <utmp.h>
#include <utmpx.h>
#include <pwd.h>
#include <fcntl.h>
#include <paths.h>
#include <pwd.h>
#include <signal.h>
#include <setjmp.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <time.h>
#include <unistd.h>
#include <utmpx.h>
#include "broadcast.h"
#include "helpers.h"
@@ -43,12 +42,7 @@ static sigjmp_buf jbuf;
/*
* Alarm handler
*/
/*ARGSUSED*/
# ifdef __GNUC__
static void handler(int arg __attribute__((unused)))
# else
static void handler(int arg)
# endif
RC_NORETURN static void handler(int arg RC_UNUSED)
{
siglongjmp(jbuf, 1);
}

View File

@@ -19,6 +19,7 @@
* except according to the terms contained in the LICENSE file.
*/
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include <stdbool.h>
@@ -26,9 +27,11 @@
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <strings.h>
#include <unistd.h>
#include <time.h>
#include <utmp.h>
#include "broadcast.h"
#include "einfo.h"
@@ -167,13 +170,13 @@ static void sleep_no_interrupt(int seconds)
duration = remaining;
}
static void stop_shutdown(int sig)
RC_NORETURN static void stop_shutdown(int sig)
{
(void) sig;
unlink(nologin_file);
unlink(shutdown_pid);
einfo("Shutdown canceled");
exit(0);
einfo("Shutdown cancelled");
exit(0);
}
int main(int argc, char **argv)

View File

@@ -17,11 +17,10 @@
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "einfo.h"
#include "sysvinit.h"

View File

@@ -16,10 +16,7 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <poll.h>
@@ -27,6 +24,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
@@ -42,9 +42,9 @@
#include "einfo.h"
#include "rc-logger.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "helpers.h"
#define TMPLOG RC_SVCDIR "/rc.log"
#define DEFAULTLOG "/var/log/rc.log"

View File

@@ -13,6 +13,9 @@
#ifndef RC_LOGGER_H
#define RC_LOGGER_H
#include <stdbool.h>
#include <sys/types.h>
extern pid_t rc_logger_pid;
extern int rc_logger_tty;
extern bool rc_in_logger;

View File

@@ -20,26 +20,21 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <errno.h>
#include <dirent.h>
#include <ctype.h>
#include <getopt.h>
#include <libgen.h>
#include <limits.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <strings.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <termios.h>
#include <unistd.h>
@@ -49,9 +44,9 @@
#include "rc-logger.h"
#include "misc.h"
#include "plugin.h"
#include "version.h"
#include "_usage.h"
#include "helpers.h"
const char *extraopts = NULL;
const char getoptstring[] = "a:no:s:S" getoptstring_COMMON;
@@ -92,6 +87,7 @@ static RC_HOOK hook_out;
struct termios *termios_orig = NULL;
RC_PIDLIST service_pids;
RC_PIDLIST free_these_pids;
static void
clean_failed(void)
@@ -121,8 +117,7 @@ clean_failed(void)
static void
cleanup(void)
{
RC_PID *p1 = LIST_FIRST(&service_pids);
RC_PID *p2;
RC_PID *p, *tmp;
if (!rc_in_logger && !rc_in_plugin &&
applet && (strcmp(applet, "rc") == 0 || strcmp(applet, "openrc") == 0))
@@ -144,10 +139,13 @@ cleanup(void)
rc_logger_close();
}
while (p1) {
p2 = LIST_NEXT(p1, entries);
free(p1);
p1 = p2;
LIST_FOREACH_SAFE(p, &service_pids, entries, tmp) {
LIST_REMOVE(p, entries);
free(p);
}
LIST_FOREACH_SAFE(p, &free_these_pids, entries, tmp) {
LIST_REMOVE(p, entries);
free(p);
}
rc_stringlist_free(main_hotplugged_services);
@@ -349,22 +347,46 @@ static char *get_krunlevel(void)
static void
add_pid(pid_t pid)
{
sigset_t sset, old;
RC_PID *p = xmalloc(sizeof(*p));
p->pid = pid;
/* this list will be accessed inside the SIGCHLD signal handler.
* so we need to ensure that the SIGCHLD handler doesn't get invoked
* while the list is at an inconsistent state.
*/
sigemptyset(&sset);
sigaddset(&sset, SIGCHLD);
sigprocmask(SIG_SETMASK, &sset, &old);
LIST_INSERT_HEAD(&service_pids, p, entries);
sigprocmask(SIG_SETMASK, &old, NULL);
}
static void
remove_pid(pid_t pid)
remove_pid(pid_t pid, bool inside_signal)
{
RC_PID *p;
sigset_t sset, old;
RC_PID *p, *tmp;
LIST_FOREACH(p, &service_pids, entries)
if (p->pid == pid) {
LIST_REMOVE(p, entries);
free(p);
return;
}
/* same rationale for blocking SIGCHLD as add_pid() */
sigemptyset(&sset);
sigaddset(&sset, SIGCHLD);
sigprocmask(SIG_SETMASK, &sset, &old);
LIST_FOREACH(p, &service_pids, entries) {
if (p->pid == pid) {
LIST_REMOVE(p, entries);
LIST_INSERT_HEAD(&free_these_pids, p, entries);
break;
}
}
/* only call free if we're not inside a signal handler */
if (!inside_signal) {
LIST_FOREACH_SAFE(p, &free_these_pids, entries, tmp) {
LIST_REMOVE(p, entries);
free(p);
}
}
sigprocmask(SIG_SETMASK, &old, NULL);
}
static void
@@ -382,7 +404,7 @@ static void
handle_signal(int sig)
{
int serrno = errno;
char *signame = NULL;
const char *signame = NULL;
pid_t pid;
RC_PID *pi;
int status = 0;
@@ -402,7 +424,7 @@ handle_signal(int sig)
/* Remove that pid from our list */
if (pid > 0)
remove_pid(pid);
remove_pid(pid, true);
break;
case SIGWINCH:
@@ -414,15 +436,15 @@ handle_signal(int sig)
case SIGINT:
if (!signame)
xasprintf(&signame, "SIGINT");
signame = "SIGINT";
/* FALLTHROUGH */
case SIGTERM:
if (!signame)
xasprintf(&signame, "SIGTERM");
signame = "SIGTERM";
/* FALLTHROUGH */
case SIGQUIT:
if (!signame)
xasprintf(&signame, "SIGQUIT");
signame = "SIGQUIT";
eerrorx("%s: caught %s, aborting", applet, signame);
/* NOTREACHED */
case SIGUSR1:
@@ -611,7 +633,7 @@ stop:
add_pid(pid);
if (!parallel) {
rc_waitpid(pid);
remove_pid(pid);
remove_pid(pid, false);
}
}
}
@@ -677,7 +699,7 @@ do_start_services(const RC_STRINGLIST *start_services, bool parallel)
add_pid(pid);
if (!parallel) {
rc_waitpid(pid);
remove_pid(pid);
remove_pid(pid, false);
}
}
}
@@ -695,7 +717,7 @@ do_start_services(const RC_STRINGLIST *start_services, bool parallel)
}
#ifdef RC_DEBUG
static void
RC_NORETURN static void
handle_bad_signal(int sig)
{
char pid[10];
@@ -750,6 +772,7 @@ int main(int argc, char **argv)
applet = basename_c(argv[0]);
LIST_INIT(&service_pids);
LIST_INIT(&free_these_pids);
atexit(cleanup);
if (!applet)
eerrorx("arguments required");

View File

@@ -10,20 +10,11 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include "einfo.h"

View File

@@ -15,27 +15,20 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
#include "einfo.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
const char *applet = NULL;
const char *extraopts = NULL;

View File

@@ -15,7 +15,9 @@
* except according to the terms contained in the LICENSE file.
*/
#include <errno.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -24,8 +26,8 @@
#include "einfo.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
const char *applet = NULL;
const char *extraopts = NULL;

View File

@@ -16,17 +16,21 @@
*/
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <inttypes.h>
#include <errno.h>
#include <time.h>
#include "einfo.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
enum format_t {
FORMAT_DEFAULT,
@@ -61,8 +65,8 @@ const char * const longopts_help[] = {
longopts_help_COMMON
};
const char *usagestring = "" \
"Usage: rc-status [options] -f ini <runlevel>...\n" \
" or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]";
"Usage: rc-status [options] [-f ini] <runlevel>...\n" \
" or: rc-status [options] [-f ini] [-a | -c | -l | -m | -r | -s | -u]";
static RC_DEPTREE *deptree;
static RC_STRINGLIST *types;
@@ -293,6 +297,7 @@ int main(int argc, char **argv)
TAILQ_FOREACH(l, levels, entries)
printf("%s\n", l->value);
goto exit;
/* NOTREACHED */
case 'm':
services = rc_services_in_runlevel(NULL);
levels = rc_runlevel_list();
@@ -312,8 +317,9 @@ int main(int argc, char **argv)
free(s->value);
free(s);
}
print_services(NULL, services, FORMAT_DEFAULT);
print_services(NULL, services, format);
goto exit;
/* NOTREACHED */
case 'r':
runlevel = rc_runlevel_get();
printf("%s\n", runlevel);
@@ -324,12 +330,12 @@ int main(int argc, char **argv)
TAILQ_FOREACH_SAFE(s, services, entries, t)
if (!rc_service_value_get(s->value, "child_pid"))
TAILQ_REMOVE(services, s, entries);
print_services(NULL, services, FORMAT_DEFAULT);
print_services(NULL, services, format);
goto exit;
/* NOTREACHED */
case 's':
services = rc_services_in_runlevel(NULL);
print_services(NULL, services, FORMAT_DEFAULT);
print_services(NULL, services, format);
goto exit;
/* NOTREACHED */
case 'u':
@@ -344,7 +350,7 @@ int main(int argc, char **argv)
break;
}
}
print_services(NULL, services, FORMAT_DEFAULT);
print_services(NULL, services, format);
goto exit;
/* NOTREACHED */
@@ -444,6 +450,7 @@ int main(int argc, char **argv)
* be added to the list
*/
unsetenv("RC_SVCNAME");
print_level("Dynamic", "needed/wanted", format);
print_services(NULL, nservices, format);
print_level("Dynamic", "manual", format);

View File

@@ -17,7 +17,6 @@
#include <errno.h>
#include <getopt.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -29,6 +28,7 @@
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
const char *applet = NULL;
const char *extraopts = NULL;

View File

@@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2022 The OpenRC Authors.
* Copyright (c) 2022-2023 The OpenRC Authors.
* See the Authors file at the top-level directory of this distribution and
* https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
*
@@ -30,12 +30,12 @@
#include <errno.h>
#include <endian.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "rc.h"
#include "einfo.h"
#include "helpers.h"
#include "_usage.h"
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
static const char seedrng_prefix[] = "SeedRNG v1 Old+New Prefix";
static const char seedrng_failure[] = "SeedRNG v1 No New Seed Failure";
int opt, fd, dfd, program_ret = 0;
char *seed_dir = NULL;
const char *seed_dir = NULL;
uint8_t new_seed[MAX_SEED_LEN];
size_t new_seed_len;
bool new_seed_creditable;
@@ -470,7 +470,7 @@ int main(int argc, char **argv)
switch (opt) {
case LONGOPT_SEED_DIR:
if (!seed_dir)
seed_dir = xstrdup(optarg);
seed_dir = optarg;
break;
case LONGOPT_SKIP_CREDIT:
skip_credit = true;
@@ -479,7 +479,7 @@ int main(int argc, char **argv)
}
}
if (!seed_dir)
seed_dir = xstrdup(DEFAULT_SEED_DIR);
seed_dir = DEFAULT_SEED_DIR;
if (getuid())
eerrorx("%s: superuser access is required", applet);
umask(0077);

View File

@@ -10,24 +10,16 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include "einfo.h"
#include "rc.h"
#include "misc.h"
#include "helpers.h"
const char *applet = NULL;

View File

@@ -13,19 +13,13 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "version.h"
#include "helpers.h"
#if lint
# define _noreturn
#endif
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
# define _noreturn __attribute__ ((__noreturn__))
#else
# define _noreturn
#endif
void set_quiet_options(void)
{
@@ -42,7 +36,7 @@ void set_quiet_options(void)
}
}
_noreturn void show_version(void)
RC_NORETURN void show_version(void)
{
const char *systype = NULL;
@@ -57,7 +51,7 @@ _noreturn void show_version(void)
exit(EXIT_SUCCESS);
}
_noreturn void usage(int exit_status)
RC_NORETURN void usage(int exit_status)
{
const char * const has_arg[] = { "", "<arg>", "[arg]" };
int i;

View File

@@ -11,6 +11,7 @@
*/
#include <getopt.h>
#include <stdlib.h>
#define getoptstring_COMMON "ChqVv"

View File

@@ -18,22 +18,22 @@
#ifndef __HELPERS_H__
#define __HELPERS_H__
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
#ifdef lint
# define _unused
#endif
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
# define _dead __attribute__((__noreturn__))
# define _unused __attribute__((__unused__))
# define _xasprintf(a, b) __attribute__((__format__(__printf__, a, b)))
#else
# define _dead
# define _unused
# define _xasprintf(a, b)
#endif
#define RC_UNUSED __attribute__((__unused__))
#define RC_NORETURN __attribute__((__noreturn__))
#define RC_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
@@ -55,11 +55,7 @@
} while (/* CONSTCOND */ 0)
#endif
#include <stdarg.h>
#include <stdbool.h>
#include <sys/stat.h>
_unused static void *xmalloc (size_t size)
RC_UNUSED static void *xmalloc (size_t size)
{
void *value = malloc(size);
@@ -70,7 +66,7 @@ _unused static void *xmalloc (size_t size)
/* NOTREACHED */
}
_unused static void *xrealloc(void *ptr, size_t size)
RC_UNUSED static void *xrealloc(void *ptr, size_t size)
{
void *value = realloc(ptr, size);
@@ -81,7 +77,7 @@ _unused static void *xrealloc(void *ptr, size_t size)
/* NOTREACHED */
}
_unused static char *xstrdup(const char *str)
RC_UNUSED static char *xstrdup(const char *str)
{
char *value;
@@ -103,7 +99,7 @@ _unused static char *xstrdup(const char *str)
* basename_c never modifies the argument. As such, if there is a trailing
* slash then an empty string is returned.
*/
_unused static const char *basename_c(const char *path)
RC_UNUSED static const char *basename_c(const char *path)
{
const char *slash = strrchr(path, '/');
@@ -112,14 +108,14 @@ _unused static const char *basename_c(const char *path)
return (path);
}
_unused static bool exists(const char *pathname)
RC_UNUSED static bool exists(const char *pathname)
{
struct stat buf;
return (stat(pathname, &buf) == 0);
}
_unused static bool existss(const char *pathname)
RC_UNUSED static bool existss(const char *pathname)
{
struct stat buf;
@@ -129,12 +125,12 @@ _unused static bool existss(const char *pathname)
/*
* This is an OpenRC specific version of the asprintf() function.
* We do this to avoid defining the _GNU_SOURCE feature test macro on
* glibc systems and to insure that we have a consistent function across
* glibc systems and to ensure that we have a consistent function across
* platforms. This also allows us to call our xmalloc and xrealloc
* functions to handle memory allocation.
* this function was originally written by Mike Frysinger.
*/
_unused _xasprintf(2,3) static int xasprintf(char **strp, const char *fmt, ...)
RC_UNUSED RC_PRINTF(2,3) static int xasprintf(char **strp, const char *fmt, ...)
{
va_list ap;
int len;

View File

@@ -15,22 +15,21 @@
* except according to the terms contained in the LICENSE file.
*/
#include <sys/file.h>
#include <sys/types.h>
#include <sys/utsname.h>
#ifdef __linux__
# include <sys/sysinfo.h>
#endif
#include <sys/time.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/time.h>
#ifdef __linux__
# include <sys/sysinfo.h>
#endif
#include <sys/types.h>
#include <sys/utsname.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
@@ -40,6 +39,7 @@
#include "rc.h"
#include "misc.h"
#include "version.h"
#include "helpers.h"
extern char **environ;
@@ -234,7 +234,7 @@ signal_setup_restart(int sig, void (*handler)(int))
}
int
svc_lock(const char *applet)
svc_lock(const char *applet, bool ignore_lock_failure)
{
char *file = NULL;
int fd;
@@ -245,6 +245,14 @@ svc_lock(const char *applet)
if (fd == -1)
return -1;
if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
if (ignore_lock_failure) {
/* Two services with a need b, and b's start()
* calling restart --no-deps on a would cause
* harmless errors: just ignore them.
* See https://github.com/OpenRC/openrc/issues/224
*/
exit(EXIT_SUCCESS);
}
eerror("Call to flock failed: %s", strerror(errno));
close(fd);
return -1;
@@ -274,7 +282,7 @@ exec_service(const char *service, const char *arg)
sigset_t old;
struct sigaction sa;
fd = svc_lock(basename_c(service));
fd = svc_lock(basename_c(service), false);
if (fd == -1)
return -1;

View File

@@ -19,6 +19,7 @@
#define __RC_MISC_H__
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -27,6 +28,7 @@
#include <unistd.h>
#include "helpers.h"
#include "rc.h"
#define RC_LEVEL_BOOT "boot"
#define RC_LEVEL_DEFAULT "default"
@@ -48,7 +50,7 @@ void env_filter(void);
void env_config(void);
int signal_setup(int sig, void (*handler)(int));
int signal_setup_restart(int sig, void (*handler)(int));
int svc_lock(const char *);
int svc_lock(const char *, bool);
int svc_unlock(const char *, int);
pid_t exec_service(const char *, const char *);

View File

@@ -17,12 +17,10 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -32,8 +30,8 @@
#include "einfo.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "plugin.h"
#include "helpers.h"
#define RC_PLUGIN_HOOK "rc_plugin_hook"

View File

@@ -18,6 +18,11 @@
#ifndef __LIBRC_PLUGIN_H__
#define __LIBRC_PLUGIN_H__
#include <stdbool.h>
#include <sys/types.h>
#include "rc.h"
/* A simple flag to say if we're in a plugin process or not.
* Mainly used in atexit code. */
extern bool rc_in_plugin;

View File

@@ -30,16 +30,11 @@
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "einfo.h"
#include "queue.h"
#include "rc.h"
#include "misc.h"
#include "schedules.h"
#include "helpers.h"

View File

@@ -13,6 +13,9 @@
#ifndef __RC_SCHEDULES_H
#define __RC_SCHEDULES_H
#include <stdbool.h>
#include <sys/types.h>
void free_schedulelist(void);
int parse_signal(const char *applet, const char *sig);
void parse_schedule(const char *applet, const char *string, int timeout);

View File

@@ -15,14 +15,12 @@
* except according to the terms contained in the LICENSE file.
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <utmp.h>
#include "wtmp.h"

View File

@@ -19,6 +19,7 @@
#define __RC_WTMP_H__
#include <utmp.h>
#include <sys/types.h>
void log_wtmp(const char *user, const char *id, pid_t pid, int type,
const char *line);

View File

@@ -10,14 +10,9 @@
* except according to the terms contained in the LICENSE file.
*/
#include <errno.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
int main(int argc, char **argv)
{

View File

@@ -16,8 +16,8 @@
*/
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <unistd.h>
#include "pipes.h"

View File

@@ -26,47 +26,44 @@
# define _GNU_SOURCE
#endif
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <termios.h>
#include <sys/time.h>
#include <sys/wait.h>
#ifdef __linux__
#include <sys/syscall.h> /* For io priority */
#include <sys/prctl.h> /* For prctl */
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <grp.h>
#include <pwd.h>
#include <sched.h>
#include <signal.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#ifdef __linux__
# include <sys/syscall.h> /* For io priority */
# include <sys/prctl.h> /* For prctl */
#endif
#include <termios.h>
#include <time.h>
#include <unistd.h>
#ifdef HAVE_PAM
#include <security/pam_appl.h>
# include <security/pam_appl.h>
/* We are not supporting authentication conversations */
static struct pam_conv conv = { NULL, NULL};
#endif
#ifdef HAVE_CAP
#include <sys/capability.h>
# include <sys/capability.h>
#endif
#include <sched.h>
#include "einfo.h"
#include "queue.h"
#include "rc.h"
@@ -182,9 +179,9 @@ extern char **environ;
# define SYS_ioprio_set __NR_ioprio_set
#endif
#if !defined(__DragonFly__)
static inline int ioprio_set(int which _unused,
int who _unused,
int ioprio _unused)
static inline int ioprio_set(int which RC_UNUSED,
int who RC_UNUSED,
int ioprio RC_UNUSED)
{
#ifdef SYS_ioprio_set
return syscall(SYS_ioprio_set, which, who, ioprio);
@@ -207,20 +204,20 @@ handle_signal(int sig)
{
int status;
int serrno = errno;
char *signame = NULL;
const char *signame = NULL;
switch (sig) {
case SIGINT:
if (!signame)
xasprintf(&signame, "SIGINT");
signame = "SIGINT";
/* FALLTHROUGH */
case SIGTERM:
if (!signame)
xasprintf(&signame, "SIGTERM");
signame = "SIGTERM";
/* FALLTHROUGH */
case SIGQUIT:
if (!signame)
xasprintf(&signame, "SIGQUIT");
signame = "SIGQUIT";
eerrorx("%s: caught %s, aborting", applet, signame);
/* NOTREACHED */
@@ -239,9 +236,6 @@ handle_signal(int sig)
eerror("%s: caught unknown signal %d", applet, sig);
}
/* free signame */
free(signame);
/* Restore errno */
errno = serrno;
}

View File

@@ -27,20 +27,6 @@
# define _GNU_SOURCE
#endif
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <termios.h>
#include <sys/time.h>
#include <sys/wait.h>
#ifdef __linux__
#include <sys/syscall.h> /* For io priority */
#include <sys/prctl.h> /* For prctl */
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@@ -52,7 +38,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <strings.h>
#ifdef __linux__
# include <sys/syscall.h> /* For io priority */
# include <sys/prctl.h> /* For prctl */
#endif
#include <syslog.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
@@ -196,8 +192,8 @@ extern char **environ;
# define SYS_ioprio_set __NR_ioprio_set
#endif
#if !defined(__DragonFly__)
static inline int ioprio_set(int which _unused, int who _unused,
int ioprio _unused)
static inline int ioprio_set(int which RC_UNUSED, int who RC_UNUSED,
int ioprio RC_UNUSED)
{
#ifdef SYS_ioprio_set
return syscall(SYS_ioprio_set, which, who, ioprio);
@@ -212,7 +208,7 @@ static void cleanup(void)
free(changeuser);
}
static void re_exec_supervisor(void)
RC_NORETURN static void re_exec_supervisor(void)
{
syslog(LOG_WARNING, "Re-executing for %s", svcname);
execlp("supervise-daemon", "supervise-daemon", svcname, "--reexec",
@@ -358,7 +354,7 @@ static pid_t exec_command(const char *cmd)
return pid;
}
static void child_process(char *exec, char **argv)
RC_NORETURN static void child_process(char *exec, char **argv)
{
RC_STRINGLIST *env_list;
RC_STRING *env;
@@ -591,7 +587,7 @@ static void child_process(char *exec, char **argv)
eerrorx("%s: failed to exec `%s': %s", applet, exec,strerror(errno));
}
static void supervisor(char *exec, char **argv)
RC_NORETURN static void supervisor(char *exec, char **argv)
{
FILE *fp;
char buf[2048];

View File

@@ -19,20 +19,17 @@
*/
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <unistd.h>
#include <utime.h>
#include <string.h>
#include "einfo.h"
#include "rc.h"
#include "misc.h"
#include "_usage.h"
#include "helpers.h"
const char *applet = NULL;
@@ -78,14 +75,12 @@ int main(int argc, char **argv)
eerrorx("swclock: Reference file was not specified");
if (sflag) {
if (stat(file, &sb) == -1) {
opt = open(file, O_WRONLY | O_CREAT, 0644);
if (opt == -1)
eerrorx("swclock: open: %s", strerror(errno));
close(opt);
} else
if (utime(file, NULL) == -1)
eerrorx("swclock: utime: %s", strerror(errno));
int fd = open(file, O_WRONLY | O_CREAT, 0644);
if (fd == -1)
eerrorx("swclock: open: %s", strerror(errno));
if (futimens(fd, NULL) == -1)
eerrorx("swclock: futimens: %s", strerror(errno));
close(fd);
return 0;
}

View File

@@ -12,24 +12,14 @@
#define SYSLOG_NAMES
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include "einfo.h"
#include "rc.h"
#include "misc.h"
#include "helpers.h"
const char *applet = NULL;