summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Heim <phreak@gentoo.org>2006-02-17 10:47:44 +0000
committerChristian Heim <phreak@gentoo.org>2006-02-17 10:47:44 +0000
commit4571aac387bef4a5f88ed40d611e22f54cb3e14c (patch)
treed150c71a0235442f920635eb0ece35ffc2cc06c9
parentMerging r1881 (diff)
downloadbaselayout-vserver-4571aac387bef4a5f88ed40d611e22f54cb3e14c.tar.gz
baselayout-vserver-4571aac387bef4a5f88ed40d611e22f54cb3e14c.tar.bz2
baselayout-vserver-4571aac387bef4a5f88ed40d611e22f54cb3e14c.zip
Merging r1909
svn path=/baselayout-vserver/branches/baselayout-1_12/; revision=237
-rw-r--r--ChangeLog17
-rw-r--r--ChangeLog.vserver15
-rw-r--r--net-scripts/conf.d/net.example55
-rwxr-xr-xnet-scripts/net.modules.d/helpers.d/dhcp4
-rw-r--r--net-scripts/net.modules.d/helpers.d/functions4
-rw-r--r--net-scripts/net.modules.d/iproute228
-rw-r--r--net-scripts/net.modules.d/pppd8
-rw-r--r--net-scripts/net.modules.d/tuntap43
-rw-r--r--sbin/rc-daemon.sh6
9 files changed, 108 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index 522d6cb..887cd82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,18 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+* baselayout-1.12.0_pre16 (16 Feb 2006)
+
+ 15 Feb 2006; Roy Marples <uberlord@gentoo.org>:
+
+ tuntap now works if openvpn is installed, #122452.
+
+ 14 Feb 2006; Roy Marples <uberlord@gentoo.org>:
+
+ ip rules setup has been documented in net.example, #107628.
+
+ pppd should now be fully re-entrant, #122396.
+
08 Feb 2006; Roy Marples <uberlord@gentoo.org>:
New module ip6to4 that creates tunnels with IPv6 addresses based off
@@ -9,7 +21,7 @@
07 Feb 2006; Roy Marples <uberlord@gentoo.org>:
- Always ensure the end_service is called, #119233 again.
+ Always ensure that end_service is called, #119233 again.
You can now specify a maxfail value for pppd (default 0), #115346.
@@ -17,9 +29,6 @@
chat commands in pppd are now re-quoted, #121665.
- ip routing policies are now supports via the rule_eth0=( ... )
- variable (only supported by iproute2), #107628.
-
wpa_supplicant now looks for config files in order
/etc/wpa_supplicant/wpa_supplicant-$iface.conf
/etc/wpa_supplicant/wpa_supplicant.conf
diff --git a/ChangeLog.vserver b/ChangeLog.vserver
index f86fe7c..5a006f5 100644
--- a/ChangeLog.vserver
+++ b/ChangeLog.vserver
@@ -1,6 +1,21 @@
# ChangeLog for Gentoo System Intialization ("rc") scripts
# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2
+ 17 Feb 2006; Christian Heim <phreak@gentoo.org>:
+ Merging latest changes to the baselayout-1_12 branch. This merge is based
+ upon revision 1909.
+
+ ChangeLog | 17 ++++-
+ ChangeLog.vserver | 15 ++++
+ net-scripts/conf.d/net.example | 55 ++++++++++++++----
+ net-scripts/net.modules.d/helpers.d/dhcp | 4 -
+ net-scripts/net.modules.d/helpers.d/functions | 4 -
+ net-scripts/net.modules.d/iproute2 | 28 ---------
+ net-scripts/net.modules.d/pppd | 8 +-
+ net-scripts/net.modules.d/tuntap | 43 +++++++-------
+ sbin/rc-daemon.sh | 6 -
+ 9 files changed, 108 insertions(+), 72 deletions(-)
+
14 Feb 2006; Christian Heim <phreak@gentoo.org>:
Merging latest changes to the baselayout-1_12 branch. This merge is based
upon revision 1881.
diff --git a/net-scripts/conf.d/net.example b/net-scripts/conf.d/net.example
index d637731..baec820 100644
--- a/net-scripts/conf.d/net.example
+++ b/net-scripts/conf.d/net.example
@@ -119,13 +119,6 @@
# "::/0" # IPv6 unicast
#)
-# If you're using iproute2 then you can also do policy routing.
-# This is not available with ifconfig.
-#rules_eth0=(
-# "from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100"
-# "from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100"
-#)
-
# If a specified module fails (like dhcp - see below), you can specify a
# fallback like so
#fallback_eth0=( "192.168.0.2 netmask 255.255.255.0" )
@@ -511,7 +504,7 @@
#-----------------------------------------------------------------------------
# TUN/TAP
-# For TUN/TAP support emerge sys-apps/usermode-utilities
+# For TUN/TAP support emerge net-misc/openvpn or sys-apps/usermode-utilities
#
# NOTE: The interface name must be either tun or tap followed by a number
#config_tun1=( "192.168.0.1/24")
@@ -519,6 +512,7 @@
# For passing custom options to tunctl use something like the following. This
# example sets the owner to adm
#tunctl_tun1="-u adm"
+# When using openvpn, there are no options
#-----------------------------------------------------------------------------
# Bridging (802.1d)
@@ -695,7 +689,34 @@
# # This function could be used, for example, to register with a
# # dynamic DNS service. Another possibility would be to
# # send/receive mail once the interface is brought up.
-# return 0
+
+# # Here is an example that allows the use of iproute rules
+# # which have been configured using the rules_eth0 variable.
+# #rules_eth0=(
+# # "from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100"
+# # "from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100"
+# #)
+# local x="rules_${IFVAR}[@]"
+# local -a rules=( "${!x}" )
+# if [[ -n ${rules} ]] ; then
+# einfo "Adding IP policy routing rules"
+# eindent
+# # Ensure that the kernel supports policy routing
+# if ! ip rule list | grep -q "^" ; then
+# eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
+# eerror "in your kernel to use ip rules"
+# else
+# for x in "${rules[@]}" ; do
+# ebegin "${x}"
+# ip rule add ${x} dev "${IFACE}"
+# eend $?
+# done
+# fi
+# eoutdent
+# # Flush the cache
+# ip route flush cache dev "${IFACE}"
+# fi
+
#}
#postdown() {
@@ -703,7 +724,21 @@
# # Probably a good idea to set RC_DOWN_INTERFACE="no" in /etc/conf.d/rc
# # as well ;)
# [[ ${IFACE} != "lo" ]] && ethtool -s "${IFACE}" wol g
-#
+
+# Automatically erase any ip rules created in the example postup above
+# if interface_exists "${IFACE}" ; then
+# # Remove any rules for this interface
+# local rule
+# ip rule list | grep " iif ${IFACE}[ ]*" | {
+# while read rule ; do
+# rule="${rule#*:}"
+# ip rule del ${rule}
+# done
+# }
+# # Flush the route cache
+# ip route flush cache dev "${IFACE}"
+# fi
+
# # Return 0 always
# return 0
#}
diff --git a/net-scripts/net.modules.d/helpers.d/dhcp b/net-scripts/net.modules.d/helpers.d/dhcp
index 35d6775..ceb2d60 100755
--- a/net-scripts/net.modules.d/helpers.d/dhcp
+++ b/net-scripts/net.modules.d/helpers.d/dhcp
@@ -20,7 +20,7 @@ case "${action}" in
deconfig|leasefail)
# Just remove IPv4 / inet addresses
interface_del_addresses "${interface}" true
- service_started "${service}" && mark_service_inactive "net.${interface}"
+ service_started "${service}" && mark_service_inactive "${service}"
remove_state "${interface}"
if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
best_interface=$( select_best_interface )
@@ -115,7 +115,7 @@ else
apply_state "${interface}"
fi
-! service_stopping "${service}" && mark_service_started "${service}"
+service_inactive "${service}" && mark_service_started "${service}"
echo "${action}"
exit 0
diff --git a/net-scripts/net.modules.d/helpers.d/functions b/net-scripts/net.modules.d/helpers.d/functions
index dd325a3..058ba95 100644
--- a/net-scripts/net.modules.d/helpers.d/functions
+++ b/net-scripts/net.modules.d/helpers.d/functions
@@ -484,7 +484,7 @@ clean_pidfile() {
if [[ -n ${pid} ]]; then
local cmd="${pidfile##*/}"
cmd="${cmd%%-*}"
- ps -p "${pid}" 2>/dev/null | grep -q "${cmd}" && return 1
+ ps p "${pid}" 2>/dev/null | grep -q "${cmd}" && return 1
fi
rm -f "${pidfile}"
@@ -499,7 +499,7 @@ process_finished() {
local i pid="$1" cmd="$2" secs="${3:-9}"
for (( i=0; i<secs; i++ )); do
- ps -p "${pid}" 2>/dev/null | grep -q "${cmd}" || return 0
+ ps p "${pid}" 2>/dev/null | grep -q "${cmd}" || return 0
sleep 1
done
diff --git a/net-scripts/net.modules.d/iproute2 b/net-scripts/net.modules.d/iproute2
index 2052998..c1c2dea 100644
--- a/net-scripts/net.modules.d/iproute2
+++ b/net-scripts/net.modules.d/iproute2
@@ -346,26 +346,6 @@ iproute2_post_start() {
eoutdent
fi
- # Now apply any rules we may want
- x="rules_${ifvar}[@]"
- local -a rules=( "${!x}" )
- if [[ -n ${rules} ]] ; then
- einfo "Adding IP policy routing rules"
- eindent
- # Ensure that the kernel supports policy routing
- if ! ip rule list | grep -q "^" ; then
- eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
- eerror "in your kernel to use ip rules"
- else
- for x in "${rules[@]}" ; do
- ebegin "${x}"
- ip rule add ${x} dev "${iface}"
- eend $?
- done
- fi
- eoutdent
- fi
-
# Flush the route cache
ip route flush cache dev "${iface}"
@@ -401,14 +381,6 @@ iproute2_post_stop() {
local iface="$1" rule=""
iproute2_exists "${iface}" || return
-
- # Remove any rules for this interface
- ip rule list | grep " iif ${iface}[ ]*" | {
- while read rule ; do
- rule="${rule#*:}"
- ip rule del ${rule}
- done
- }
# Flush the route cache
ip route flush cache dev "${iface}"
diff --git a/net-scripts/net.modules.d/pppd b/net-scripts/net.modules.d/pppd
index 4a46045..d74d7ba 100644
--- a/net-scripts/net.modules.d/pppd
+++ b/net-scripts/net.modules.d/pppd
@@ -240,7 +240,7 @@ pppd_start() {
[[ ${insert_link_in_opts} -eq 0 ]] || opts="${!link} ${opts}"
ebegin "Running pppd"
- [[ " ${opts} " != *" updetach "* ]] && mark_service_inactive "net.${iface}"
+ mark_service_inactive "net.${iface}"
eval start-stop-daemon --start --exec /usr/sbin/pppd \
--pidfile "/var/run/ppp-${iface}.pid" -- "${opts}" >/dev/null
if [[ $? != "0" ]] ; then
@@ -254,10 +254,10 @@ pppd_start() {
einfo "${iface} received address ${addr}"
else
einfo "Backgrounding ..."
- exit 0
fi
-
- return 0
+
+ # pppd will re-call us when we bring the interface up
+ exit 0
}
# bool pppd_stop(char *iface)
diff --git a/net-scripts/net.modules.d/tuntap b/net-scripts/net.modules.d/tuntap
index bdea08c..c37ae91 100644
--- a/net-scripts/net.modules.d/tuntap
+++ b/net-scripts/net.modules.d/tuntap
@@ -6,6 +6,9 @@
# Fix any potential localisation problems
# Note that LC_ALL trumps LC_anything_else according to locale(7)
+openvpn() {
+ LC_ALL=C /usr/sbin/openvpn "$@"
+}
tunctl() {
LC_ALL=C /usr/bin/tunctl "$@"
}
@@ -23,8 +26,9 @@ tuntap_depend() {
#
# Returns 1 if tuntap is installed, otherwise 0
tuntap_check_installed() {
+ [[ -x /usr/sbin/openvpn ]] && return 0
[[ -x /usr/bin/tunctl ]] && return 0
- ${1:-false} && eerror "For TunTap support, emerge sys-apps/usermode-utilities"
+ ${1:-false} && eerror "For TunTap support, emerge net-misc/openvpn or sys-apps/usermode-utilities"
return 1
}
@@ -44,15 +48,16 @@ tuntap_check_kernel() {
#
# Returns 0 if the tun/tap interface exists, otherwise 1
tuntap_exists() {
- tunctl -d "$1" &>/dev/null
+ local itype="$(interface_type "$1")"
+ [[ ${itype} != "tun" && ${itype} != "tap" ]] && return 1
+ interface_exists "$1"
}
# bool tuntap_pre_start(char *iface)
#
# Create the device, give it the right perms
tuntap_pre_start() {
- local iface="$1" opts ifvar=$( bash_variable "$1" )
- local itype=$( interface_type "${iface}" )
+ local iface="$1" itype="$(interface_type "$1")"
# Check that we are a valid tun/tap interface
# NOTE - the name can be anything as we define it
@@ -62,14 +67,15 @@ tuntap_pre_start() {
tuntap_check_kernel || return 1
- # Get our options
- opts="tunctl_${ifvar}"
-
ebegin "Creating Tun/Tap interface ${iface}"
- tunctl ${!opts} -t "${iface}" >/dev/null
- eend "$?" || return 1
-
- return 0
+ if [[ -x /usr/sbin/openvpn ]] ; then
+ openvpn --mktun --dev "${iface}" >/dev/null
+ else
+ local ifvar="$(bash_variable "${iface}")"
+ local opts="tunctl_${ifvar}"
+ tunctl ${!opts} -t "${iface}" >/dev/null
+ fi
+ eend $?
}
# bool tuntap_stop(char *iface)
@@ -79,16 +85,15 @@ tuntap_stop() {
local iface="$1"
tuntap_check_installed || return 0
- interface_exists "${iface}" || return 0
+ tuntap_exists "${iface}" || return 0
- # tunctl doesn't always error on on tun/tap
- # interfaces (mainly aliases, etc)
- if tuntap_exists "${iface}" ; then
- interface_exists "${iface}" \
- || einfo "Destroyed Tun/Tap interface ${iface}"
+ ebegin "Destroying Tun/Tap interface ${iface}"
+ if [[ -x /usr/sbin/openvpn ]] ; then
+ openvpn --rmtun --dev "${iface}" >/dev/null
+ else
+ tunctl -d "${fiace}" >/dev/null
fi
-
- return 0
+ eend $?
}
# vim:ts=4
diff --git a/sbin/rc-daemon.sh b/sbin/rc-daemon.sh
index 7e67dcc..24409ed 100644
--- a/sbin/rc-daemon.sh
+++ b/sbin/rc-daemon.sh
@@ -144,7 +144,7 @@ rc_try_kill_pid() {
pkill "-${signal}" -s "${pid}"
pgrep -s "${pid}" >/dev/null || return 0
else
- local pids="$(ps -eo pid,sid | sed -n "s/ ${pid}\$//p")"
+ local pids="$(ps eo pid,sid | sed -n "s/ ${pid}\$//p")"
[[ -z ${pids} ]] && return 0
kill -s "${signal}" ${pids} 2>/dev/null
e=false
@@ -296,7 +296,7 @@ rc_stop_daemon() {
else
local npids
for pid in ${pids} ; do
- npids="${npids} $(ps -eo pid,ppid | sed -n "s/ ${pid}\$//p")"
+ npids="${npids} $(ps eo pid,ppid | sed -n "s/ ${pid}\$//p")"
done
pids="${pids} ${npids}"
fi
@@ -304,7 +304,7 @@ rc_stop_daemon() {
for pid in ${pids}; do
if [[ ${RC_FAIL_ON_ZOMBIE} == "yes" ]]; then
- ps -p "${pid}" &>/dev/null || return 1
+ ps p "${pid}" &>/dev/null || return 1
fi
if rc_kill_pid "${pid}" false ; then