Commit Graph

3039 Commits

Author SHA1 Message Date
Christian Brauner
16ff3cd8df check whether /sys/fs/cgroup is a mountpoint
The current check only tries to detect whether /sys/fs/cgroup exists and
whether it is writable or not. But when the init system doesn't mount
cgroups then /sys/fs/cgroup will just be an empty directory. When paired
with unprivileged containers that mount sysfs this will cause misleading
errors to be printed since /sys/fs/cgroup will be owned by user
nobody:nogroup in this case. Independent of this specific problem this
check will also be misleading when the /sys/fs/cgroup exists and is in
fact writable by the init system but isn't actually a mountpoint.

Note from William. "grep -qs" doesn't need to redirect output to
/dev/null since it is completely silent.

This fixes #209.
2018-02-23 15:51:12 -06:00
William Hubbs
38032626a6 improve cgroup configuration checks
make the base/controller functions return successfully if cgroups v1/v2
are not configured in the kernel
2018-02-23 15:07:04 -06:00
William Hubbs
aa7d3a7911 openrc: force deptree update for sysinit runlevel 2018-02-22 16:16:07 -06:00
William Hubbs
98262647a9 supervise-daemon: zero out the cmdline buffer when it is allocated 2018-02-22 12:54:21 -06:00
William Hubbs
5868abe97b start-stop-daemon: compiler warning cleanup 2018-02-21 18:16:56 -06:00
William Hubbs
71aad16256 openrc-run: clean up a compiler warning 2018-02-21 18:15:35 -06:00
William Hubbs
e275da84de supervise-daemon: remove references to PATH_MAX 2018-02-21 18:14:56 -06:00
William Hubbs
a6cc7f06cf rc.c: remove PATH_MAX references 2018-02-21 13:49:41 -06:00
William Hubbs
c1178c8eeb rc-selinux.c: remove references to path_max 2018-02-20 16:35:50 -06:00
William Hubbs
3c031ca978 rc-plubin.c: remove references to PATH_MAX 2018-02-20 16:01:15 -06:00
William Hubbs
8e02406d8f rc-misc.c: remove references to PATH_MAX 2018-02-20 14:22:29 -06:00
William Hubbs
8dbdabcc5e start-stop-daemon: clean up string handling 2018-02-16 14:04:40 -06:00
William Hubbs
488d8989c5 openrc-run: clean up string handling
- remove references to PATH_MAX
- use xasprintf to create strings
2018-02-15 15:26:40 -06:00
William Hubbs
9e14b35da8 rc-update: remove reference to PATH_MAX 2018-02-15 12:23:39 -06:00
William Hubbs
7b4879cb72 mountinfo: create strings with xasprintf 2018-02-14 16:56:19 -06:00
William Hubbs
74cfb455c5 kill_all: create strings with xasprintf 2018-02-14 16:50:24 -06:00
William Hubbs
0110487722 helpers.h: silence compiler warnings about xasprintf 2018-02-10 16:48:22 -06:00
William Hubbs
68b9b0bc2a xasprintf: exit if return value of vsnprintf is invalid 2018-02-10 14:49:40 -06:00
William Hubbs
4616f8f809 helpers.h: add xasprintf function
This is our own version of asprintf(). This original code was written by
Mike Frysinger, and I was able to modify it to use our memory helper
functions.

We need a version of this code because it is not available on glibc at
least without defining _GNU_SOURCE, and I would rather not do that.

This is the first step in improving string handling in OpenRC for #207.
2018-02-09 16:27:12 -06:00
William Hubbs
287d71bd25 helpers.h: style fix 2018-02-09 15:35:12 -06:00
Michael Orlitzky
c1ffe4d9f2 man/openrc-run.8: fix mountinfo args.
The "Ar" tag for the mountinfo command contained a typo (leading
space) that resulted in the tag being output verbatim; that is,

  mountinfo ... .Ar mount1 mount2

rather than e.g.

  mountinfo ... <mount1> <mount2>

This commit deletes the leading space to fix the output.

This fixes #204.
2018-02-06 13:53:11 -06:00
Michael Orlitzky
4c517bdb2b man/openrc-run.8: add missing "Xo" tags for fstabinfo and mountinfo.
The BUILTINS are all surrounded by Xo...Xc tags, but the opening "Xo"
was missing from the two commands fstabinfo and mountinfo. This commit
adds them, and thereby fixes the spacing when viewed by man.

This is for #204.
2018-02-06 13:52:36 -06:00
William Hubbs
110582491f service-script-guide.md cleanups
Refer to /var/run in the documentation instead of /run, and make it
clear at the top of the pidfile section that we use /run under Linux.

This is for #202.
2018-01-24 17:43:08 -06:00
William Hubbs
5dd1d39d20 typo fix 2018-01-24 10:56:33 -06:00
William Hubbs
1771bc2a83 checkpath: use fchown and fchmod to handle ownership and mode changes
This is related to #195.

This is an attempt to shorten the window for the first two issues
discussed by using a file descriptor which does not follow symbolic
links and using the fchmod and fchown calls instead of chown and chmod.
with.
2018-01-23 16:56:06 -06:00
William Hubbs
87c98ebb01 checkpath: fix lchown error message
X-Gentoo-Bug: 643084
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=643084
2018-01-16 13:34:37 -06:00
William Hubbs
4af5a80b0c _rc_deptree_load - return NULL if the stat() call is not successful
X-Gentoo-Bug: 643084
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=643084
2018-01-16 13:11:22 -06:00
William Hubbs
fee2ffe559 Reformat and fix titles in documentation 2018-01-12 14:10:42 -06:00
William Hubbs
8878f8916b Rename guide.md to user-guide.md to better describe its purpose 2018-01-11 10:57:05 -06:00
William Hubbs
14e3359a9e move developer documentation from guide.md to service-script-guide.md 2018-01-10 13:25:13 -06:00
William Hubbs
918d955fd2 checkpath: use lchown instead of chown
Checkpath should never follow symbolic links when changing ownership of a file.

This is for https://github.com/openrc/openrc/issues/195.
2018-01-09 17:25:28 -06:00
William Hubbs
92cfa0e543 service-script-guide.md: formatting changes
Add a title, adjust the headings and update the example that referred to
"net.lo" to refer to "loopback".
2018-01-08 15:33:03 -06:00
Michael Orlitzky
c2bd33e483 service-script-guide.md: new guide for service script authors.
This fixes #162.
2018-01-08 13:59:12 -06:00
3PO
f42ec82f21 net-online: only process symbolic links in /sys/class/net
The /sys/class/net directory contains files which are not symlinks if
the system has bonded devices [1].  We should ignore these files.

This fixes #196.

[1] https://elkano.org/blog/manage-interface-bondings-sysfs-interface/
2018-01-05 14:56:33 -06:00
William Hubbs
7affff568a init.d.examples: pid files always go in /var
This removes the @VARBASE@ substitution since it is always translated to
/var.
2017-12-20 11:01:29 -06:00
William Hubbs
4f750933fd procfs: remove the @sysconfdir@ reference 2017-12-14 17:31:57 -06:00
William Hubbs
50b69d564a hostname: replace @SYSCONFDIR@ references with /etc
I do not know of any situation where /etc/hostname is at any other
location. Also, this does not run on prefix.
2017-12-14 17:07:31 -06:00
William Hubbs
eb18f4f348 hwclock: use shell variables for configuration file path
This removes a reference to @SYSCONFDIR@.
2017-12-14 16:38:09 -06:00
William Hubbs
d5f3fe52c8 sysctl: hard code paths for sysctl files on *bsd
For *BSD,the sysctl*.conf files are always in /etc.
2017-12-14 14:18:39 -06:00
William Hubbs
bb1bc6eeb7 local: misc cleanups
Remove references to @SYSCONFDIR@ since these can be calculated at
runtime.
Also style fixes.
2017-12-14 12:52:03 -06:00
William Hubbs
53844fd0dc devfs: cleanup
clean up local definitions. Also remove @SYSCONFDIR@ substitutions since
they can be calculated at runtime.
2017-12-14 12:08:38 -06:00
bell07
14938c29ce net-online: wait for ping_test_host
The script should wait till the ping host is available or timeout reached
Closes : #179
Closes : #191
2017-12-12 16:29:34 -06:00
William Hubbs
8bf501aaf2 network: use 'command -v ip' to test for the ip executable
This is an improved test because it doesn't require the ip executable to be
in a specific path.
2017-12-12 14:23:04 -06:00
William Hubbs
9d05f68b51 Do not use file tests in net-online
https://unix.stackexchange.com/questions/252002/help-testing-special-file-in-sys-class-net

This is for #189
2017-12-12 12:45:52 -06:00
William Hubbs
ee2524cd1d net-online: clean up quoting and test for existence
This is for #178.
2017-12-11 17:41:04 -06:00
Marcel Greter
5c81661d47 Gracefully handle unreadable /sys/class/net/dev/ nodes
Fixes https://bugs.gentoo.org/629228
Fixes #189
Fixes #185
Fixes #178
2017-12-11 14:46:16 -06:00
William Hubbs
fb96c9c127 Make bash-completion and zsh-completion optional 2017-12-07 12:53:04 -06:00
William Hubbs
6c456f9383 Add zsh-completion support 2017-12-07 11:30:32 -06:00
William Hubbs
d220fc2723 add bash completion support
This fixes #188.
2017-12-06 13:25:26 -06:00
William Hubbs
a2447dfb42 rc-service: add --ifcrashed option
This works like the other --if options. If the service is crashed, run
the command.

This fixes #154.
2017-12-04 17:17:17 -06:00