Commit Graph

1311 Commits

Author SHA1 Message Date
William Hubbs
9fedb3b40b Add detection for docker containers 2015-12-02 10:20:15 -06:00
William Hubbs
635e33cdc8 librc: comsolidate rc_sys_v1 and rc_sys_v2 into rc_sys
These functions were never meant to be used outside of OpenRC, and they
were added when we thought we were going to do away with the automatic
detection of subsystems. Since the autodetection is not going away, we
can combine these functions into rc_sys.
2015-12-01 17:39:04 -06:00
Ian Stakenvicius
33d3f33b3c Implement "want" dependency
The want dependency is similar to the use dependency. If a service
script, for example called service1, adds "want service2" to its depend
function, OpenRC will attempt to start service2, if it exists on the
system,  when service1 is started.

However, service1 will start regardless of the status of
service2.

X-Gentoo-Bug: 406021
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=406021
2015-11-12 12:32:45 -06:00
Benda Xu
085d77f17e Standardize macro tests for gnu hurd
This also fixes breakage of GNU/hurd builds introduced by commit 3f82edbeb9.
2015-11-11 13:37:41 -06:00
William Hubbs
c831f1f994 librc: rework overriding rc.conf options from the kcl
Rename the rc_conf_override function to describe its purpose better,
drop one conditional compile by making it available everywhere, and move
the call to it after the optional rc.conf.d directory is processed.
2015-11-05 11:20:57 -06:00
William Hubbs
591aea2821 librc: Remove redundant code from rc_config_load 2015-11-05 11:20:57 -06:00
William Hubbs
c09eeca491 Add rc.conf.d support
This makes it possible to override settings in rc.conf by adding a
directory @SYSCONFDIR@/rc.conf.d and putting files in this directory.
The files will be processed in lexical order, and the last setting in
these files will be used.
2015-11-05 10:40:24 -06:00
William Hubbs
b81317bdf8 mountinfo: make sure the netdev variable is initialized on Linux
This fixes the following regression:

X-Gentoo-Bug: 562668
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=562668
2015-10-13 08:27:43 -05:00
William Hubbs
5f4f242036 mountinfo: fix --netdev and --nonetdev on Linux
On Linux, the --netdev and --nonetdev switches were not working. They
were both returning false. After this change, they operate based on the
presence or abscence of the _netdev option in mount options.
2015-10-05 10:18:00 -05:00
William Hubbs
b3f7ff901f mountinfo: read /proc/self/mounts instead of /proc/mounts on Linux 2015-10-04 15:35:33 -05:00
William Hubbs
3b6a6df4b5 openrc-run: rename some dependency variables and a function for clarity
All of the dependency type lists had the types_ prefix in their names;
this has been changed to deptypes_ to make them more self documenting.

Along the same lines, the setup_types function was renamed
setup_deptypes.
2015-09-17 15:02:30 -05:00
William Hubbs
f69833a1e1 mountinfo: fix -e and -E options
Add the -e and -E options to getoptstring so they are recognized.
2015-08-02 07:39:58 -05:00
William Hubbs
eeadca0b8a Add EERROR_QUIET and EINFO_QUIET to environment whitelist 2015-07-23 12:44:10 -05:00
Jakob Drexel
0b435ddd83 librc: Fix crash if the service name is the same as the including runlevel
If a service has the same name as the runlevel it is in, openrc will
crash on changing to such runlevel. It goes in a recursive madness and
eventually gets a SEGV while in snprintf (don't know why).

This fixes two errors:
1. ls_dir stats files not with full path -> stat always returns != 0
2. ls_dir adds files to list if stat failed

This fixes #53.

X-Gentoo-Bug: 537304
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=537304
2015-05-04 09:54:51 -05:00
William Hubbs
c709e6077c Add support for systemd-nspawn containers
This adds support for running OpenRC in a container created by
the systemd-nspawn utility.

This fixes #52.

X-Gentoo-Bug: 548058
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=548058
2015-05-01 09:04:07 -05:00
William Hubbs
8b93492086 convert all references from runscript to openrc-run 2015-04-27 11:21:29 -05:00
William Hubbs
03803ae8e9 start-stop-daemon: redirect stdin if --background option is used
X-Gentoo-Bug: 498684
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=498684
2015-04-24 12:24:09 -05:00
William Hubbs
b8ab99b5d3 checkpath: Remove the last HAVE_SELINUX test 2015-03-25 08:33:42 -05:00
William Hubbs
a4cf61e8bf selinux: unconditionally include the header and provide stub methods
If selinux is disabled, then stub methods will be provided instead of
calling the real methods. This removes some warnings about unused
parameters which used to be covered up with #ifdef HAVE_SELINUX.

Signed-off-by: Jason Zaman <jason@perfinion.com>
2015-03-25 01:01:38 -05:00
William Hubbs
d38cc8f221 checkpath: fix warning about selinux_on being unused 2015-03-24 23:18:15 -05:00
Doug Freed
f085ae400c Fix some compiler warnings
librc: Fix C90 warning (mixed declaration and code)
rc: Fix warning about discarding const qualifier

Fixes #45.
2015-03-24 19:08:29 -05:00
Will Miles
c1faafcad8 start-stop-daemon: Fix regression for --test
The previous fix to --test (PR #34) prevented reading one too many
arguments when --exec -or --name was not specified, but created a
regression where the last argument would not print if either of those
arguments was specified. This corrects the issue.

Fixes #41.
2015-03-24 15:52:19 -05:00
William Hubbs
a0378f3871 checkpath: do not chown or chmod symbolic links
This is another security fix. If you use chown() or chmod() on a
symbolic link, it affects the referenced file, not the symbolic link
itself.

X-Gentoo-Bug: 540006
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=540006
2015-02-19 14:39:04 -06:00
William Hubbs
6781667641 typo fix 2015-02-15 16:15:18 -06:00
William Hubbs
b17af3c85f checkpath: security fix for -m and -o options
Do not change permissions on the target if it is a file and has multiple
hard links. This is necessary because a hard link can be an attack
vector to gain privilege escalation.

X-Gentoo-Bug: 540006
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=540006
2015-02-15 16:04:43 -06:00
Will Miles
3f80f22e22 Prioritize local includes and libraries
This fixes #35.
2015-01-24 13:48:53 -06:00
Will Miles
cddb4aad08 Fix off-by-one error in --test argument printout in start-stop-daemon.
Fixes #34.
2015-01-22 12:53:41 -06:00
Doug Freed
74478830a8 fix double free of pidfile
This fixes a double free of the pidfile variable. For discussion of this
issue, see the bug.

X-Gentoo-Bug: 531600
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=531600
2015-01-12 10:30:36 -06:00
William Hubbs
7a92eb8887 rename git.mk to gitver.mk
This is a more descriptive name since this file only sets the gitver
variable.
2014-12-05 11:55:45 -06:00
Jason Zaman
1932360adc Integrate the functionality from runscript_selinux.so
runscript used to dlopen() runscript_selinux.so. This adds equivalent
functionality directly in to runscript instead. It authenticates with
either PAM or shadow and optionally has a dep on audit.

X-Gentoo-Bug: 517450
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=517450
2014-11-03 09:31:25 -06:00
Alexander Vershilov
be952bebb3 Fix incorrect handling of chroot option.
Fixes #28.

X-Gentoo-Bug: #527370
X-Gentoo-Bug-Url: https://bugs.gentoo.org/show_bug.cgi?id=527370
2014-11-01 16:44:30 -05:00
William Hubbs
7700e6fe79 Fix compile errors created by bundling queue.h 2014-10-24 10:44:14 -05:00
Anthony G. Basile
6ca79042b9 helpers.h, start-stop-daemon.c: remove uneeded macros
TAILQ_CONCAT, TAILQ_FOREACH_SAFE and LIST_FOREACH_SAFE are defined
in our bundled queue.h and are no longer required.
2014-10-23 19:14:06 -05:00
Anthony G. Basile
1e0a4bebde Bundle <sys/queue.h> from NetBSD
We are bundling this to allow building on musl-based systems since musl
does not include <sys/queue.h>.
2014-10-23 19:14:06 -05:00
William Hubbs
ca6b86be44 Fix all tests for GNU/kFreeBSD
It is necessary to check for both the kernel and c library because
__FreeBSD_kernel is also defined on native FreeBSD [1].

[1] http://sourceforge.net/p/predef/wiki/OperatingSystems/
2014-10-23 18:47:24 -05:00
Gabriele Giacone
4ac289b539 Fix rc_svcdir for GNU/Hurd 2014-10-23 13:05:08 -05:00
Svante Signell
875f03e27c fix defines for GNU/Hurd 2014-10-23 13:00:24 -05:00
Gabriele Giacone
89c8a62a10 Fix rc_svcdir for GNU/kFreeBSD 2014-10-22 13:27:37 -05:00
Svante Signell
3f82edbeb9 Fix GNU/kFreeBSD port
Check for __FreeBSD_kernel instead of __GLIBC__ in source files.

note from William Hubbs:
I was told this is a better check for GNU/kFreeBSD than checking the
C  library the source is being compiled against.
GNU/kFreeBSD than checking which library we are using.
2014-10-22 11:05:07 -05:00
Anthony G. Basile
86e9aa0d36 einfo.h, rc.h.in: simplify __BEGIN_DECLS logic
There is no need to redefine __BEGIN_DECLS and __END_DECLS.
We simplify the logic here and avoid undefining these macros.
2014-10-22 07:46:49 -04:00
Anthony G. Basile
4a08517cac einfo.h, rc.h.in: ensure __BEGIN_DECLS is defined
Some Standard C Libraries, like musl, don't define __BEGIN_DECLS
or __END_DECLS.  We add some ifdef magic to ensure these are
available.
2014-10-21 09:39:34 -04:00
Alexander Vershilov
f9acd65497 librc:look for the pid file in a chroot if defined
X-Gentoo-Bug: 524388
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=524388
2014-10-20 15:44:19 -05:00
William Hubbs
866501be1c typo fix 2014-09-20 16:51:30 -05:00
William Hubbs
d1e71b07af Show rc and runscript deprecation warnings in verbose mode
These messages are being changed for this release to show in verbose
mode because of the number of times they display.
2014-08-11 12:32:44 -05:00
William Hubbs
2624a8c8a7 checkpath: apply ownership to all paths given on command line
The stat structure was not being initialized correctly in do_check. This
was causing the owner adjustment to be skipped if the first path had the
correct owner.

Also, the "correcting owner" message should always be printed when the
owner is being changed.

X-Gentoo-Bug: 518042
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=518042
2014-07-28 10:41:24 -05:00
William Hubbs
275714bdc7 checkpath: style fix 2014-07-25 11:04:57 -05:00
William Hubbs
1f7582c78b src/librc/librc-daemon.c: style fix 2014-07-19 13:03:00 -05:00
William Hubbs
cc1bc6a4ce src/rc/Makefile: typo fix 2014-07-19 12:59:35 -05:00
William Hubbs
40f42ced21 rc-status: fix infinite loop when using stacked runlevels
Remove the recursive call in print_stacked_services which was causing an
infinite loop when using stacked runlevels.
I would like to thank Doug Freed and Jason Zaman for assisting with
tracking this down.

X-Gentoo-Bug: 514972
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=514972
2014-07-17 23:10:28 -05:00
Jason Zaman
89907b60ba move the selinux_setup function into rc-selinux
X-Gentoo-Bug: 516956
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516956
2014-07-16 17:59:25 -05:00
William Hubbs
a94a9740d5 checkpath: style fixes 2014-07-16 15:03:11 -05:00
William Hubbs
8b8edc2970 style fixes 2014-07-16 14:48:03 -05:00
William Hubbs
010c2ab18b Rename SELinux source files
The name rc-selinux-util.* is a bit long, so I renamed the source files
to rc-selinux.*

X-Gentoo-Bug: 516956
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516956
2014-07-16 14:14:37 -05:00
Jason Zaman
9c689542c3 checkpath: restore the SELinux context
X-Gentoo-Bug: 516956
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=516956
2014-07-16 13:09:38 -05:00
William Hubbs
71d6d61b28 checkpath: fix logic for the writable option
The -W option does not need an argument of its own; it can take the
first path after all other options are processed on the command line.

Also, move the processing for the -W option out of the switch so it will
be in the same loop as the other processing.
2014-07-13 14:12:36 -05:00
William Hubbs
d80482c2f4 checkpath: fix error message in previous commit 2014-07-11 15:23:38 -05:00
William Hubbs
d0040aff0a checkpath: report an error if required options were not specified
Before this commit, not specifying -d, -f, -p or -W in a checkpath
command meant the command exited successfully but actually did nothing.

This is an error condition, so report it as such.
2014-07-11 15:04:06 -05:00
William Hubbs
9eb9b28d3e librc: filter out container processes on OpenVZ host
Thanks to info and testing done by Daniel Robbins <drobbins@funtoo.org>,
there is now a fix for this. Below is his description of the steps
OpenRC needed to use.

1) See if /proc/<pid>/status exists
2) If it does, see if it has a "envID:" field
3) If it does, see if "envID:" is set to "0"
4) If so, then it's one of the host's processes and should be a
candidate for the list. Otherwise, it is one of the container's
processes and should be ignored.

This should fix the bug and allow start-stop-daemon to work properly on
OpenVZ hosts.

X-Gentoo-Bug: 376817
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=376817
2014-06-20 16:01:47 -05:00
William Hubbs
de186401e5 fstabinfo: fix mount and remount
The mount and remount options should always be processed. They were only
being processed if -q was not on the command line.

X-Gentoo-Bug: 498206
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=498206
2014-01-18 13:50:05 -06:00
Benda Xu
abadaa04ab rc-update: add option to remove a service from all runlevels
The -a option,which only applies to the del command, is used to remove a
service from all runlevels.

X-Gentoo-Bug: 497740
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=497740
2014-01-13 10:41:38 -06:00
William Hubbs
3470eda3f5 Rename runscript to openrc-run
This was requested by Debian, because the minicom software, which is
available on Debian and other distros, has a binary named runscript. We
are keeping a backward compatibility symlink for now, but this allows
Debian or any other distro to safely remove the symlink.

X-Gentoo-Bug: 494220
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=494220
2013-12-29 22:57:31 -06:00
William Hubbs
c096ad63ca add openrc binary to ignore patterns 2013-12-13 12:19:27 -06:00
William Hubbs
7a35daeab7 runscript: clarify the message wrt scheduling
The message about a service being scheduled to start was confusing to
some of our users; I was told this wording is more clear.

X-Gentoo-Bug: 493070
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=493070
2013-12-13 01:09:55 -06:00
William Hubbs
7b5fa011ac Rename the rc binary to openrc
Debian requested this rename due to the "rc" binary conflicting with the
"rc" binary from the plan 9 shell.

We also add a deprecation warning to the binary when it is run as rc to
encourage users to switch to openrc instead.

X-Gentoo-Bug: 493958
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=493958
2013-12-12 18:31:29 -06:00
William Hubbs
1fccf91df1 rc-update: make "service already installed" message informational
This message was being sent to stderr, and it should be sent to
stdout since it is informational. This change was requested by
zero_chaos.
2013-12-01 11:20:29 -06:00
Steven Chamberlain
766d71c2d3 Begin port to GNU/kFreeBSD
This is just a minimal port to get Debian up and running; the rest will
be done later.
2013-10-30 01:40:03 -05:00
William Hubbs
aeb670f4e8 librc: do not allow "." and ".." as runlevel names
The rc_runlevel_exists function was attempting to treat "." and ".." as
valid runlevels; however, this should not be allowed.

X-Gentoo-Bug: 488710
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=488710
2013-10-21 14:21:22 -05:00
William Hubbs
48981be8a8 Revert "Make einfo routines private"
This reverts commit de88aff0a8.
I was advised that splashutils links to libeinfo, so we do have a
consumer for this library.
2013-10-21 13:49:41 -05:00
William Hubbs
f751e14416 convert flock() messages to verbose warnings
Convert these messages to warnings that are only displayed if
EINFO_VERBOSE is set to yes in the environment.

This is based on a suggestion from Patrick Lauer <patrick@gentoo.org>.

X-Gentoo-Bug: 487588
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=487588
2013-10-12 09:38:09 -05:00
William Hubbs
82378bd92d start-stop-daemon: fix do_stop calls
Several calls to do_stop were forcing the test parameter to be true,
which was causing extra output to the terminal, such as:

* Would send signal 0 to pid xxxxx

This should only happen if the --test command line option was used.
2013-10-06 12:00:37 -05:00
Natanael Copa
03c67bcc27 librc: fix a read off-by-one bug
We should first check if we are within bounds and then read rather than
the opposite.

This makes valgrind happy.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2013-10-04 14:02:02 -05:00
Natanael Copa
681a37e7bd librc: fix off-by-one bug
We need allocate space for both the added leading '-' and the trailing
'\0'.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2013-10-04 14:01:46 -05:00
William Hubbs
56d592866c start-stop-daemon: fix eerorr calls in get_pid
The eerror calls in this function make it too verbose, so change them to
ewarnv() calls instead. This means that they will only print if the
--verbose option is used or EINFO_VERBOSE=yes is set in the environment.
2013-09-30 16:55:25 -05:00
William Hubbs
de88aff0a8 Make einfo routines private
The libeinfo library has no consumers other than OpenRC, so there is no
reason for it to be maintained as a library. The einfo routines are now
an object that links with the rc binary.
2013-09-26 22:18:21 -05:00
William Hubbs
9e989227ab start-stop-daemon: remove the verbose variable
Along the same lines as the quiet variable, this is controlled by an
environment variable for the einfo code, so we do not need a separate
boolean flag.
2013-09-24 01:47:17 -05:00
William Hubbs
d6436bed09 start-stop-daemon: remove the quiet variable
The suppression of output is controlled in the e* functions themselves,
so there is no need for a variable to test in start-stop-daemon.

X-Gentoo-Bug: 482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
2013-09-23 17:28:39 -05:00
William Hubbs
4480f1f395 rc: add service to ignore patterns 2013-09-23 13:37:21 -05:00
William Hubbs
0ba14ae720 style fixes 2013-09-23 12:40:26 -05:00
Alexander V Vershilov
7716bf31de Fix stacked runlevel support
Patch was provided by  Max Hacking <max.gentoo.bugzilla@hacking.co.uk>
and slightly fixed by Alexander Vershilov <qnikst@gentoo.org> and
William Hubbs <williamh@gentoo.org>.

Fixes:
1). Rebase to newest OpenRC version.
2). Remove code style fixes. Port to currect code style.
3). Fix rc_runlevel_stack instead of introducing new function.
4). Make get_runlevel_chain a private function.

X-Gentoo-Bug: 467368
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=467368
2013-09-20 14:27:31 -05:00
William Hubbs
445b297360 rc: add support for suppressing error messages
Add support for suppressing error messages with --quiet specified twice
on the command line.

X-Gentoo-Bug: 482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
2013-09-03 19:05:13 -05:00
William Hubbs
2590bf7a2b libeinfo: add separate variable to suppress eerror messages
Add an EERROR_QUIET environment variable which works like EINFO_QUIET
but for the eerror functions. This will allow library consumers to
choose whether to suppress eerror messages separately from einfo and
ewarn messages.

X-Gentoo-Bug: 482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
2013-09-03 13:03:55 -05:00
William Hubbs
a78b18e291 libeinfo: suppress output for eerror* functions
This makes the eerror* functions honor the EINFO_QUIET environment
variable like the einfo* and ewarn* functions.

X-Gentoo-Bug: 482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
2013-08-28 14:23:46 -05:00
William Hubbs
72b58b9e6b Revert "Libeinfo: do not suppress ewarn() messages"
This reverts commit 4ee62c7903.

The previously referenced commit broke consistency because ewarnx() was
respecting the EINFO_QUIET environment setting, but after this commit,
ewarn() was not.
Also, due to discussion on the below referenced bugs, I think we do
want to suppress warnings when EINFO_QUIET=yes.

X-Gentoo-Bug: 482396
X-Gentoo-Bug: 439174
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=439174
2013-08-27 10:26:48 -05:00
William Hubbs
5c3e5d801b start-stop-daemon: remove redundant test of the quiet value
The einfo() function tests for the EINFO_QUIET environment variable
directly, and this is the variable that is set by the --quiet flag, so
there was no reason for this test to exist.
2013-08-26 17:09:18 -05:00
William Hubbs
bb8a9c087d start-stop-daemon: fix --quiet switch
The --quiet switch wasn't really quiet, because we changed it to report
errors. I am changing it back due to discussions on the listed bugs.

X-Gentoo-Bug: 482396
X-Gentoo-Bug: 439174
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=439174
2013-08-26 15:51:11 -05:00
Gary
9ebd5a6aff Add support for DragonFly BSD 2013-07-25 22:33:24 -05:00
Alexander V Vershilov
c18d623dc0 rc-status: fix typo
X-Gentoo-Bug: 477318
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=477318
2013-07-19 15:30:28 -05:00
Alexander V Vershilov
0f70cd067f rc-status: fix -a to show all services
We need to unset rc_svcname so that all of the services are added to the
list to display.

X-Gentoo-Bug: 409787
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=409787
2013-07-16 12:53:03 -05:00
William Hubbs
a09a60c4cf Add service applet
The service applet is equivalent to rc-service. This was added so that
we will be more compatible with Debian and Fedora.

Reported-by: cardoe@gentoo.org
X-Gentoo-Bug: 468168
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=468168
2013-05-02 13:52:27 -05:00
William Hubbs
70628a875b fix the build for non-selinux systems
The symlinks should be created only if MKSELINUX=yes, not if it just has
a value.
2013-05-01 18:20:01 -05:00
William Hubbs
10a4385e40 rc: allow switching runlevels without stopping services
OpenRC, by default, stops all services that are not listed in a runlevel
when rc is used to switch runlevels. This adds a -n/--no-stop command
line option to rc which tells it to skip stopping the services which are
not in the runlevel.

Reported-by: gentoo@thoth.purplefrog.com
X-Gentoo-Bug: 372585
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=372585
2013-04-28 12:51:12 -05:00
Natanael Copa
e4668a5061 Fix autodetection of lxc
The /proc/1/environ contains various \0 terminated strings. The current
code will only work when the search string is in the first of those.

To fix this we look for strings in entire buffer.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2013-04-09 02:25:26 -05:00
Andrew Gregory
fb10b97172 rc-service: add usage message
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-25 14:45:39 -06:00
Andrew Gregory
927207c1b7 rc-status: improve usage message accuracy and consistency
This makes it more clear that many of the options are used as an
alternative to a runlevel.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-25 14:44:04 -06:00
Andrew Gregory
5872bf1333 rc-update: improve usage message accuracy and consistency
The old message did not indicate that the runlevel argument was optional
for add and del or that it could be used with show.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-25 14:41:30 -06:00
Andrew Gregory
67377cc09f rc: add usage message
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-25 14:39:50 -06:00
Andrew Gregory
8c90042dee make BINDIR and SBINDIR available to input files
BINDIR and SBINDIR can be set independently of PREFIX and may not be set
to PREFIX/bin as scripts currently assume.

Note from William Hubbs:

This adds @BINDIR@ and @SBINDIR@ macros to the sed commands run to
convert *.in files to the executable form.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-02-23 20:30:39 -06:00
Alexander Mezin
970893adf3 runscript: retry prefix flock if it is interrupted by a signal
Reported-by: Pacho Ramos <pacho2@gentoo.org>
X-Gentoo-Bug: 434800
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=434800
2013-02-15 13:28:35 -06:00
Andrew Gregory
3896b9d55c libeinfo: check for "color" in the terminal name
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2013-01-04 08:48:08 -06:00
William Hubbs
630d23283a Add tools directory
This directory will contain tools which are not necessary for OpenRC to
run, but which some users have found useful.

The first of these is deptree2dot, which converts /run/openrc/deptree to
a .dot file for use with graphviz. This can assist in finding circular
dependencies.
2013-01-02 18:00:04 -06:00
William Hubbs
a9272f50f7 Do not add a prefix to the /run directory
This doesn't affect us on gentoo, but on archlinux, which has done the
/usr merge, OpenRC was looking for /run under PREFIX. /run is always at
the root level, so it shouldn't have prefix appended to it.

Reported-by: udeved@openrc4arch.site40.net
2012-12-03 18:33:21 -06:00
William Hubbs
e634376482 Checkpath: print the path when correcting the owner
Checkpath was printing the path it was working with unless it was
correcting the owner. In this case, it was printing "checkpath", which
is not very useful.

Reported-by: <devurandom@gmx.net>
X-Gentoo-Bug: 439014
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=439014
2012-10-27 12:59:58 -05:00
William Hubbs
978dbe0284 mountinfo: respect the -q command line option
Previously, we were setting the quiet flag before the command line was
parsed. Since the flag is only used once, we can just read the
environment variable which is set by the parsing process.

Reported-by: <devurandom@gmx.net>
X-Gentoo-Bug: 439010
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=439010
2012-10-24 12:29:29 -05:00
William Hubbs
20af890ac2 Spacing fixes 2012-10-17 18:47:36 -05:00
William Hubbs
b68d4b3580 checkpath: fix bool values
Use true/false for bool values instead of 0/1.

Reported-by: <vapier@gentoo.org>
2012-10-09 18:55:09 -05:00
William Hubbs
6f345abe91 checkpath: change the owner/group only when requested to do so
Fix checkpath so that it only changes the owner/group if -o is on the
command line.

Reported-by: <flameeyes@gentoo.org>
X-Gentoo-Bug: 437560
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=437560
2012-10-09 16:44:01 -05:00
William Hubbs
361f5ce2b8 set the RC_UNAME environment variable when updating dependencies
This is needed because the network script uses this variable in the
depend() function but it wasn't exported when this was run.

Reported-by: <aaly90@gmail.com>
2012-10-04 22:01:33 -05:00
William Hubbs
0a132cdca5 fix RC_SVCDIR on prefix systems
On prefix systems, RC_SVCDIR was being defined based on the host
operating system. This is not correct because there will not be a /run
directory in a prefix.
This commit moves RC_SVCDIR on prefix systems to the same location as on
non-Linux systems.
2012-09-20 16:04:48 -05:00
Christian Ruppert
6b1e806c8b Typo: emtpy -> empty
Reported-by: Walter <walter@pratyeka.org>
X-Gentoo-Bug: 430146
X-Gentoo-Bug-URL: https://bugs.gentoo.org/430146
2012-09-14 22:59:01 +02:00
Christian Ruppert
3cd293c515 Silence the right get_pid() call 2012-09-12 21:35:55 +02:00
Christian Ruppert
a06072b395 Silence get_pid(), OpenRC will give the process some time to create the PID file and the first get__pid() call may fail. 2012-09-12 21:00:20 +02:00
William Hubbs
5092595835 add RC_PREFIX environment variable
This will be used by init scripts which want to be able to run in a
Gentoo Prefix installation. RC_PREFIX will contain the prefix offset.
2012-09-09 22:22:15 -05:00
Christian Ruppert
9afdf50667 Do not silence errors 2012-08-19 00:26:38 +02:00
Christian Ruppert
8dc06e3259 Fix quiet usage
EINFO_QUIET will always been unset when we first do unsetenv("EINFO_QUIET") and
later query it again anyway..
2012-08-18 23:21:40 +02:00
William Hubbs
e641b43849 Bring Back prefix support
We now have a team member who is interested in OpenRC on prefix, so I am
bringing it back to the main tree.
2012-07-26 10:54:48 -05:00
Mike Frysinger
f5ba232fb4 rc: fix inverted string compare logic
X-Gentoo-Bug: 417227
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=417227
Reported-by: sphakka <marcoep@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-23 19:32:59 -04:00
Mike Frysinger
6241f17e95 rc: fix thinko in applet collapse
We want to lookup the service based on the applet name.

Reported-by: Christian Ruppert <idl0r@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-16 18:16:51 -04:00
William Hubbs
82d3918d7a move rc_svcdir to /run/openrc on Linux systems
If you are not using linux, this should not affect you.

If you are using linux, from this point forward, openrc requires the
/run directory to be a mounted tmpfs. If it is, you can run
@LIBEXECDIR@/sh/migrate-to-run.sh as root to migrate your dependency
tree and state information to the new location. If it is not, you must
create the /run directory as root with permissions 755 then reboot your
system.

reported-by: Maxim Kammerer <mk@dee.su>
X-Gentoo-Bug: 401059
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=401059
2012-05-14 13:49:06 -05:00
Mike Frysinger
2486eb4989 rc: collapse the applet if statements into a single array walk
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-06 01:17:30 -04:00
Mike Frysinger
0813a80223 add a new ARRAY_SIZE macro and use it
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-06 01:17:30 -04:00
Mike Frysinger
3969cb2a85 split out librc-independent helpers into a dedicated header file
Many of these helpers are not special to librc, so split them out so they
can be used in all source trees (including libeinfo).

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-06 01:17:30 -04:00
Christian Ruppert
441272ff97 Reduce overhead by leaving rc_deptree_update_needed() as soon as possible
There's no need to check any further if we're returning true anyway.

Signed-off-by: Christian Ruppert <idl0r@gentoo.org>
2012-04-26 12:40:13 +02:00
Christian Ruppert
fd6bbfbe07 Disable some questionable lines
Caused by bug 412589 I was looking at the do_mark_service() function and quickly
found that the segfault is caused by a strlen() call against a NULL pointer.
I also noticed it's using "/exclusive/%s.%s" so svcname.pid, all other functions
are just using the svcname.. So it seems that svcname.pid was/is never used and
thus not necessary at all.

In relation to the above, the if statement in the do_mark_service() function
("if (ok && svcname && strcmp(svcname, service) == 0) {") needs to be
fixed/improved as svcname and service are almost always equal, see my comment in
the function for further details.

Signed-off-by: Christian Ruppert <idl0r@gentoo.org>

Reported-by: Patrick McLean <chutzpah@gentoo.org>
X-Gentoo-Bug: 412589
X-Gentoo-Bug-URL: https://bugs.gentoo.org/412589
2012-04-26 10:33:54 +02:00
Christian Ruppert
1f5072421e Remove duplicate getenv("RC_SVCNAME") call 2012-04-24 03:49:04 +02:00
William Hubbs
300c03203d librc: Do not output error messages from within the library.
This fixes a compile issue. Also, it is cleaner to have the client
output error messages as opposed to having the library do this.

Reported-by: Ewoud Kohl van Wijngaarden <gentoo@kohlvanwijngaarden.nl>
X-Gentoo-Bug: 409743
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=409743
2012-03-26 15:04:40 -05:00
William Hubbs
582c8e9868 librc: make rc_proc_getent available for all operating systems
This looks up an option on the kernel command line. For now, itworks on
linux and returns NULL on the bsds, but we are definitely open to
patches for that side.
2012-02-25 15:00:03 -06:00
Christian Ruppert
de6323ba51 Fix rc_proc_getent() undeclared on BSD
X-Gentoo-Bug: 405713
X-Gentoo-Bug-URL: https://bugs.gentoo.org/405713
Reported-by: Dmitri Bogomolov <4glitch@gmail.com>
2012-02-25 17:56:24 +01:00
William Hubbs
3272261479 Skip pam if running as root
Reported-by: Piotr Karbowski <piotr.karbowski@gmail.com>
X-Gentoo-Bug: 386623
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=386623
2012-02-23 16:47:52 -06:00
William Hubbs
3247184d86 Remove prefix support
I spoke with the prefix team sometime back and was told that they do not
have an interest in using OpenRC on prefix systems.
2012-02-21 07:27:16 -06:00
William Hubbs
04db6c3d39 rc: remove calls to rc_sys_v2 and rc_sys_v1
These separate calls are no longer needed since we do not warn about
falling back to automatic detection.
2012-02-20 20:04:57 -06:00
Jory A. Pratt
3c602e7422 remove the warning about falling back to autodetection 2012-02-20 19:07:54 -06:00
Christian Ruppert
6913f1deb6 Fix some more warnings 2012-02-12 20:37:05 +01:00
Christian Ruppert
d9dc5dc423 Use size_t instead of int 2012-02-12 02:23:04 +01:00
Christian Ruppert
8c55f1e50d Remove unused/useless function single_user() 2012-02-11 00:24:46 +01:00
William Hubbs
0fcc6251fc fstabinfo: add --remount option
This adds a --remount/-R option to fstabinfo. This new option works like
--mount, but it adds the necessary options to remount a file system
that is already mounted.

Reported-by: Piotr Karbowski <piotr.karbowski@gmail.com>
X-Gentoo-Bug: 401573
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=401573
2012-01-31 16:33:05 -06:00
William Hubbs
7da8394a8e Complain about loading /etc/conf.d/rc
Openrc was quietly loading this file if it existed and this was causing
some issues, so now openrc loads the file and complains about it.

Hopefully the warning message will convince everyone to remove this file
and migrate the settings to @SYSCONFDIR@/rc.conf where they belong.
2012-01-30 13:24:54 -06:00
Christian Ruppert
2d2751c433 Do not unlink the temp. log during shutdown
Also ignore errors in case of EROFS (Read-Only file systems)
Reported-by: Maxim Kammerer
X-Gentoo-Bug: 401115
X-Gentoo-Bug-URL: https://bugs.gentoo.org/401115
2012-01-28 18:59:16 +01:00
Christian Ruppert
6be8a0679b Do not loop flock()
There's no need to loop until flock was successfully as flock() would simply
block till a previous lock has been released.
There's more to do to fix it properly, see my comments in the patch.

Reported-by: James Le Cuirot <chewi@aura-online.co.uk>
X-Gentoo-Bug: 360013
X-Gentoo-Bug-URL: https://bugs.gentoo.org/360013
2012-01-28 16:43:54 +01:00
Christian Ruppert
7ea5c614d9 Add -W/--writable function to checkpath
Checkpath -W will use access(3p) to determine whether or not a path is
writable. This is more accurate than test(1p) because it also takes into
account whether or not the filesystem is mounted read-only.

Modified by William Hubbs to add the man page update.
2012-01-26 14:42:18 -06:00
Christian Ruppert
5d441dd376 Whitespace 2012-01-26 20:47:46 +01:00
Christian Ruppert
44019f6542 Add is_writable() function to check whether a path is writable or not 2012-01-26 20:46:31 +01:00
Christian Ruppert
8b4fc05ff2 Disable parallel startup in interactive mode 2012-01-24 19:41:50 +01:00
Christian Ruppert
ced60319e3 Override rc.conf options only 2012-01-24 19:41:50 +01:00
Robin H. Johnson
426b94bd69 Per the systemd tmpfiles implementation, we need to watch out for umask during initial creation of files as well as potentially changing permissions later. Also do not abort if the items exist already, per truncate rules in tmpfiles.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-01-23 10:26:58 +00:00
Robin H. Johnson
06b8084b2c Ensure that when -F is passed, existing files are truncated properly.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-01-23 05:30:00 +00:00
Robin H. Johnson
e3d0fe06bd Respin features.h usage so that we correctly test for features before we use them. Some BSD libc implementations may have one or the other flag, but not both.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-01-23 05:26:40 +00:00
Robin H. Johnson
319f5003c6 Revert "Drop include for features.h"
This reverts commit 30a565f80d.
2012-01-23 05:24:54 +00:00
William Hubbs
30a565f80d Drop include for features.h
The following information is taken from the feature_test_macros man
page:

<features.h> is a Linux/glibc-specific header file.  Other systems have
an analogous file, but typically with a different name.  This header
file is automatically included by other header files as required: it is
not necessary to explicitly include it in order to employ feature test
macros.

Reported-by: Tibor Vago <tibor.vago@gmail.com>
X-Gentoo-Bug: 399635
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=399635
2012-01-22 14:41:47 -06:00
William Hubbs
85c90f9a1d small style fix 2012-01-20 21:38:13 -06:00
William Hubbs
d729f9d0f2 style fixes 2012-01-16 12:11:29 -06:00
Christian Ruppert
30a56cdb46 Add "ifstopped" command to runscript
Signed-off-by: Christian Ruppert <idl0r@gentoo.org>
2012-01-15 02:10:35 +01:00
Christian Ruppert
14625346c0 Allow overriding of rc.conf options via kernel cmdline
This adds a new function that allows us to override some specific rc.conf
options via the kernel cmdline aka /proc/cmdline.
This makes esp. sense in cases where a rc_parallel enabled system has boot
issues. Simply disable rc_parallel by appending rc_parallel=no to your kernel
cmdline.
2012-01-15 01:02:11 +01:00
Christian Ruppert
c3be42006b Rename proc_getent to rc_proc_getent and make it global 2012-01-15 01:02:11 +01:00
Robin H. Johnson
66f4305e1c rc/checkpath: tmpfiles.d backend creation code
This commit provides the checkpath applet with feature parity to
systemd's tmpfiles.c create_item function.

Very similarly to the systemd function, it does NOT do any of the
cleanup work in this function.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2012-01-09 19:20:47 -08:00
Christian Ruppert
34b7632d1d Do not exit immediately when a service has been stopped already
The old behaviour was to exit(EXIT_SUCCESS) in case the service has been stopped
already, even if further commands has been passed to the init script
(like zap, start).
So using for example /etc/init.d/foo stop zap start would abort immediately
after "stop" if the service has been stopped already. Though there may be cases
were we need it to proceed with the remaining commands, zap and start in this
case.
This patch fixes the behaviour to continue and proceed with the remaining
commands whenever necessary.

X-Gentoo-Bug: 371845
X-Gentoo-Bug-URL: https://bugs.gentoo.org/371845
2011-12-31 03:35:32 +01:00
Christian Ruppert
372745844b Code style fixes 2011-12-30 16:03:24 +01:00
Christian Ruppert
0d6ae379f4 Compare stricter in proc_getent
The new proc_getent compares stricter so that e.g. "ro" doesn't match
root=/dev/sdaN anymore.
So it has to be either "ro" or "ro=".
2011-12-30 16:03:24 +01:00
Christian Ruppert
49e99a7393 Don't try to write the log during sysinit
During the sysinit and shutdown runlevels the logfile destination may be
read-only. Skip the error messages in this case.

X-Gentoo-Bug: 390645
X-Gentoo-Bug-URL: https://bugs.gentoo.org/390645
2011-12-29 13:58:08 +01:00
Christian Ruppert
8dcb7554ee Use RC_LEVEL_SHUTDOWN 2011-12-29 03:16:53 +01:00
Christian Ruppert
b754a27f62 Remove useless rc_runlevel_get() call
The current runlevel will be passed to rc_logger_open() already.
2011-12-29 03:08:29 +01:00
Christian Ruppert
ec65f181ea Don't print error when the logfile isn't writeable during shutdown
The logfile or its basedir may be read-only during shutdown because the
directory may be umounted or read-only remounted already. In this case we simply
skip this error.
This is related to a comment in bug 390645 but the initial bug is not fixed
through this commit.

X-Gentoo-Bug: 390645
X-Gentoo-Bug-URL: https://bugs.gentoo.org/390645
2011-12-29 02:50:24 +01:00
William Hubbs
e574b5d441 fix compile error
A variable used in the previous commit was actually removed in another
commit; that is why I didn't catch it.

Reported-by: Duncan < 1i5t5.duncan@cox.net>
X-Gentoo-Bug: 394369
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=394369
2011-12-11 14:33:39 -06:00
William Hubbs
5e01051c4e Allow init scripts to be executed with a relative path
This was a regression that was caused by the fix for
http://bugs.gentoo.org/show_bug.cgi?id=350910. I am reverting the commit
that we said fixed that bug and re-opening it.

Reported-By: Nathaniel <nathaniel@paust.us
X-Gentoo-Bug: 392457
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=392457
2011-12-11 01:18:08 -06:00
Mike Frysinger
453d13296d rc: usage: do not output non-printable short options in usage
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-19 02:43:25 -05:00
Mike Frysinger
c21c1f1e59 rc: usage: optimize help string alignment output a little
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-19 02:42:41 -05:00
Mike Frysinger
c7cc685458 rc: fix style around case_RC_COMMON_GETOPT
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-19 02:33:11 -05:00
Mike Frysinger
ef1ff1b4f2 make shell math operations style more succulent
Convert the style:
	var=$((${var} + 1))
to:
	: $(( var += 1 ))

The latter is easier to read imo.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-19 02:25:36 -05:00
William Hubbs
66e99b6d63 Fix compile warning 2011-11-17 16:06:18 -06:00
William Hubbs
5b1aaf8cc8 add support for extra_stopped_commands 2011-11-16 13:56:55 -06:00
Mike Frysinger
3f2e9c4e1f mountinfo: Do not error out if realpath fails
Reported-By: Dennis Schridde <devurandom@gmx.net>
X-Gentoo-Bug: 383333
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=383333
2011-11-15 15:19:55 -06:00
Mike Frysinger
16661d02e9 ssd: fix building when SYS_ioprio_set is missing
Older glibc's might not provide this.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-09 00:09:58 -05:00
William Hubbs
f46626dcfc add auto detection for lxc
Reported-by: Francesco Riosa <francesco+gentoo_bugzilla@pnpitalia.it>
X-Gentoo-Bug: 384151
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=384151
2011-11-07 08:39:16 -06:00
William Hubbs
5066d40ac8 Use pattern rules instead of suffix rules
Rework the makefiles to use pattern rules instead of suffix rules.
This is the preferred way to write implicit rules according to the gnu
make manual.
2011-10-29 09:43:24 -05:00
Christian Ruppert
e2f1464f47 Use the real/actual path when looking for mounts
/proc/mounts contains real/actual paths so we should do the same in mountinfo.
2011-09-08 19:20:20 +02:00
Christian Ruppert
5df9dc1af5 Remove unused variable 2011-09-08 18:42:05 +02:00
Flex
6d5b452ef5 Do not ignore return code for custom script functions
X-Gentoo-Bug: 380317
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=380317
2011-09-02 11:32:30 -05:00
Diego
b71f3bd2fd Start-stop-daemon: remove call to pam_authenticate 2011-09-01 17:08:55 -05:00
William Hubbs
4ee62c7903 Libeinfo: do not suppress ewarn() messages
The ewarn() function was affected by the EINFO_QUIET environment
variable which lead to warning messages being suppressed. Warnings
should not be suppressed.

Reported-by: Hanno Boeck <hanno@gentoo.org>
X-Gentoo-Bug: 380073
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=380073
2011-08-22 12:39:26 -05:00
William Hubbs
0c8bea2152 Improve processing of service directories and conf.d files
symbolic links should not be followed in an attempt to work out the name
of the service we are running. Also, @sysconfdir@/conf.d should be tried
as a backup directory for configuration files.

I would like to thank Robin Johnson for his input on this change.

X-Gentoo-Bug: 350910
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=350910
2011-07-31 10:00:48 -05:00
William Hubbs
370e5c775a runscript: rename saveDir back to save to fix compile error 2011-07-26 16:58:42 -05:00
William Hubbs
07694255a4 rename save and save2 for clarity
The names saveDir and saveLnk seem to better define how these variables
are used.
2011-07-20 14:38:55 -05:00
Christian Ruppert
a74382d9cb Fix rc_service_value_get() to return multiple lines as well
As introduced in bug 372547 using service_get_value() in the init scripts
or using rc_service_value_get() directly will only return one line.
This patch fixes it by using the new rc_getfile() function, it returns even
multiple lines. We're still using a char *, so the lines will be appended
instead of added into new element.

X-Gentoo-Bug: 372547
X-Gentoo-Bug-URL: http://bugs.gentoo.org/372547
2011-07-13 21:32:13 +02:00
Mike Frysinger
fdaf1c65cd Add a new function, bool rc_getfile(const char *, char **, size_t *)
<snip>
Read the entire @file into the buffer and set @len to the
size of the buffer when finished. For C strings, this will
be strlen(buffer) + 1.
Don't forget to free the buffer afterwards!
</snip>

We also fix bug 374899 by adding this new function.

X-Gentoo-Bug: 374899
X-Gentoo-Bug-URL: http://bugs.gentoo.org/374899
2011-07-13 21:31:20 +02:00
Christian Ruppert
ef22868f36 Do not skip similar config options
OpenRC goes through the config and checks each option for duplicates.
Lets say we're on "rc_logger" currently and its the last option in the config
file and we previously defined rc_logger_path.

It now goes through all previous config options and compares those against the
current one "rc_logger" *but* it compares only the first N bytes, in this
case strlen("rc_logger"). So it strips the _path from "rc_logger_path" which
ends up into "rc_logger" and it compares that against the current one (also
		"rc_logger"), it would then simply override the previous definition.

This patch fixes this behaviour to always compare the full option / variable
names.
2011-07-09 23:15:16 +02:00
Christian Ruppert
05e3251467 Rename rc_logger_path to rc_log_path 2011-07-06 21:16:15 +02:00
Christian Ruppert
44dc7db4f8 Improve logging
Add "e" (O_CLOEXEC) to all fopen() calls.
Remove system() call and replace it by fopen() and friends.
This also fixes bug 368933

X-Gentoo-Bug: 368933
X-Gentoo-Bug-URL: https://bugs.gentoo.org/368933
2011-07-05 23:42:21 +02:00
Christian Ruppert
003d4ba15b Don't write into optarg, this also fixes a compiler warning. 2011-07-05 00:51:29 +02:00
Christian Ruppert
70a3a3cf39 Add --startas/-a back to the optstring
X-Gentoo-Bug: 373609
X-Gentoo-Bug-URL: https://bugs.gentoo.org/373609
2011-06-30 20:21:48 +02:00
Mike Frysinger
d0bc4f20ad drop useless "All rights reserved" notice
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-06-29 19:46:31 -04:00
Christian Ruppert
b6766c2544 Use RC_CONF instead of the hardcoded /etc/rc.conf 2011-06-28 18:45:39 +02:00
Joe Harvell
24ba795563 Only print the deprecation warning for --chuid/-c when using it
The deprecation warning has been printed when using the replecement functions as
well, bug 373243.
2011-06-27 23:20:47 +02:00
Christian Ruppert
4eb37f67cf Warn if deprecated commandline options are used for start-stop-daemon 2011-06-05 16:49:12 +02:00
Mike Frysinger
e49da2af91 clean up gitignore files
Rather than listing explicit object files, ignore all of them in
the whole tree.

Also ignore patch/gdb related files throughout.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-06-03 17:07:22 -04:00
Mike Frysinger
11d8b70d74 rc-update: sort "show" output
X-Gentoo-Bug: 367305
X-Gentoo-Bug-URL: http://bugs.gentoo.org/367305
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-28 12:11:37 -04:00
Mike Frysinger
227f831639 cc.mk: move debug.mk out of end Makefiles
Since we always want debug.mk whenever we include cc.mk, move the include
out of the Makefiles and into cc.mk itself.  This also fixes an include
order bug in rc/Makefile where debug.mk is included before cc.mk and
breaks the default CFLAGS setup in cc.mk.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-28 12:00:34 -04:00
Mike Frysinger
fe18c7bb63 librc: tweak style: foo () -> foo()
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-28 11:53:29 -04:00
Mike Frysinger
f8ff4a86a3 rc: delete now unused local "i" variable
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-28 11:42:49 -04:00
Christian Ruppert
d59e245bc7 Fix dirname calls in runscript
runscript will try to get the dir and basename of a file/link in case it
contains at least one slash. This patch gives a temporary copy of the path to
the dirname() function since dirname() can modify its argument.
2011-05-23 14:23:15 -05:00
James Le Cuirot
8fcaba9a22 fix rc_service_extra_commands return value
If there were no extra commands, rc_service_extra_commands returned a
list containing a single empty string. This changes that to return an
empty list, which is more consistent with what you would expect.

X-Gentoo-Bug: 360013
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013
2011-04-27 15:27:16 -05:00
William Hubbs
04e256e3b8 fix list returned by rc_service_extra_commands
This function was returning the setting of the variable $opts, which is
not correct. $opts was used in baselayout-1, but it is replaced by
$extra_commands and $extra_started_commands in openrc.

This does not appear to break backward compatibility since this function
does not appear to be used anywhere in the openrc code.

Thanks to James Le Cuirot for the original patch.

X-Gentoo-Bug: 360013
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013
2011-04-27 14:46:59 -05:00
William Hubbs
07db27d220 typo fix
X-Gentoo-Bug: 217999
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=217999
2011-04-09 13:00:44 -05:00
William Hubbs
b512d0db98 new implementation of applet option
This reworks the implementation of the --applet option so that it is
processed in run_applets() and does not require two calls to the
getopts_long() function. It is based on code by Robin Johnson and Chris
Richards.

X-Gentoo-Bug: 351712
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=351712
2011-02-16 09:00:38 -06:00
William Hubbs
73d1a8698e make version option common
This reworks the code for the version option so that it is part of the
parser loop and is a common option to all applets.
2011-02-14 18:40:05 -06:00
Mike Frysinger
c0aa27ef32 tests: filter valid parisc relocs
Parisc generates a few relocs against internal symbols which are OK.

X-Gentoo-Bug: 258913
X-Gentoo-Bug-URL: http://bugs.gentoo.org/258913
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-02-14 12:06:58 -05:00
William Hubbs
04379b2de9 fix symlink target
The target for the symlinks in ${SBINDIR} (the same directory as the rc
binary) was "rc". This is not correct; the target should be
${SBINDIR}/rc instead.
2011-02-07 02:25:00 -06:00
William Hubbs
db6d680765 rework pam, ncurses and termcap include files
This allows error checking inside the included files instead of either
including the appropriate file or a blank file.

Also the blank file named .mk gets removed by this change.
2011-02-04 22:30:30 -06:00
William Hubbs
19037cbd83 remove unnecessary shell calls
The main makefile, init.d/Makefile and src/librc/Makefile all contain
several shell calls which can be handled as make conditionals. This
switches them to conditionals.
2011-02-04 17:46:57 -06:00
Chris Richards
21c5a022af selinux: replace symlinks with wrapper scripts
This needs to be done on selinux systems so the proper context can be
set for each rc applet.

X-Gentoo-Bug: 351712
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=351712
2011-01-31 14:54:02 -06:00
William Hubbs
cca7e9f7e1 use immediate evaluation for shell calls
This reworks the shell calls in the makefiles to use immediate
evaluation and should improve parallel building.

X-Gentoo-Bug: 289264
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=289264
2011-01-31 14:05:57 -06:00
Mike Frysinger
9ce957c3e7 librc: delete trailing newlines
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-01-17 20:05:13 -05:00
Mike Frysinger
c825a74dd1 tests: check for trailing blank newlines
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-01-17 20:04:53 -05:00
Robin H. Johnson
164b8e4e04 Document that rc_sys_v{1,2} should not be used outside of OpenRC. 2011-01-17 22:30:40 +00:00
Robin H. Johnson
de8b4855d3 Bug #351570: Fix hidden functions visibility for rc_deptree_load_file. 2011-01-17 19:36:51 +00:00
Robin H. Johnson
f3f55f1f6d Build cleanup: librc.funcs.hidden.list is generated by testsuite. 2011-01-17 19:34:09 +00:00
Robin H. Johnson
2b7c2b8cf1 Bug #351570: Hidden function fixes: rc_conf_value.
Refactor rc_conf_value into librc for use in library context.
Also requires moving:
- rc_conf internal static
- Defines: PROFILE_ENV, SYS_WHITELIST, USR_WHITELIST, RC_PATH_PREFIX
  moved to rc.h with new RC_ prefix added.
- Defines: RC_CONF, RC_CONF_OLD moved to rc.h.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2011-01-17 19:29:45 +00:00
Mike Frysinger
6e876bca13 tests: check for common style issues
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-01-17 04:49:35 -05:00
Mike Frysinger
faa2df1159 more whitespace cleanup
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-01-17 04:49:12 -05:00
Mike Frysinger
711713d664 start-stop-daemon: use termios.h rather than sys/termios.h
POSIX specifies termios.h, not sys/termios.h.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-01-17 04:48:13 -05:00
Robin H. Johnson
b2d0656814 Style fix: "char *foo" not "char* foo". 2011-01-17 08:46:41 +00:00
Robin H. Johnson
c0a3e25d48 Style fix: /* */ comments not // comments. 2011-01-17 08:43:40 +00:00
Robin H. Johnson
0c93f4df32 Style fix: "while (" not "while(". 2011-01-17 08:42:28 +00:00
Robin H. Johnson
b1fcf4ce9c Style fix: "if (" not "if(". 2011-01-17 08:41:02 +00:00
Robin H. Johnson
6804edfc85 Better error checking of argc for --applet call. 2011-01-17 08:39:44 +00:00
Robin H. Johnson
bfb87f2d51 Use xstrdup for style. 2011-01-17 08:34:03 +00:00
Robin H. Johnson
e6fc30da61 Clean up all trailing whitespace in src/. 2011-01-17 08:28:43 +00:00
Robin H. Johnson
49339525a9 Bug #351712: Implement --applet selection mode for SELinux wrappers.
In addition to detecting what multicall applet we want via argv[0],
provide an explicit override mode with a --applet initial argument.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2011-01-17 07:37:43 +00:00
Robin H. Johnson
b00ad439a6 Add new option -F to rc-depend tool, so that we can debug user deptree files easily. 2011-01-17 06:53:50 +00:00
Robin H. Johnson
0e90ae266a Factor out new function rc_deptree_load_file to aid in debugging deptree files from users. Loads from a given filename instead of the hardcoded RC_DEPTREE_CACHE define. 2011-01-17 06:32:46 +00:00
Eray Aslan
66abbefd6c bug 351160: make openrc exit codes LSB compliant
* status on a stopped service now has a return code of 3 (was 1)
* starting an already started service now has a return code of 0 (was 1)
* stopping an already stopped service now has a return code of 0 (was 1)
2011-01-12 19:46:11 -06:00
Robin H. Johnson
647df8cfe7 Make sure old rc_sys code never runs if the rc_sys variable exists.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2011-01-05 22:33:03 -08:00
Robin H. Johnson
3d4d1ab14b Remove broken automatic LXC subsystem detection.
Any system using cgroups was being detected as an LXC system. This was
triggering on OpenVZ under RHEL6 as well as the "automated per tty task
groups" as discussed on the LKML.

All LXC users should now switch to the new rc_sys variable introduced in
the previous patch.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2011-01-05 22:09:34 -08:00
Robin H. Johnson
09f990a7c8 Implement explicit selection of subsystem types.
- Fixes bugs #347583, #349389, both of which were triggered by cgroups
  being detected as the LXC subsystem type.
- Makes it much easier to select "prefix" type.
- "rc -S" will now print a warning if you have not configured rc_sys in
  /etc/rc.conf
- All other semantics of rc_sys are unchanged in this patch.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2011-01-05 22:09:34 -08:00
Thomas Pfaff
062223a5df Avoid race condition in runscript (bug #319865)
Under normal conditions, runscript creates one child and waits for its
termination, which is signaled by a pipe write from the SIGCHLD
sighandler.

When running killprocs however more than one SIGHCLD signal is generated, at
least on all of my amd64 boxes running on real hardware and in vmware.

When the first SIGCHLD occurs svc_exec leaves the loop and closes the pipe.
Subsequent SIGCHLDs during the close can lead to a race condition and create an
EBADF error in the pipe write (pipe is closed but the file handle is still !=
-1).

We avoid this by blocking SIGHCHLD during the pipe close.
2010-12-03 14:01:28 -06:00
Mike Frysinger
3036b44798 restore init.d pause option 2010-04-09 02:19:40 -04:00
Mike Frysinger
acc0edb040 restore old e* func output
Gentoo has always used the sytle:
 * moo ...                [ ok ]
Latest openrc now does:
* moo...                    [ok]

Realistically, 4 spaces out of 80 on reduced terminals doesn't make any
sort of realistic difference and it's been just fine for the last 10
years, so keep the default behavior.
2010-04-09 02:19:40 -04:00
Roy Marples
4d86d34635 Fix -s and -S. 2010-03-26 22:10:03 +00:00
Roy Marples
7271449a0c Fix two leaks. 2010-03-17 20:37:47 +00:00
Mike Frysinger
ecf9ef49a7 random spelling fixes
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2010-01-08 22:02:51 +00:00
Roy Marples
dc3ccd8101 start-stop-daemon can now set process IO scheduling. 2009-12-14 08:47:48 +00:00
Roy Marples
509e34d425 Only allow one service to be provided by default.
Fixes Gentoo #293139.
2009-11-14 08:37:05 +00:00
Roy Marples
0de1d18d41 Fix logic 2009-11-13 22:29:01 +00:00
Roy Marples
80d4ce3a11 Add a --warn option to just warn when reference file does not exist.
Fixes Gentoo #291894.
2009-11-13 21:31:09 +00:00
Roy Marples
95ee39ab1c Add support for Linux Containers, fixes #202.
Patch by bug reporter.
2009-11-04 19:21:24 +00:00
Roy Marples
ac6808a73e Regenerate version.h if necessary 2009-10-16 08:13:34 +01:00
William Hubbs
c96a015742 fix wait time for gentoo bug 288495
The wait time was in seconds.  This patch converts it to milliseconds.
2009-10-15 20:25:01 +01:00
Roy Marples
a8f6a9b654 Add new utility and init script swclock that sets the system time based on
the mtime of a file. It saves the shutdown time to this file also.
This is handy for systems without a working RTC chip.
Based on an idea by Michael A. Smith <michael@smith-li.com>.
Fixes Gentoo #272073.
2009-10-13 08:03:45 +01:00
Roy Marples
07f9be7b1c Add pkg-config support, fixes #187. 2009-10-08 00:20:43 +01:00
Roy Marples
42ca23b878 Don't quote opts 2009-09-21 19:05:47 +01:00
Roy Marples
3dc712e222 Allow init scripts to show their dependencies easier 2009-09-04 16:00:08 +01:00
Roy Marples
44585fea46 Add -P to start-stop-daemon to display a . for each second elapsed.
Fixes #197.
2009-09-04 15:41:08 +01:00
Roy Marples
6e485bde39 Really fix --signal 0 2009-09-04 13:32:59 +01:00
Roy Marples
2ea1df634e Fix signed error. 2009-09-04 13:24:26 +01:00
Roy Marples
7012630302 Allow any valid numeric signal and not just what we define. 2009-09-01 13:57:45 +01:00
Roy Marples
7fbb6ad427 Don't provide ourself, fixes #190 2009-07-20 19:42:15 +01:00
Roy Marples
b4104957b1 We should use -feature instead of nofeature.
This matches the ifconfig and Gentoo USE flag syntax and is hopefully
easier to read.
Fixes #178.
2009-07-01 00:07:32 +01:00
Roy Marples
6abeec7430 Use rc_getline instead of assuming a fixed kernel cmdline length.
This is now requires as COMMAND_LINE_SIZE isn't exposed by kernel
headers anymore.
Fixes #177.
2009-06-21 12:20:53 +01:00
Roy Marples
c3e9a7ec14 Warn about going inactive correctly. 2009-06-01 20:10:42 +01:00
Roy Marples
c0fd1b49e4 Move non compiled libraries from /lib/rc to /libexec/rc
OpenRC version is now stored as plaintext in /libexec/rc/version

Plugins (cursplash, splashutils) will have to be re-compiled to pickup
the new directories. State data needs to be moved from /lib/rc/init.d
to /libexec/rc/init.d as well.
2009-05-23 20:38:12 +01:00
Roy Marples
5294abe617 If already started or stopped, abort. 2009-05-17 12:29:46 +01:00
Roy Marples
b2eb9f8a83 Unset PAM environment variables if not set 2009-05-07 12:20:59 +01:00
Roy Marples
7c81f74b60 Fix compile on NetBSD 2009-05-05 16:39:59 +01:00
Roy Marples
43063ae7c2 Fix compile on NetBSD and FreeBSD 2009-05-05 10:24:21 +01:00
Roy Marples
6615eb4b68 Add runlevel stacking, #88
This implementation has the limitation that you cannot have a stacked
runlevel and service of the same name in a runlevel.
2009-05-02 12:26:45 +01:00
Roy Marples
e040bd77e9 Ignore test results 2009-05-02 12:18:34 +01:00
Roy Marples
658a220638 Add (c) to Copyright 2009-05-01 15:11:40 +01:00
Roy Marples
fb051bf81a Add -i, --ifexists so that we can do this
rc-sercice -i foo -- restart
instead of this
  rc-service -e foo && rc-service foo -- restart
2009-05-01 08:38:57 +01:00
Roy Marples
caf29a6480 Fix git versioning 2009-05-01 00:15:20 +01:00
Roy Marples
f689187966 Add -Z, --dry-run option to show which services we would start/stop
without actually doing so.
Fixes #151.
2009-04-30 23:42:01 +01:00
Roy Marples
3d0e5175d8 Avoid more gcc warning about not checking return values ... 2009-04-30 19:56:43 +01:00
Roy Marples
21e45e895c Brand with git version instead of svn 2009-04-30 19:16:31 +01:00
Juan RP
a1e40e9beb Fix parens 2009-04-30 16:45:18 +01:00
Roy Marples
b70501ef45 Go back to git 2009-04-30 15:05:39 +01:00
Roy Marples
e0f0fc8046 Don't start services when their need dependency is broken 2009-04-28 08:29:02 +00:00
Roy Marples
94b3057571 Add the noshutdown keyword to special case the shutdown. 2009-04-27 12:04:33 +00:00
Roy Marples
338c93733d Fix the nstop keyword. 2009-04-27 09:06:30 +00:00
Roy Marples
eaa32c75c9 Add the nostop keyword so that we don't stop the network init script by default. 2009-04-26 21:16:05 +00:00
Roy Marples
77c8f8abbb Use /bin/bash or user shell in /etc/passwd if none set before /bin/sh. 2009-04-26 17:57:06 +00:00
Roy Marples
0feddbd815 Use kill for the pid check as it's fast. 2009-04-25 20:44:13 +00:00
Roy Marples
c07b384d82 Don't drop to sulogin by default, but make this configurable. 2009-04-24 11:49:55 +00:00
Roy Marples
bd211d534b We should match the full variable name. 2009-04-24 11:45:48 +00:00
Roy Marples
b0ac71fe2a Add missing show levels switch. 2009-04-24 10:23:49 +00:00
Roy Marples
9966a902ab rc-status -c now lists services that have crashed.
It returns 0 if there are crashed services, otherwise 1.
This it easy to restart crashed services automatically.
More for #120.
2009-04-24 10:17:53 +00:00
Roy Marples
5276b13926 Cast to int 2009-04-24 08:32:44 +00:00
Roy Marples
e7b35a8f15 Allow rc to start (optionally stop) crashed services, #120 2009-04-24 07:03:08 +00:00
Roy Marples
e643a7fdd5 Describe interval units 2009-04-24 06:37:29 +00:00
Roy Marples
ade85d4bd8 Improve style for KNF 2009-04-23 21:31:22 +00:00
Roy Marples
6953474655 Style 2009-04-23 20:53:24 +00:00
Roy Marples
7086df5664 Don't include hotplugged services in manual. 2009-04-23 20:27:40 +00:00
Roy Marples
7dc9c39503 Improve the service timeout code and reduce the timeout to 60 seconds.
Don't process any dependencies when changing runlevels and called 
outside of RC otherwise we can deadlock.
2009-04-23 20:20:17 +00:00
Roy Marples
f326f688f6 Add the -i, --interpreted option.
This enables the code to include the daemons interpreter when matching
process name which fixes bug #164.
Existing init scripts that rely on the old behaviour will need to be 
fixed.
2009-04-22 10:45:01 +00:00
Roy Marples
ee53e6ad29 -w, --wait seconds
New option so you can set the number of seconds to wait for and
check the daemon is still running.
The old code that periodically polled wasn't that reliable - in this 
case simpler == better.
Fixes #160
2009-04-19 18:20:49 +00:00
Roy Marples
3579663173 Don't leak the lock fd. 2009-04-18 19:54:04 +00:00
Roy Marples
657cb3a6eb Fix compile on FreeBSD. 2009-04-18 00:57:17 +00:00
Roy Marples
c9e24a0494 Move status to runscript.sh so init scripts can override it, #159
Return 32 if crashed, #163
2009-04-18 00:09:03 +00:00
Roy Marples
ee54bb9372 Using fifos for locking can be error prone.
flocks are safer, as we only use tmpfs for our lock files.

I don't know how this works for inactive just yet though ...
2009-04-17 22:55:11 +00:00
Roy Marples
dea9e11a69 When logging, stdout isn't always a tty, which is the case for VPS
systems, Thanks to mwrobel - fixes #106.
2009-04-02 23:55:19 +00:00
Roy Marples
077b2d3ba8 Report if service is not executable. 2009-02-28 14:12:19 +00:00
Roy Marples
907ca8a89f Set errno when service does not exist better. 2009-02-28 14:12:03 +00:00
Roy Marples
f38ef00939 Fix unit test. 2009-02-23 10:43:24 +00:00
Roy Marples
749938d439 Style. 2009-02-23 09:35:57 +00:00