Commit Graph

3139 Commits

Author SHA1 Message Date
udeved
199a210d2f scripts/Makefile: make symlinks absolute instead of relative
This closes #142.
2017-06-12 10:39:44 -05:00
udeved
5b7667af32 scripts/Makefile: respect SBINDIR with MKSYSVINIT
This is for #142.
2017-06-12 10:38:47 -05:00
Jory A. Pratt
11243f85b6 kill_all: include limits.h for PATH_MAX 2017-06-08 10:04:19 -05:00
William Hubbs
3c40826d34 version 0.28 2017-06-08 08:45:16 -05:00
William Hubbs
560d874d2f fix compile issue for musl 2017-06-08 08:43:42 -05:00
William Hubbs
e84366fd23 Update ChangeLog 2017-06-07 12:03:52 -05:00
William Hubbs
caacedc0a8 man: update openrc-shutdown man page
Add the new wtmp options and fix some cross references.
2017-06-07 11:28:01 -05:00
William Hubbs
84d140a1f6 scripts/shutdown: pass --single to openrc-shutdown
Sysvinit shutdown has a default of single user mode, but openrc-shutdown
makes you choose a default action. Because of this, the shutdown wrapper
needs to pass --single to openrc-shutdown.
2017-06-07 10:59: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
1801561c2d init.d/bootmisc: use openrc-shutdown instead of halt to write halt record
This fixes #139 and fixes #128.
and fixes #124.
2017-06-05 16:52:50 +00:00
William Hubbs
7689106aa1 add support for writing reboot and shutdown records to wtmp 2017-06-04 20:56:03 -05:00
William Hubbs
1564e155b7 openrc-init: add optional sysvinit compatibility 2017-05-31 18:07:02 -05:00
William Hubbs
44bac3c379 Change killprocs to use kill_all instead of killall5
X-Gentoo-Bug:376977
X-Gentoo-Bug-URL:https://bugs.gentoo.org/show_bug.cgi?id=376977
2017-05-30 18:48:33 -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
688566c535 mk/cc.mk: make implicit function declarations fatal (#136)
Avoids issues with missing prototypes causing truncation of pointers.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2017-05-30 03:51:42 -04: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
ec27299f4b typo fix
X-Gentoo-Bug: 618888
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=618888
2017-05-22 12:52:58 -05: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
f1013037b4 version 0.27 2017-05-12 17:14:15 -05:00
William Hubbs
e4bfb4530a update ChangeLog 2017-05-11 22:00:41 -05:00
William Hubbs
78e0042ecc man/rc-status: document changes for supervised daemons
rc-status now shows the amount of time a supervised daemon has been
active as well as the number of times it has been respawned during the
current respawn period.
2017-05-11 21:55:31 -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
6ac094a59c version 0.26 2017-04-19 17:24:44 -05:00
William Hubbs
84c81ca02d update ChangeLog 2017-04-17 12:35:12 -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
5fd3747b19 reword the bugs section of the openrc-init man page 2017-04-14 11:11:07 -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
i.Dark_Templar
6f88ee4ec6 bootmisc: do not remove ld-elf32.so.hints
File /var/run/ld-elf32.so.hints is used on FreeBSD 64bit multilib
This fixes #125.
2017-04-10 10:15:28 -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
i.Dark_Templar
79a9edc730
Fix make install on FreeBSD: don't try to install /etc/init.d/modules twice 2017-04-05 16:54:53 +03: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
55a87a30ec init.d/agetty.in: add -prefix keyword 2017-03-31 16:21:28 -05:00