Commit Graph

2877 Commits

Author SHA1 Message Date
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
William Hubbs
a912029462 init.d/mount-ro: change dependency on killprocs and savecache to after
killprocs always succeeds and savecache is not required by mount-ro, so
we can just start after both of these have run.
2017-03-31 13:39:42 -05:00
William Hubbs
1e90782797 agetty-guide: typo fix 2017-03-31 10:34:41 -05:00
William Hubbs
51a292e09b init.d: add agetty to ignore patterns 2017-03-28 17:52:53 -05:00
William Hubbs
50fccf47d4 sh/gendepends.sh.in: fix detection of service scripts
We do not need to care about the path on the shebang line of a service
script as long as the shebang line ends with "openrc-run".
This fixes #119 and #120.
2017-03-23 13:17:11 -05:00
William Hubbs
9bd63b5d4a update dependencies for clock service
The clock services had a very long list of "before" dependencies that
referred to other services within OpenRC. For ease of maintenance,
convert these to "after clock" dependencies in the individual services.
2017-03-16 10:16:39 -05:00
William Hubbs
48db17a93f update news file 2017-03-15 17:30:23 -05:00
William Hubbs
c333707cba Remove all occurances of 'before *' from dependencies
Using wildcards in dependencies causes issues when rc_parallel is set to
yes because it can lead to deadlocks.
All dependencies need to be explicit rather than implicit.

This is the first stage of moving this direction.
2017-03-14 18:04:31 -05:00
William Hubbs
5f5b1f7cbe init.d/sysfs.in: efivarfs tweaks
Since we check for /sys/firmware/efi/efivars, we do not need to check
for /sys/firmware/efi

Since Failing to mount efivarfs is not critical, we silence the error
message from mount.
2017-03-12 13:55:49 -05:00
William Hubbs
cfdf56475e version 0.25 2017-03-12 13:55:25 -05:00
William Hubbs
fde3902d06 update ChangeLog 2017-03-09 16:20:17 -06:00
William Hubbs
d7bbb0f583 add agetty service
The agetty service is an alternate way to manage gettys with agetty
under Linux which is separate from an external init system.
2017-03-09 15:23:02 -06:00
William Hubbs
21ca2b746c init.d/sysfs: drop modules completely from the dependencies
This is for #112.
2017-03-08 10:44:10 -06:00