Commit Graph

1067 Commits

Author SHA1 Message Date
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