William Hubbs
35b1996704
supervise-daemon: elevate some log messages to warnings
...
Prior to this change, we were logging unexpected terminations of daemons
we were supervising at the info level. This change moves the logs to
warnings.
2017-10-18 18:07:50 -05:00
William Hubbs
1e9af2cd42
fix compiler warning
2017-10-05 18:31:07 -05:00
William Hubbs
3c05db74f6
remove service binary
...
The service binary was just a synonym for rc-service, so use rc-service
instead of service. If you want a "service" binary, it should be
something that can determine which service manager you are running and
run the appropriate service manager commands.
2017-10-02 18:09:09 -05:00
William Hubbs
1cac8b080c
ignore sigchld when shutting down the supervised process
...
We need to do this to skip the zombie state for the child process since
we are not easily able to wait() for it.
2017-09-18 16:59:18 -05:00
William Hubbs
b58194ef63
typo fix
2017-09-18 13:30:56 -05:00
William Hubbs
b28c0d6f66
typo fix
2017-09-18 13:03:34 -05:00
William Hubbs
3cf19b0f30
supervise-daemon: code cleanup
...
Clean up the process for killing an active supervisor when stopping.
2017-09-18 12:25:37 -05:00
William Hubbs
0eb47b9af3
initialize the stop schedule
2017-09-18 10:36:17 -05:00
William Hubbs
4ab60ff109
rc-schedules.c: pass the correct pid to rc_find_pids
...
This is for #163 .
2017-09-17 14:20:05 -05:00
Jason Zaman
db4a578273
selinux: fix const qualifier warning
...
rc-selinux.c: In function ‘selinux_setup’:
rc-selinux.c:361:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
curr_t = context_type_get(curr_con);
^
2017-09-17 11:41:24 -05:00
Jason Zaman
b1c3422f45
selinux: use openrc contexts path to get contexts
...
The minimum requirement for libselinux is now >=2.6
The refpolicy and the gentoo policy contain the
contexts since version 2.20170204-r4
2017-09-17 11:40:07 -05:00
William Hubbs
b0a077a35f
add quiet switch to do_stop in src-schedules.c
...
This allows supervise-daemon to run this code without attempting to
print some status messages used by start-stop-daemon.
2017-09-14 18:24:39 -05:00
William Hubbs
382efdbfcb
add quiet parameter to run_stop_schedule
2017-09-06 17:22:35 -05:00
William Hubbs
17b5cc78d3
add retry option to supervise-daemon
...
The --retry option for supervise-daemon defines how the supervisor will
attempt to stop the child process it is monitoring. It is defined when
the supervisor is started since stopping the supervisor just sends a
signal to the active supervisor.
This fixes #160 .
2017-09-06 17:22:21 -05:00
William Hubbs
36a0ab9054
make run_stop_schedule accept a pid instead of a pid file
2017-08-25 11:36:45 -05:00
William Hubbs
d7938f54f2
start-stop-daemon: move --retry processing code to a shared module
...
This was part of start-stop-daemon; however, it needs to be shared in
order to be used by supervise-daemon.
2017-08-24 11:34:18 -05:00
William Hubbs
cfbe9c2ede
move get_pid function to a shared file
2017-08-23 14:36:50 -05:00
Jason Graham
6d4e843397
fix ENT macro usage
...
X-Gentoo-Bug: 624796
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=624796
2017-07-24 18:24:18 -05:00
Jory A. Pratt
11243f85b6
kill_all: include limits.h for PATH_MAX
2017-06-08 10:04:19 -05:00
William Hubbs
560d874d2f
fix compile issue for musl
2017-06-08 08:43:42 -05:00
William Hubbs
ee886c4482
openrc-shutdown: add --single option and clean up option processing
2017-06-05 15:49:22 -05:00
William Hubbs
7689106aa1
add support for writing reboot and shutdown records to wtmp
2017-06-04 20:56:03 -05:00
Sergei Trofimovich
0ddee9b7d2
openrc-init: fix buffer overflow in init.ctl
...
How to reproduce 1-byte overflow:
```
$ FEATURES=-test CFLAGS="-fsanitize=address -O0 -ggdb3" emerge -1 openrc
=================================================================
==1==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff0efd8710
at pc 0x000000402076 bp 0x7fff0efd7d50 sp 0x7fff0efd7d40
WRITE of size 1 at 0x7fff0efd8710 thread T0
#0 0x402075 (/sbin/openrc-init+0x402075)
#1 0x3cf6e2070f in __libc_start_main (/lib64/libc.so.6+0x3cf6e2070f)
#2 0x4013b8 (/sbin/openrc-init+0x4013b8)
Address 0x7fff0efd8710 is located in stack of thread T0 at offset 2432 in frame
#0 0x401cfb (/sbin/openrc-init+0x401cfb)
This frame has 3 object(s):
[32, 160) 'signals'
[192, 344) 'sa'
[384, 2432) 'buf' <== Memory access at offset 2432 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow ??:0 ??
```
The problem here is in the code handling reads from 'init.ctl':
```
int main(int argc, char **argv) {
...
char buf[2048];
for (;;) {
/* This will block until a command is sent down the pipe... */
fifo = fopen(RC_INIT_FIFO, "r");
count = fread(buf, 1, 2048, fifo);
buf[count] = 0;
...
}
```
`buf[count] = 0;` writes outside the buffer when `fread()` returns non-truncated read.
This fixes #138 .
2017-05-30 16:21:23 -05:00
Sergei Trofimovich
7185e242ff
rc-logger.c: fix crash on fclose(NULL) ( #137 )
...
Only close the log if we successfully opened it.
Reported-by: Brian Evans <grknight@gentoo.org>
Tested-by: Brian Evans <grknight@gentoo.org>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2017-05-30 03:47:55 -04:00
William Hubbs
1ece16bfcd
openrc-shutdown: add dry-run option
2017-05-22 12:42:37 -05:00
William Hubbs
0cfd0dd9ef
openrc-shutdown: move to single user mode by default
...
To be more compatible with sysvinit, move to single user mode if no
options are specified on the command line.
2017-05-22 12:15:15 -05:00
William Hubbs
a77ee2e941
init: add ability to switch to single user mode
2017-05-22 11:29:23 -05:00
William Hubbs
49b8a573a1
add kill_all helper
...
This is similar to the sysvinit killall5 utility. It should only be used
in service scripts, so it will not be installed in the path.
This closes #129 .
2017-05-19 18:13:39 -05:00
William Hubbs
a2055af900
rc_status: calculate time differences in time_t and display seconds in uptime
2017-05-15 18:55:47 -05:00
William Hubbs
cbf96967f1
supervise-daemon: save start time and respawn count before dropping privs
2017-05-12 17:15:55 -05:00
William Hubbs
82e12e3092
rc-status: show uptimes and respawn counts for supervised daemons
2017-05-11 21:39:03 -05:00
William Hubbs
1ebef0d7a3
fix to_time_t to honor dst
2017-05-11 18:13:13 -05:00
William Hubbs
6b4050ab9c
fix from_time_t function
2017-05-11 16:22:12 -05:00
William Hubbs
cf5e9aa2bb
Move time_t conversions to rc-misc.c so they can be shared
2017-05-11 16:06:12 -05:00
William Hubbs
a3250e77d4
supervise-daemon: save start time and respawn count
...
This will allow rc-status to display an uptime and restart count for
supervised processes.
2017-05-11 13:54:20 -05:00
William Hubbs
df027ca472
supervise-daemon: fix our status when we give up on the child process
2017-05-11 11:36:42 -05:00
William Hubbs
4c89e3f5fa
supervise-daemon:create multiple options from --respawn-limit
...
This creates --respawn-delay, --respawn-max and --respawn-period. It was
suggested that it would be easier to follow if the options were
separated.
This is for #126 .
2017-05-10 18:13:23 -05:00
William Hubbs
3673040722
supervise-daemon: add a --respawn-limit option
...
Allow limiting the number of times supervise-daemon will attempt to respawn a
daemon once it has died to prevent infinite respawning. Also, set a
reasonable default limit (10 times in a 5 second period).
This is for issue #126 .
2017-05-09 18:30:08 -05:00
William Hubbs
96c8ba2fb5
supervise-daemon: mark all open file descriptors FD_CLOEXEC
2017-04-29 13:48:45 -05:00
William Hubbs
47cf1d0c70
supervise-daemon:remove the controlling tty in the supervisor
2017-04-29 12:04:15 -05:00
William Hubbs
06a6a27e44
supervise-daemon: fix access to tty_fd and devnull_fd
...
Both the child and supervisor need access to these file descriptors.
2017-04-29 10:12:16 -05:00
William Hubbs
5de3798afc
supervise-daemon: mark the service started when the supervisor is active
2017-04-29 09:41:07 -05:00
William Hubbs
0e3f872098
init: send term/kill signals as final step of shutdown
2017-04-17 12:23:45 -05:00
William Hubbs
4694900190
init: fix signal handling
...
The only signals we handle are SIGINT and SIGCHLD, so block all others
and unblock them in the child process before we start a rurnlevel.
2017-04-13 12:54:30 -05:00
William Hubbs
05738bfce1
init: add re-exec capability
...
This will allow the re-execution of the init process after upgrading
OpenRC.
2017-04-12 17:56:36 -05:00
William Hubbs
cc51bdca3b
Add attribution to openrc-init.c and openrc-shutdown.c
2017-04-07 07:39:12 -05:00
William Hubbs
13ca79856e
add init process
...
openrc-init.c and openrc-shutdown.c are based on code which was written by
James Hammons <jlhamm@acm.org>, so I would like to publically
thank him for his work.
2017-04-06 17:13:59 -05:00
Austin English
9eb669591e
start-stop-daemon: warn if calling --start with --retry or --stop with --wait
...
This fixes #122
2017-04-03 10:43:40 -05:00
William Hubbs
6f614cd3f3
Move deptree2dot to the support folder
...
Since deptree2dot and the perl requirement are completely optional, we
can move this tool to the support folder. This gives the user the option
of using it if they have perl installed, and means we do not have an
optional runtime dependency on perl.
Documentation for this tool has also been added to the support folder.
X-Gentoo-Bug: 600742
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=600742
2017-02-17 12:06:03 -06:00
Doug Freed
6dcb692986
start-stop-daemon: allow all standard signals
...
Also we define the signalpair_item macro.
This fixes #113 .
X-Gentoo-Bug: 604986
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604986
2017-01-25 17:48:52 -06:00
William Hubbs
b73941f0c3
mountinfo: make the path to /proc/mounts a constant
...
This path should not be hard coded in the open call.
Linux prior to 2.4.19 did not have /proc/self/mounts, so for now I'm
making this value /proc/mounts everywhere, but that may change to
/proc/self/mounts on linux; I'm not sure we should care about <2.4.19.
X-Gentoo-Bug: 604646
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604646
2017-01-04 18:18:37 -06:00
Benda Xu
c304522131
Clean up warnings that can use the _unused macro
...
X-Gentoo-Bug: 604666
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
2017-01-04 17:18:35 -06:00
Benda Xu
92325b44ba
Indentation fixes
...
X-Gentoo-Bug: 604666
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=604666
2017-01-04 16:59:38 -06:00
Doug Freed
45aa36cc62
librc: detect loops in stacked runlevels and abort
...
This fixes #109 .
X-Gentoo-Bug: 558700
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=558700
2016-12-19 18:24:31 -06:00
Jason Zaman
6414c3bc39
selinux: fix SIGSEGV with invalid contexts
...
Fixes: https://github.com/openrc/openrc/issues/104
2016-11-17 12:03:12 -06:00
William Hubbs
be06cd250e
src/rc/rc: do not try to start services if fork fails
2016-11-01 17:31:57 -05:00
William Hubbs
4fd144c0a6
src/rc/rc-misc.c: report error if call to flock() fails
...
X-Gentoo-Bug: 597390
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=597390
2016-10-24 12:47:49 -05:00
Sven Wegener
78146b0e14
do_service: Initialize idx to 0
...
If index is not explicitly specified for service_started_daemon, it will
look for daemons by random index.
This fixes #100 .
2016-10-11 10:30:02 -05:00
Doug Freed
6710316a18
openrc-run: fix double free
2016-09-30 17:29:56 -04:00
William Hubbs
83bb827edf
Revert "Disable parallel startup in interactive mode"
...
This reverts commit 8b4fc05ff2
.
The original commit did not explain why this feature was disabled, and I
now have a request to enable it.
This fixes #24 .
2016-09-19 12:09:05 -05:00
Doug Freed
6cabaf274d
rc-misc: allow EINFO_VERBOSE through too
2016-09-16 09:51:03 -04:00
Doug Freed
1edb5f6fd9
rc-misc: Allow EINFO_COLOR through env_filter()
...
This allows rc-service -C <service> <action> to properly not print color
messages.
Fixes #93
2016-09-14 22:48:56 -04:00
William Hubbs
69ac78d76a
openrc-run: make runscript warning respect quiet option
...
X-Gentoo-Bug: 591414
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=591414
2016-08-25 11:04:48 -05:00
William Hubbs
ca8c29ee60
librc: fix Docker auto detection
...
The original auto detection of Docker containers assumed the presence of
a container environment variable. However, Docker-1.12 does not
implement this, and I'm not sure which versions of docker implemented
it.
The new test is for the presence of a file named .dockerenv in the
root directory.
2016-07-31 12:24:56 -05:00
Kenneth Lakin
94b98430cb
start-stop-daemon: Add SSD_IONICELEVEL
...
This is the disk IO counterpart to SSD_NICELEVEL.
Modified by William Hubbs to add the variable to the start-stop-daemon
man page.
This fixes #69 .
2016-07-26 12:30:39 -05:00
Doug Freed
3adb8fb389
rc-logger: refuse to cat TMPLOG into itself
...
This prevents an infinite loop in case somebody decides to set
rc_log_path to match TMPLOG.
2016-07-24 02:27:53 +00:00
William Hubbs
695be59083
rc-status: add -m/--manual option to show manually started services
...
X-Gentoo-Bug: 585906
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=585906
2016-07-18 13:20:56 -05:00
Doug Freed
c962678dd6
rc: Rename some static variables to kill warnings
2016-07-16 20:10:37 +00:00
William Hubbs
3a1262703f
Remove the DEBUG_MEMORY macro
...
This fixes #43 .
2016-07-14 16:52:57 -05:00
William Hubbs
20035210bd
make variable aflag a boolean show_all
2016-07-14 12:13:17 -05:00
Jaromil
7f84b5d741
libeinfo: document the x suffix on function names
...
This fixes #88 .
2016-07-13 17:04:28 -05:00
William Hubbs
b2c92b88cc
fstabinfo/mountinfo: ensure /etc/fstab exists before calling setmntent
...
This is based on a patch by A. Wilcox <awilfox.gentoo@foxkit.us>.
X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226
X-Gentoo-Bug: 478226
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=478226
2016-06-10 17:16:37 -05:00
William Hubbs
87884db667
Make deprecation warnings for rc and runscript more visible
...
These warnings were inserted in verbose only mode in OpenRC-0.13.A
Now, we are making them more visible in preparation for removing these
compatibility binaries in the future.
2016-05-24 11:24:10 -05:00
William Hubbs
94077d264e
supervise-daemon: log the exit code or signal when a child process dies
2016-05-23 11:10:51 -05:00
Jason Zaman
3fa9015b8e
rc-selinux: access check was backwards
2016-05-13 12:52:21 -05:00
William Hubbs
3b5a8b331e
supervise-daemon: add pam service file
2016-05-13 12:05:23 -05:00
William Hubbs
ad23d5b8db
openrc-run: clean up runscript deprecation message
2016-05-04 18:17:58 -05:00
William Hubbs
62410eaf4b
add daemon supervisor
...
The supervise-daemon process is meant to be a lightweight supervisor
which can monitor and restart a daemon if it crashes.
2016-04-27 11:13:50 -05:00
Mike Gilbert
171e856ec8
start-stop-daemon: Allow group read/write when creating output files
...
This allows for better interaction with inherited ACL entries.
This fixes #84 .
X-Gentoo-Bug: 577362
X-Gentoo-Bug-URL: https://bugs.gentoo.org/577362
2016-04-11 11:11:59 -05:00
William Hubbs
7eaf71176b
Fix rc_env_allow wildcard usage
...
Before this commit, using * in rc_env_allow did not work.
This fixes #60 .
2016-02-12 12:44:52 -06:00
William Hubbs
8a7e4d38a7
rc-service: add --ifinactive and --ifnotstarted flags
...
X-Gentoo-Bug: 523174
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=523174
2016-01-28 12:57:11 -06:00
William Hubbs
47dd5e37cb
add back deprecation warnings lost during refactoring
2016-01-22 12:46:29 -06:00
William Hubbs
e277ae57ef
fix tests
...
X-Gentoo-Bug: 572602
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572602
2016-01-22 12:07:13 -06:00
William Hubbs
69f052b611
librc: Complain when a real and virtual service have the same name
2016-01-21 15:58:03 -06:00
William Hubbs
e4eacf02ca
openrc-run: in verbose mode, log execution of the shell script
...
This is to show when openrc-run runs the openrc-run.sh script; it is
used for debugging.
2016-01-20 11:20:40 -06:00
Doug Freed
62b49b2a3a
rc: remove use of magic constant and allow OpenVZ to drop to shell
...
OpenVZ has had console support for a long time now; allow them to use it
to drop to a shell during interactive boot.
2016-01-19 00:09:20 -06:00
Doug Freed
4c814a0a28
librc: handle rc_sys="prefix" even if we weren't built with a prefix
...
This probably isn't needed, but it mimics old behavior.
2016-01-19 00:09:20 -06:00
Doug Freed
36dde4e7f2
librc: fix handling the nothing special case for rc_sys
2016-01-19 00:09:20 -06:00
Doug Freed
649f63d882
librc: move system detection code into rc_sys and use it
...
This fixes an issue where librc code was calling code that only existed
in the rc binary.
This reverts commits 8addd79
and 9f6e056
This fixes #75 .
2016-01-19 00:09:20 -06:00
William Hubbs
55a28f5d25
Revert "rc: make get_systype similar to the old rc_sys function"
...
This reverts commit f79a7a7be1
.
2016-01-18 23:40:20 -06:00
William Hubbs
6c09421375
Revert "librc: fix librc-depend functions to call rc_sys"
...
This reverts commit 73482cf13a
.
2016-01-18 23:40:03 -06:00
William Hubbs
79359f77cc
fix bsd build
...
X-Gentoo-Bug: 572068
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572068
2016-01-18 16:06:39 -06:00
William Hubbs
f79a7a7be1
rc: make get_systype similar to the old rc_sys function
2016-01-18 15:50:59 -06:00
William Hubbs
73482cf13a
librc: fix librc-depend functions to call rc_sys
2016-01-18 15:09:31 -06:00
William Hubbs
0910c455d3
src/rc/Makefile: fix make depend target
2016-01-14 13:33:05 -06:00
William Hubbs
f5e06bc55a
include rc.h properly in source files
...
We were attempting to include rc.h in rc-misc.h instead of the source
files where it should be included.
2016-01-14 12:52:32 -06:00
William Hubbs
6da0abc085
fix selinux build
...
X-Gentoo-Bug: 571798
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=571798
2016-01-14 11:29:24 -06:00
William Hubbs
b34df9dd81
fix selinux build
2016-01-13 20:11:06 -06:00
William Hubbs
6f02069746
Add LANG, LC_MESSAGES and TERM to the environment whitelist
2016-01-13 19:34:22 -06:00
William Hubbs
d4c7207ef3
fix seg fault
2016-01-13 19:30:19 -06:00