Compare commits

..

47 Commits

Author SHA1 Message Date
Daniel Robbins
7146e99855 Revert "Unprivileged users (such as services for example) should not be able view who is logged into system."
This reverts commit 62bd337494.

It's a bit too restrictive for a default install, as it also prevents "who" from working on user accounts.
2011-06-20 22:14:53 -06:00
Daniel Robbins
e65ce9e301 Merge remote-tracking branch 'gentoo/master' 2011-06-04 17:04:04 -06:00
Mike Frysinger
7ca74d7636 fix underquoting of wrapped color stubs of exit status
X-Gentoo-Bug: 369911
X-Gentoo-Bug-URL: http://bugs.gentoo.org/369911
Reported-by: Steve Dibb <beandog@gentoo.org>
Reported-by: Christian Ruppert <idl0r@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-06-03 20:41:43 -04: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
Diego Elio Pettenò
a2c8e5ce50 Don't set hostname on containers.
LXC already provides a means to set the utsname/hostname of the system, so
avoid overriding the user's configuration through hostname here.

Signed-off-by: Diego Elio Pettenò <flameeyes@gmail.com>
2011-06-02 11:34:13 -05: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
98d3b407fe cc.mk: enable -g by default
Can do no harm!

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-28 12:00:13 -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
William Hubbs
74c8667497 fix keymaps config file to show the correct variable name
X-Gentoo-Bug: 367283
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=367283
2011-05-17 13:06:55 -05:00
Mike Frysinger
3d56124ed1 only warn about /run if it exists
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-16 18:49:21 -04:00
Mike Frysinger
bb34ea886a drop rc_sys funcs from removal schedule
The automagic detection isn't really problematic, and we allow people to
easily override this when detection isn't possible.  On the other hand,
if people haven't configured rc_sys in their rc.conf, the lack of auto
detection can easily lead to an unbootable system.

Further, we're attempting to have a stable shared library ABI, which
dropping funcs from is not feasible.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-16 18:00:18 -04:00
William Hubbs
fd48bc09ff net:bonding small style change for readability 2011-05-16 14:57:46 -05:00
Kfir Lavi
db1daa5857 Do not add slaves to bond interface if they are already added
X-Gentoo-Bug: 366653
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=366653
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2011-05-16 09:21:18 -04:00
Mike Frysinger
2493a1f32e net: ccwgroup: forward port changes from baselayout-1
Quite a bit of work happened in baselayout-1 on the ccwgroup module, but
seems it didn't make it into openrc.  So forward port all the existing
code so we can work with more than just qeth and layer2 options.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-05-16 01:22:32 -04:00
William Hubbs
40341fcd7e do not run services if openrc did not boot the system
X-Gentoo-Bug: 364159
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=364159
2011-05-11 14:54:41 -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
b712a9161f change udhcpc support to busybox udhcpc
This updates the udhcpc support to use busybox's udhcpc instead of the
stand alone version.

I would like to thank jackieku <kjackie@gmail.com> for assisting with
this update.

X-Gentoo-Bug: 205286
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=205286
2011-04-26 15:25:08 -05:00
William Hubbs
8202e7dce4 add back the eend command in start/stop for local service
This was added back due to a user request. It will always be on a line
of its ownbecause I'm considering adding more verbose info messages to
local that show when each service is run if local is run with the -v
option.

X-Gentoo-Bug: 363343
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=363343
2011-04-21 13:02:49 -05:00
Robin H. Johnson
2d197357ef [oldnet] Bug #363959: Improve plug_timeout ifplugd/netplugd code.
- Add support for a global plug_timeout setting to match the
  documentation.
- Update the documentation to also show per-interface configuration.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
2011-04-19 17:49:20 +00:00
William Hubbs
b6409feaac fix permissions for /run/lock
If /run/lock is a directory, set the ownership and permissions for it,
whether or not we created the directory.
2011-04-19 10:56:14 -05:00
Lars Wendler
ede4d1cd60 Don't unmount /run on shutdown
This is needed so that udev will stop properly on shutdown.

X-Gentoo-Bug: 363971
X-Gentoo-Bug-Url: http://bugs.gentoo.org/show_bug.cgi?id=363971
2011-04-18 15:26:19 -05:00
Amadeusz Żołnowski
64ef51ab09 Add support for /run directory
This is a new directory for storing volatile runtime data.
See https://lwn.net/Articles/436012

X-Gentoo-Bug: 363971
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=363971
2011-04-18 15:26:13 -05:00
William Hubbs
372bae3213 make rc_sys system specific
This rearranges the configuration files so it is more clear that the
rc_sys setting is system specific.

X-Gentoo-Bug: 363957
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=363957
2011-04-18 14:42:02 -05:00
Anthony G. Basile
ac56ab7f6d Check for /sys/module/usbcore before modprobe usbcore
The use of /proc/bus/usb to mount usbfs has been deprecated, but
the option is still available in the kernel.  The new approach is
to use /sys.  We should not modprobe usbcore if either /proc/bus/usb
or /sys/module/usbcore exist.

X-Gentoo-Bug: 363551
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=363551
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2011-04-17 09:12:20 -04:00
Daniel Robbins
6a5e6f1ee0 openrc-0.7.0 upstream merge 2011-01-20 14:00:29 -07:00
Piotr Karbowski
d8ce5dccb2 openrc-0.6.8 2010-12-16 11:17:34 +01:00
Piotr Karbowski
62bd337494 Unprivileged users (such as services for example) should not be able view who is logged into system. 2010-12-16 10:04:46 +01:00
Jory A. Pratt
06c8bd0156 Fix for make-3.82 breakage. 2010-12-03 20:06:34 -07:00
Daniel Robbins
33803219d4 openrc-0.6.5 2010-11-26 17:02:16 -07:00
Jory A. Pratt
18c08a9d4d remove 'use hostname' bug 340991, Thanks Diego 2010-11-26 16:59:28 -07:00
William Hubbs
2406dc4f3e allow net_fs_list to be extended but not replaced
This fixes bug #342825.
2010-11-26 16:59:18 -07:00
Diego Elio Pettenò
8e6d461a7f Allow cleaning up of pam_mktemp-based temporary directories.
This was blacklisted before, so the .private directories never had their
content cleaned up, even if WIPE_TMP was set to yes.
2010-11-26 16:57:37 -07:00
William Hubbs
472a3bb99c remove support for local.start and local.stop for bug #343709
The openrc ebuild now migrates these files to /etc/conf.d/local, so we
do not need to support them.
2010-11-26 16:53:54 -07:00
William Hubbs
c9a2085699 add warnings about local.start and local.stop for bug #343709
We need to warn users that they should be using /etc/conf.d/local
instead of /etc/conf.d/local.start and /etc/conf.d/local.stop. This adds
those warnings.
2010-11-26 16:53:50 -07:00
William Hubbs
69169b7e95 update documentation for rc_interactive
rc_interactive is automatically disabled if rc_parallel is set to YES.
Update the documentation in rc.conf to reflect this.
This fixes bug #327305.
2010-11-26 16:53:37 -07:00
William Hubbs
3a11f8af34 remove "use hostname" from sysctl for bsd systems 2010-11-26 16:51:42 -07:00
William Hubbs
e2e5b27d85 do not mount local file systems with the _netdev option in fstab
This fixes #344947.
2010-11-26 16:51:20 -07:00
Daniel Robbins
f343360741 0.6.4 release 2010-10-27 23:43:30 -06:00
Brant Gurganus
694fd2027f correction for unmounting volumes with weird characters 2010-10-24 13:08:38 -04:00
Daniel Robbins
ca76764743 Merge branch 'master' of github.com:funtoo/openrc 2010-10-20 19:21:48 -06:00
Jory A. Pratt
19bd9923d7 surpress output of loadkeys, fix setfont path check 2010-10-20 19:21:02 -06:00
Brant Gurganus
2a844e1122 corrected a typo 2010-10-20 16:26:01 -04:00
Daniel Robbins
5135412978 fixing history, one step at a time 2010-08-16 19:09:26 -06:00
37 changed files with 364 additions and 175 deletions

15
.gitignore vendored
View File

@@ -1 +1,16 @@
*.bz2
*.diff
*.patch
*.orig
*.rej
core
.gdb_history
.gdbinit
.depend
*.a
*.o
*.So
lib*.so

View File

@@ -5,27 +5,6 @@ removed, it should also be removed from this file.
---------------------------
What: rc_sys automatic detection code
- Functions for removal: rc_sys_v1, rc_sys_v2
When: 2011/03/01
Why: The original automatic sub-system detection is flawed in that it cannot
safely detect some variables (Using cgroups confused it to think you were
using LXC, and Prefix cannot be detect by definition). Also, almost all of
the detection requires that /proc is available and readable. During early
boot, /proc may not be mounted yet, leading to mis-detection. The readable
condition can also fail under some hardened kernels when running as an
unprivileged user.
The new rc_sys_v2 function uses the rc_sys variable from rc.conf. After
the removal, the contents of the rc_sys_v2 function will move into the
rc_sys function.
Who: Robin H. Johnson <robbat2@gentoo.org>
---------------------------
What: oldnet ADSL rp-pppoe mode
When: undecided

72
README
View File

@@ -1,8 +1,9 @@
OpenRC README
=============
Installation
------------
make install
Yup, that simple. Works with GNU make.
@@ -67,31 +68,54 @@ init.d.misc is not installed by default as the scripts will need
tweaking on a per distro basis. They are also non essential to the operation
of the system.
Reporting Bugs
--------------
Bugs should go to the Gentoo Bugzilla:
http://bugs.gentoo.org/
You'll want the "Gentoo Linux" product and the "baselayout" component.
If you installed OpenRC from your chosen distribution, you should report
bugs directly to them. For example, if you use Gentoo and emerged OpenRC
then you should reports bugs to http://bugs.gentoo.org.
History - by Roy Marples
------------------------
I became a Gentoo/Linux developer in 2004 and wrote the modular network
scripts for the Gentoo baselayout package. baselayout is a collection of
bash scripts to bring up your computer and its services.
Then towards the end of 2005 I found myself as the primary maintainer
for baselayout.
History - by Daniel Robbins
---------------------------
At the start of 2007, baselayout-2 is announced to the world, re-writing the
core of baselayout in C and allowing POSIX sh init scripts instead of
forcing the use of bash. By Mid 2007 I have re-written everything, including
init scripts, and alpha and pre baselayout-2 snapshots where put into Gentoo.
Towards the end of 2007 I retired as a Gentoo developer for reasons I won't
go into here. baselayout-2 was still in the pre stage, and aside from the
fbsd users, it was masked everywhere. However, I also desired to keep the
baselayout-2 project alive, but outside of Gentoo and into other projects
such as FreeBSD.
The Gentoo modular network scripts were created by Daniel Robbins for
Gentoo Linux 1.0_rc6, in development during most of 2001 and released
in September 2001. After their development, the dependency-based initscript
system was maintained by a number of senior developers (add names here....
need to look at baselayout cvs logs.)
As such, the Gentoo Council have allowed the creation of OpenRC under the
2 clause BSD license, managed by me as an external project.
excerpt from http://www.gentoo.org/news/en/gwn/20040426-newsletter.xml
by Grant Goodyear:
"My recollection is that one of woodchip's more impressive early feats was the
complete replacement of all of the init scripts in Portage for Gentoo Linux
1.0_rc6. Through 1.0_rc5 Gentoo had used fairly standard rc scripts modified
from Stampede Linux, but for 1.0_rc6 Daniel Robbins (drobbins) and Martin
Schlemmer (azarah) had created a new dependency-based init script system that
is still used today. Within a span of days Donny rewrote every single init
script in the Portage tree and committed new masked packages to await the
release of 1.0_rc6. Thanks to woodchip (and drobbins and azarah, of course) the
transition to the new init scripts was nearly painless."
Roy Marples became a Gentoo/Linux developer in 2004 and maintained the modular
network scripts for the Gentoo baselayout package. Then towards the end of
2005, he became the the primary maintainer for baselayout.
At the start of 2007, Roy Marples announced the ongoing development of
baselayout-2, containing a rewritten initscript code in C and allowing POSIX sh
init scripts instead of forcing the use of bash. By Mid 2007 Roy Marples had
re-implemented the Gentoo initscript design created by Daniel Robbins, using an
entirely new code base. Alpha and pre-release baselayout-2 snapshots were
added to Gentoo's Portage tree as an optional component.
Towards the end of 2007, Roy Marples retired as a Gentoo developer Baselayout-2
was still in the pre stage, and aside from the fbsd users, it was masked
everywhere. However, Roy Marples desired to keep the baselayout-2 project
alive, but outside of Gentoo and into other projects such as FreeBSD.
As such, the Gentoo Council permitted Roy Marples to release OpenRC under the 2
clause BSD license, managed by him as an external project. Around mid-2010, Roy
Marples decided to no longer maintain OpenRC. At this point, he transferred
development back to Gentoo, which continues to maintain the scripts. In
addition, Daniel Robbins continues to maintain an independent version OpenRC
for Funtoo Linux, which includes a Funtoo-specific network configuration
system.

View File

@@ -1,4 +1,4 @@
# Use KEYMAP to specify the default console keymap. There is a complete tree
# Use keymap to specify the default console keymap. There is a complete tree
# of keymaps in /usr/share/keymaps to choose from.
keymap="us"

View File

@@ -414,7 +414,7 @@
# dhclient: emerge net-misc/dhcp
# dhcpcd: emerge net-misc/dhcpcd
# pump: emerge net-misc/pump
# udhcpc: emerge net-misc/udhcp
# udhcpc: emerge sys-apps/busybox
# If you have more than one DHCP client installed, you need to specify which
# one to use - otherwise we default to dhcpcd if available.
@@ -975,10 +975,12 @@
# and you're done :)
# By default we don't wait for netplug/ifplugd to configure the interface.
# If you would like it to wait so that other services know that network is up
# then you can specify a timeout here.
# If you would like it to wait so that other services know that network is
# up then you can specify a timeout here. A value of 0 means wait forever,
# and a negative value means never wait.
#plug_timeout_eth0="10"
# If you want to set it for all interfaces:
#plug_timeout="10"
# A value of 0 means wait forever.
# If you don't want to use netplug on a specific interface but you have it
# installed, you can disable it for that interface via the modules statement

View File

@@ -1,3 +1,6 @@
##############################################################################
# FreeBSD SPECIFIC OPTIONS
# This is the subsystem type. Valid options on FreeBSD:
# "" - nothing special
# "jail" - FreeBSD jails

View File

@@ -1,3 +1,6 @@
##############################################################################
# LINUX SPECIFIC OPTIONS
# This is the subsystem type. Valid options on Linux:
# "" - nothing special
# "lxc" - Linux Containers
@@ -15,9 +18,6 @@
# PRESENTLY in, not the virtualization the environment is capable of.
rc_sys="@RC_SYS_DEFAULT@"
##############################################################################
# LINUX SPECIFIC OPTIONS
# This is the number of tty's used in most of the rc-scripts (like
# consolefont, numlock, etc ...)
rc_tty_number=12

View File

@@ -1,3 +1,6 @@
##############################################################################
# NetBSD SPECIFIC OPTIONS
# This is the subsystem type. Valid options on NetBSD:
# "" - nothing special
# "prefix" - Prefix

View File

@@ -5,7 +5,7 @@
description="Sets the hostname of the machine."
depend() {
keyword -prefix
keyword -prefix -lxc
}
start()

View File

@@ -27,7 +27,7 @@ start()
local_start
fi
return 0
eend 0
}
stop()
@@ -47,5 +47,5 @@ stop()
local_stop
fi
return 0
eend 0
}

View File

@@ -49,7 +49,7 @@ stop()
fi
if [ "$RC_UNAME" = Linux ]; then
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/sys|/sys/.*"
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
fi
no_umounts_r="^($no_umounts_r)$"

View File

@@ -14,7 +14,7 @@ depend()
start()
{
# Make sure we insert usbcore if it's a module
if [ -f /proc/modules -a ! -d /proc/bus/usb ]; then
if [ -f /proc/modules -a ! -d /sys/module/usbcore -a ! -d /proc/bus/usb ]; then
modprobe -q usbcore
fi

View File

@@ -1,7 +1,7 @@
# Copyright (c) 2008 Roy Marples <roy@marples.name>
# Setup some good default CFLAGS
CFLAGS?= -O2
CFLAGS?= -O2 -g
# Default to using the C99 standard
CSTD?= c99
@@ -31,3 +31,5 @@ _CC_FLAGS_SH= for f in ${_CCFLAGS}; do \
done;
_CC_FLAGS:= $(shell ${_CC_FLAGS_SH})
CFLAGS+= ${_CC_FLAGS}
include ${MK}/debug.mk

View File

@@ -97,13 +97,16 @@ bonding_pre_start()
# finally add in slaves
eoutdent
if [ -d /sys/class/net ]; then
sys_bonding_path=/sys/class/net/"${IFACE}"/bonding
if [ -n "${primary}" ]; then
echo "+${primary}" >/sys/class/net/"${IFACE}"/bonding/slaves
echo "${primary}" >/sys/class/net/"${IFACE}"/bonding/primary
echo "+${primary}" >$sys_bonding_path/slaves
echo "${primary}" >$sys_bonding_path/primary
fi
for s in ${slaves}; do
[ "${s}" = "${primary}" ] && continue
echo "+${s}" >/sys/class/net/"${IFACE}"/bonding/slaves
if ! grep -q ${s} $sys_bonding_path/slaves; then
echo "+${s}" >$sys_bonding_path/slaves
fi
done
else
/sbin/ifenslave "${IFACE}" ${slaves} >/dev/null

View File

@@ -8,60 +8,89 @@ ccwgroup_depend()
before interface
}
ccwgroup_pre_start()
ccwgroup_load_modules()
{
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
[ -z "${ccwgroup}" ] && return 0
if [ ! -d /sys/bus/ccwgroup ]; then
modprobe qeth
if [ ! -d /sys/bus/ccwgroup ]; then
# make sure we have ccwgroup support or this is a crap shoot
if [ ! -d /sys/bus/ccwgroup ] ; then
modprobe -q ccwgroup
if [ ! -d /sys/bus/ccwgroup ] ; then
eerror "ccwgroup support missing in kernel"
return 1
fi
fi
einfo "Enabling ccwgroup on ${IFACE}"
local x= ccw= first= layer2=
for x in ${ccwgroup}; do
[ -z "${first}" ] && first=${x}
ccw="${ccw}${ccw:+,}${x}"
done
if [ -e /sys/devices/qeth/"${first}" ]; then
echo "0" >/sys/devices/qeth/"${first}"/online
else
echo "${ccw}" >/sys/bus/ccwgroup/drivers/qeth/group
# verify the specific interface is supported
if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
modprobe $1 >& /dev/null
if [ ! -d /sys/bus/ccwgroup/drivers/$1 ] ; then
eerror "$1 support missing in kernel"
return 1
fi
fi
eval layer2=\$qeth_layer2_${IFVAR}
echo "${layer2:-0}" > /sys/devices/qeth/"${first}"/layer2
echo "1" >/sys/devices/qeth/"${first}"/online
return 0
}
ccwgroup_pre_start()
{
local ccwgroup="$(_get_array "ccwgroup_${IFVAR}")"
[ -z "${ccwgroup}" ] && return 0
local ccw_type
eval ccw_type=\${ccwgroup_type_${IFVAR}:-qeth}
ccwgroup_load_modules ${ccw_type} || return 1
einfo "Enabling ccwgroup/${ccw_type} on ${IFACE}"
set -- ${ccwgroup}
local first=$1; shift
if [ -e /sys/devices/${ccw_type}/${first}/online ]; then
echo "0" >/sys/devices/${ccw_type}/${first}/online
else
echo "${first}$(printf ',%s' "$@")" >/sys/bus/ccwgroup/drivers/${ccw_type}/group
fi
local var val
for var in $(_get_array "ccwgroup_opts_${IFVAR}") online=1 ; do
val=${var#*=}
var=${var%%=*}
echo "${val}" > /sys/devices/${ccw_type}/${first}/${var}
done
eend $?
}
ccwgroup_pre_stop()
{
local path="/sys/class/net/${IFACE}"
# Erase any existing ccwgroup to be safe
service_set_value ccwgroup_device ""
service_set_value ccwgroup_type ""
[ ! -L /sys/class/net/"${FACE}"/driver ] && return 0
local driver="$(readlink /sys/class/net/"${IFACE}"/driver)"
case "${diver}" in
*/bus/ccwgroup/*);;
[ ! -L "${path}"/device/driver ] && return 0
case "$(readlink "${path}"/device/driver)" in
*/bus/ccwgroup/*) ;;
*) return 0;;
esac
local device="$(readlink /sys/class/net/"${IFACE}"/device)"
local device
device="$(readlink "${path}"/device)"
device=${device##*/}
service_set_value ccwgroup_device "${device}"
device="$(readlink "${path}"/device/driver)"
device=${device##*/}
service_set_value ccwgroup_type "${device}"
}
ccwgroup_post_stop()
{
local device="$(service_get_value ccwgroup_device)"
[ -z "${device}" ] && return 0
local ccw_type="$(service_get_value ccwgroup_type)"
einfo "Disabling ccwgroup on ${iface}"
echo "0" >/sys/devices/qeth/"${device}"/online
echo "1" >/sys/devices/qeth/"${device}"/ungroup
einfo "Disabling ccwgroup/${ccw_type} on ${IFACE}"
echo "0" >/sys/devices/${ccw_type}/"${device}"/online
echo "1" >/sys/devices/${ccw_type}/"${device}"/ungroup
eend $?
}

View File

@@ -51,7 +51,9 @@ ifplugd_pre_start()
eindent
# IFACE-specific, then global, then default
eval timeout=\$plug_timeout_${IFVAR}
[ -z "${timeout}" ] && timeout=$plug_timeout
[ -z "${timeout}" ] && timeout=-1
if [ ${timeout} -eq 0 ]; then
ewarn "WARNING: infinite timeout set for ${IFACE} to come up"

View File

@@ -53,7 +53,9 @@ netplugd_pre_start()
eindent
# IFACE-specific, then global, then default
eval timeout=\$plug_timeout_${IFVAR}
[ -z "${timeout}" ] && timeout=$plug_timeout
[ -z "${timeout}" ] && timeout=-1
if [ ${timeout} -eq 0 ]; then
ewarn "WARNING: infinite timeout set for ${IFACE} to come up"

View File

@@ -3,14 +3,13 @@
udhcpc_depend()
{
program start /sbin/udhcpc
program start /bin/busybox
after interface
provide dhcp
}
_config_vars="$_config_vars dhcp udhcpc"
# WARNING:- The relies heavily on Gentoo patches and scripts for udhcpc
udhcpc_start()
{
local args= opt= opts= pidfile="/var/run/udhcpc-${IFACE}.pid"
@@ -22,17 +21,22 @@ udhcpc_start()
eval opts=\$dhcp_${IFVAR}
[ -z "${opts}" ] && opts=${dhcp}
# This omits the Gentoo specific patch to busybox,
# but it creates temporary files.
# We can move this stuff to udhcpc hook script to avoid that, should we do?
local conf="/var/run/udhcpc-${IFACE}.conf"
echo -n >"$conf"
# Map some generic options to dhcpcd
for opt in ${opts}; do
case "${opt}" in
nodns) args="${args} --env PEER_DNS=no";;
nontp) args="${args} --env PEER_NTP=no";;
nogateway) args="${args} --env PEER_ROUTERS=no";;
nodns) echo "PEER_DNS=no" >>"$conf" ;;
nontp) echo "PEER_NTP=no" >>"$conf" ;;
nogateway) echo "PEER_ROUTERS=no" >>"$conf" ;;
nosendhost) sendhost=false;
esac
done
[ "${metric:-0}" != "0" ] && args="${args} --env IF_METRIC=${metric}"
[ "${metric:-0}" != "0" ] && echo "IF_METRIC=${metric}" >>"$conf"
ebegin "Running udhcpc"
@@ -51,9 +55,9 @@ udhcpc_start()
fi
case " ${args} " in
*" --quit "*|*" -q "*) x="/sbin/udhcpc";;
*) x="start-stop-daemon --start --exec /sbin/udhcpc \
--pidfile \"${pidfile}\" --";;
*" --quit "*|*" -q "*) x="/bin/busybox udhcpc";;
*) x="start-stop-daemon --start --exec /bin/busybox \
--pidfile \"${pidfile}\" -- udhcpc";;
esac
case " ${args} " in
@@ -68,11 +72,8 @@ udhcpc_start()
;;
esac
local script="${RC_LIBEXECDIR}"/sh/udhcpc.h
[ -x "${script}" ] || script=/lib/rcscripts/sh/udhcpc.sh
eval "${x}" "${args}" --interface="${IFACE}" --now \
--script="${script}" \
--script="${RC_LIBEXECDIR}/sh/udhcpc-hook.sh" \
--pidfile="${pidfile}" >/dev/null
eend $? || return 1
@@ -92,14 +93,18 @@ udhcpc_stop()
ebegin "Stopping udhcpc on ${IFACE}"
case " ${opts} " in
*" release "*)
start-stop-daemon --stop --quiet --oknodo --signal USR2 \
--exec /sbin/udhcpc --pidfile "${pidfile}"
start-stop-daemon --stop --quiet --signal USR2 \
--exec /bin/busybox --pidfile "${pidfile}"
if [ -f /var/cache/udhcpc-"${IFACE}".lease ]; then
rm -f /var/cache/udhcpc-"${IFACE}".lease
fi
;;
esac
start-stop-daemon --stop --exec /sbin/udhcpc --pidfile "${pidfile}"
start-stop-daemon --stop --exec /bin/busybox --pidfile "${pidfile}"
eend $?
if [ -e "/var/run/udhcpc-${IFACE}.conf" ]; then
rm -f "/var/run/udhcpc-${IFACE}.conf"
fi
}

1
sh/.gitignore vendored
View File

@@ -7,3 +7,4 @@ init.sh
init-early.sh
ifwatchd-carrier.sh
ifwatchd-nocarrier.sh
udhcpc-hook.sh

View File

@@ -1,5 +1,5 @@
SRCS+= init.sh.in init-early.sh.in
BIN+= init-early.sh
SRCS+= init.sh.in init-early.sh.in udhcpc-hook.sh.in
BIN+= init-early.sh udhcpc-hook.sh
.SUFFIXES: .sh.Linux.in
.sh.Linux.in.sh:

View File

@@ -104,7 +104,7 @@ else
# the last ecmd
for _e in ebegin eend error errorn einfo einfon ewarn ewarnn ewend \
vebegin veend veinfo vewarn vewend; do
eval "$_e() { local _r; @LIBEXECDIR@/bin/$_e \"\$@\"; _r=$?; \
eval "$_e() { local _r; @LIBEXECDIR@/bin/$_e \"\$@\"; _r=\$?; \
export EINFO_LASTCMD=$_e; return \$_r; }"
done
unset _e

View File

@@ -91,6 +91,30 @@ if $mountproc; then
eend $?
fi
# Mount tmpfs on /run when directory exists.
# /run is a new directory for storing volatile runtime data.
# Read more about /run at https://lwn.net/Articles/436012
if [ -d /run ]; then
if mountinfo -q /run; then
einfo "/run is already mounted, skipping"
else
ebegin "Mounting /run"
if ! fstabinfo --mount /run; then
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run
fi
eend $?
fi
if [ ! -d /run/lock ]; then
mkdir /run/lock
fi
if [ -d /run/lock ]; then
chown root:uucp /run/lock
chmod 0775 /run/lock
fi
elif [ -e /run ]; then
einfo "Unable to mount /run since it is not a directory"
fi
# Try to mount xenfs as early as possible, otherwise rc_sys() will always
# return RC_SYS_XENU and will think that we are in a domU while it's not.
if grep -Eq "[[:space:]]+xenfs$" /proc/filesystems; then

View File

@@ -16,6 +16,18 @@ sourcex()
fi
}
if [ ! -e ${RC_SVCDIR}/softlevel ]; then
eerror "You are attempting to run an openrc service on a"
eerror "system which openrc did not boot."
eerror "You may be inside a chroot or you may have used"
eerror "another initialization system to boot this system."
eerror "In this situation, you will get unpredictable results!"
eerror
eerror "If you really want to do this, issue the following command:"
eerror "touch ${RC_SVCDIR}/softlevel"
exit 1
fi
sourcex "@SYSCONFDIR@/init.d/functions.sh"
sourcex "@LIBEXECDIR@/sh/rc-functions.sh"

117
sh/udhcpc-hook.sh.in Normal file
View File

@@ -0,0 +1,117 @@
#!@SHELL@
# busybox udhcp setup script
PATH=/bin:/usr/bin:/sbin:/usr/sbin
peer_var()
{
[ -n "$1" ] && [ "$1" != "yes" ]
}
update_dns()
{
peer_var "${PEER_DNS}" && return
[ -z "${domain}" ] && [ -z "${dns}" ] && return
conf="# Generated by udhcpc for ${interface}\n"
[ -n "${domain}" ] && conf="${conf}search ${domain}\n"
for i in ${dns} ; do
conf="${conf}nameserver ${i}\n"
done
if [ -x /sbin/resolvconf ] ; then
printf "${conf}" | resolvconf -a ${interface}
else
printf "${conf}" > /etc/resolv.conf
chmod 644 /etc/resolv.conf
fi
}
update_ntp()
{
peer_var "${PEER_NTP}" && return
[ -z "${ntpsrv}" ] && return
conf="# Generated by udhcpc for interface ${interface}\n"
conf="${conf}restrict default noquery notrust nomodify\n"
conf="${conf}restrict 127.0.0.1\n"
for i in ${ntpsrv} ; do
conf="${conf}restrict ${i} nomodify notrap noquery\n"
conf="${conf}server ${i}\n"
done
conf="${conf}driftfile /var/lib/ntp/ntp.drift\n"
conf="${conf}logfile /var/log/ntp.log\n"
printf "${conf}" > /etc/ntp.conf
chmod 644 /etc/ntp.conf
}
update_hostname()
{
peer_var "${PEER_HOSTNAME}" && return
[ -z "${hostname}" ] && return
myhost="$(hostname)"
[ -z "${myhost}" ] || [ "${myhost}" = "(none)" ] && hostname "${hostname}"
}
update_interface()
{
[ -n "${broadcast}" ] && broadcast="broadcast ${broadcast}"
[ -n "${subnet}" ] && netmask="netmask ${subnet}"
[ -n "${mtu}" ] && mtu="mtu ${mtu}"
ifconfig "${interface}" ${ip} ${broadcast} ${netmask} ${mtu}
}
update_routes()
{
peer_var "${PEER_ROUTERS}" && return
if [ -n "${router}" ] ; then
metric=
[ -n "${IF_METRIC}" ] && metric="metric ${IF_METRIC}"
for i in ${router} ; do
route add default gw "${i}" ${metric} dev "${interface}"
done
fi
}
deconfig()
{
ifconfig "${interface}" 0.0.0.0
if ! peer_var "${PEER_ROUTERS}" ; then
while route del default dev "${interface}" >& /dev/null; do
:
done
fi
if ! peer_var "${PEER_DNS}" ; then
[ -x /sbin/resolvconf ] && resolvconf -d "${interface}"
fi
}
if [ -r "/var/run/udhcpc-${interface}.conf" ]; then
. "/var/run/udhcpc-${interface}.conf"
fi
case "$1" in
bound|renew)
update_hostname
update_interface
update_routes
update_dns
update_ntp
;;
deconfig|leasefail)
deconfig
;;
nak)
echo "nak: ${message}"
;;
*)
echo "unknown option $1" >&2
echo "Usage: $0 {bound|deconfig|leasefail|nak|renew}" >&2
exit 1
;;
esac
exit 0

View File

@@ -1,7 +1 @@
.depend
libeinfo.o
libeinfo.So
libeinfo.a
libeinfo.so.1
libeinfo.so
.depend

View File

@@ -9,5 +9,4 @@ CPPFLAGS+= -I../includes
MK= ../../mk
include ${MK}/lib.mk
include ${MK}/cc.mk
include ${MK}/debug.mk
include ${MK}/termcap.mk

14
src/librc/.gitignore vendored
View File

@@ -1,16 +1,2 @@
.depend
librc.o
librc-daemon.o
librc-depend.o
librc-misc.o
librc-stringlist.o
librc.So
librc-daemon.So
librc-depend.So
librc-misc.So
librc-stringlist.So
librc.a
librc.so.1
librc.so
.depend
rc.h

View File

@@ -12,7 +12,6 @@ CPPFLAGS+= -I../includes
MK= ../../mk
include ${MK}/lib.mk
include ${MK}/cc.mk
include ${MK}/debug.mk
# Massage our header file for our dirs
SED_CMD= -e 's:@PREFIX@:${PREFIX}:g'

View File

@@ -308,10 +308,10 @@ _match_list(const char *exec, const char *const *argv, const char *pidfile)
if (pidfile) {
l = strlen(pidfile) + 9;
m = xmalloc(sizeof (char) * l);
m = xmalloc(sizeof(char) * l);
snprintf(m, l, "pidfile=%s", pidfile);
rc_stringlist_add(match, m);
free (m);
free(m);
}
return match;
@@ -508,7 +508,7 @@ rc_service_daemons_crashed(const char *service)
if ((fp = fopen(pidfile, "r"))) {
if (fscanf(fp, "%d", &pid) == 1)
retval = false;
fclose (fp);
fclose(fp);
}
free(pidfile);
pidfile = NULL;

View File

@@ -144,7 +144,7 @@ rc_deptree_load_file(const char *deptree_file)
e = strsep(&p, "_");
if (!e || strcmp(e, "depinfo") != 0)
continue;
e = strsep (&p, "_");
e = strsep(&p, "_");
if (!e || sscanf(e, "%d", &i) != 1)
continue;
if (!(type = strsep(&p, "_=")))
@@ -425,8 +425,8 @@ visit_service(const RC_DEPTREE *deptree,
continue;
provided = get_provided(di, runlevel, options);
TAILQ_FOREACH(p, provided, entries)
if (strcmp (p->value, depinfo->service) == 0) {
visit_service (deptree, types, sorted, visited, di,
if (strcmp(p->value, depinfo->service) == 0) {
visit_service(deptree, types, sorted, visited, di,
runlevel, options | RC_DEP_TRACE);
break;
}
@@ -681,7 +681,7 @@ rc_deptree_update_needed(time_t *newest, char *file)
/* Create base directories if needed */
for (i = 0; depdirs[i]; i++)
if (mkdir(depdirs[i], 0755) != 0 && errno != EEXIST)
fprintf(stderr, "mkdir `%s': %s\n", depdirs[i], strerror (errno));
fprintf(stderr, "mkdir `%s': %s\n", depdirs[i], strerror(errno));
/* Quick test to see if anything we use has changed and we have
* data in our deptree */
@@ -922,7 +922,7 @@ rc_deptree_update(void)
di = get_depinfo(deptree, s->value);
if (!di) {
if (strcmp(deptype->type, "ineed") == 0) {
fprintf (stderr,
fprintf(stderr,
"Service `%s' needs non"
" existent service `%s'\n",
depinfo->service, s->value);
@@ -1032,7 +1032,7 @@ rc_deptree_update(void)
if (TAILQ_FIRST(config)) {
if ((fp = fopen(RC_DEPCONFIG, "w"))) {
TAILQ_FOREACH(s, config, entries)
fprintf (fp, "%s\n", s->value);
fprintf(fp, "%s\n", s->value);
fclose(fp);
} else {
fprintf(stderr, "fopen `%s': %s\n",

View File

@@ -41,7 +41,7 @@ rc_stringlist_new(void)
librc_hidden_def(rc_stringlist_new)
RC_STRING *
rc_stringlist_add (RC_STRINGLIST *list, const char *value)
rc_stringlist_add(RC_STRINGLIST *list, const char *value)
{
RC_STRING *s = xmalloc(sizeof(*s));
@@ -52,7 +52,7 @@ rc_stringlist_add (RC_STRINGLIST *list, const char *value)
librc_hidden_def(rc_stringlist_add)
RC_STRING *
rc_stringlist_addu (RC_STRINGLIST *list, const char *value)
rc_stringlist_addu(RC_STRINGLIST *list, const char *value)
{
RC_STRING *s;
@@ -74,8 +74,8 @@ rc_stringlist_delete(RC_STRINGLIST *list, const char *value)
TAILQ_FOREACH(s, list, entries)
if (strcmp(s->value, value) == 0) {
TAILQ_REMOVE(list, s, entries);
free (s->value);
free (s);
free(s->value);
free(s);
return true;
}
@@ -127,7 +127,7 @@ rc_stringlist_sort(RC_STRINGLIST **list)
TAILQ_REMOVE(l, s, entries);
last = NULL;
TAILQ_FOREACH(n, new, entries) {
if (strcmp (s->value, n->value) < 0)
if (strcmp(s->value, n->value) < 0)
break;
last = n;
}

View File

@@ -525,7 +525,7 @@ rc_service_exists(const char *service)
}
librc_hidden_def(rc_service_exists)
#define OPTSTR ". '%s'; echo $opts"
#define OPTSTR ". '%s'; echo $extra_commands $extra_started_commands"
RC_STRINGLIST *
rc_service_extra_commands(const char *service)
{
@@ -550,14 +550,16 @@ rc_service_extra_commands(const char *service)
if ((fp = popen(cmd, "r"))) {
rc_getline(&buffer, &len, fp);
p = buffer;
while ((token = strsep(&p, " "))) {
if (!commands)
commands = rc_stringlist_new();
rc_stringlist_add(commands, token);
}
commands = rc_stringlist_new();
while ((token = strsep(&p, " ")))
if (token[0] != '\0')
rc_stringlist_add(commands, token);
pclose(fp);
free(buffer);
}
free(cmd);
return commands;
}
@@ -747,7 +749,7 @@ rc_service_state(const char *service)
if (state & RC_SERVICE_STOPPED) {
dirs = ls_dir(RC_SVCDIR "/scheduled", 0);
TAILQ_FOREACH (dir, dirs, entries) {
TAILQ_FOREACH(dir, dirs, entries) {
snprintf(file, sizeof(file),
RC_SVCDIR "/scheduled/%s/%s",
dir->value, service);
@@ -890,7 +892,7 @@ rc_services_in_runlevel_stacked(const char *runlevel)
list = rc_services_in_runlevel(runlevel);
stacks = rc_runlevel_stacks(runlevel);
TAILQ_FOREACH (stack, stacks, entries) {
TAILQ_FOREACH(stack, stacks, entries) {
sl = rc_services_in_runlevel(stack->value);
if (list != NULL) {
TAILQ_CONCAT(list, sl, entries);
@@ -1006,7 +1008,7 @@ rc_services_scheduled_by(const char *service)
RC_STRING *dir;
char file[PATH_MAX];
TAILQ_FOREACH (dir, dirs, entries) {
TAILQ_FOREACH(dir, dirs, entries) {
snprintf(file, sizeof(file), RC_SVCDIR "/scheduled/%s/%s",
dir->value, service);
if (exists(file))

17
src/rc/.gitignore vendored
View File

@@ -1,4 +1,3 @@
.depend
version.h
rc-status
rc-service
@@ -56,20 +55,4 @@ mark_service_wasinactive
mark_service_hotplugged
mark_service_failed
rc-abort
checkpath.o
fstabinfo.o
mountinfo.o
start-stop-daemon.o
swclock.o
rc-applets.o
rc-depend.o
rc-logger.o
rc-misc.o
rc-plugin.o
rc-service.o
rc-status.o
rc-update.o
runscript.o
rc.o
rc
.depend

View File

@@ -36,7 +36,6 @@ LDADD+= -lutil -lrc -leinfo
include ../../Makefile.inc
MK= ../../mk
include ${MK}/debug.mk
include ${MK}/prog.mk
include ${MK}/git.mk
include ${MK}/cc.mk

View File

@@ -164,6 +164,7 @@ show(RC_STRINGLIST *runlevels, bool verbose)
char buffer[PATH_MAX];
size_t l;
rc_stringlist_sort(&services);
TAILQ_FOREACH(service, services, entries) {
in = rc_stringlist_new();
inone = false;
@@ -299,6 +300,7 @@ rc_update(int argc, char **argv)
runlevels = rc_runlevel_list();
}
rc_stringlist_sort(&runlevels);
show (runlevels, verbose);
} else {
if (!service)

View File

@@ -806,7 +806,6 @@ main(int argc, char **argv)
int opt;
bool parallel;
int regen = 0;
int i;
#ifdef __linux__
char *proc;
char *p;

View File

@@ -1101,7 +1101,8 @@ runscript(int argc, char **argv)
bool doneone = false;
int retval, opt, depoptions = RC_DEP_TRACE;
RC_STRING *svc;
char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, pidstr[10];
char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, *save2 = NULL;
char pidstr[10];
size_t l = 0, ll;
const char *file;
struct stat stbuf;
@@ -1133,7 +1134,8 @@ runscript(int argc, char **argv)
dir = dirname(path);
if (strchr(lnk, '/')) {
save = xstrdup(dir);
dir = dirname(lnk);
save2 = xstrdup(lnk);
dir = dirname(save2);
if (strcmp(dir, save) == 0)
file = basename_c(argv[1]);
else
@@ -1149,6 +1151,7 @@ runscript(int argc, char **argv)
service = xstrdup(lnk);
}
free(save);
free(save2);
}
if (!service)
service = xstrdup(path);