diff options
Diffstat (limited to 'main/openrc/openrc-0.7.0-git_20110222.patch')
-rw-r--r-- | main/openrc/openrc-0.7.0-git_20110222.patch | 3879 |
1 files changed, 0 insertions, 3879 deletions
diff --git a/main/openrc/openrc-0.7.0-git_20110222.patch b/main/openrc/openrc-0.7.0-git_20110222.patch deleted file mode 100644 index 8a1711b596..0000000000 --- a/main/openrc/openrc-0.7.0-git_20110222.patch +++ /dev/null @@ -1,3879 +0,0 @@ -diff --git a/FEATURE-REMOVAL-SCHEDULE b/FEATURE-REMOVAL-SCHEDULE -new file mode 100644 -index 0000000..50c81f8 ---- /dev/null -+++ b/FEATURE-REMOVAL-SCHEDULE -@@ -0,0 +1,70 @@ -+The following is a list of files and features that are going to be removed in -+the source tree. Every entry should contain what exactly is going away, why it -+is happening, and who is going to be doing the work. When the feature is -+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 -+ -+Why: Replaced by the oldnet PPP module -+ -+Who: Robin H. Johnson <robbat2@gentoo.org> -+ -+--------------------------- -+ -+What: oldnet /etc/conf.d/wireless -+ -+When: undecided -+ -+Why: All configuration moved to /etc/conf.d/net -+ -+Who: Robin H. Johnson <robbat2@gentoo.org> -+ -+--------------------------- -+ -+What: Service pause action -+ -+When: Removed already, compatbility warning in place. -+ -+Why: ... -+ -+Who: -+ -+--------------------------- -+ -+What: Service --startas, --chuid , --oknodo -+ -+When: undecided -+ -+Why: Obsolete or replaced by other options. -+ --startas => use --name or --exec -+ --chuid => use --user -+ --oknodo => ignore return code instead -+ -+Who: -+ -+--------------------------- -diff --git a/Makefile b/Makefile -index 8f9cc95..dd427d0 100644 ---- a/Makefile -+++ b/Makefile -@@ -4,23 +4,18 @@ - - include Makefile.inc - --SUBDIR= conf.d etc init.d man scripts sh src -+SUBDIR= conf.d etc init.d local.d man scripts sh src - - # Build our old net foo or not --_OLDNET_SH= case "${MKOLDNET}" in \ -- [Yy][Ee][Ss]) echo "net doc";; \ -- *) echo "";; \ -- esac --_OLDNET!= ${_OLDNET_SH} --SUBDIR+= ${_OLDNET}$(shell ${_OLDNET_SH}) -+ifeq (${MKOLDNET},yes) -+SUBDIR+= net doc -+endif - - # Build pkgconfig or not --_PKGCONFIG_SH= case "${MKPKGCONFIG}" in \ -- [Yy][Ee][Ss]|"") echo "pkgconfig";; \ -- *) echo "";; \ -- esac --_PKGCONFIG!= ${_PKGCONFIG_SH} --SUBDIR+= ${_PKGCONFIG}$(shell ${_PKGCONFIG_SH}) -+MKPKGCONFIG?= yes -+ifeq (${MKPKGCONFIG},yes) -+SUBDIR+= pkgconfig -+endif - - # We need to ensure that runlevels is done last - SUBDIR+= runlevels -diff --git a/README b/README -index 07f181f..2a2eac3 100644 ---- a/README -+++ b/README -@@ -4,7 +4,7 @@ OpenRC README - Installation - ------------ - make install --Yup, that simple. Works with GNU make and BSD make. -+Yup, that simple. Works with GNU make. - - You may wish to tweak the installation with the below arguments - PROGLDFLAGS=-static -@@ -12,6 +12,7 @@ LIBNAME=lib64 - DESTDIR=/tmp/openrc-image - MKPAM=pam - MKPKGCONFIG=no -+MKSELINUX=yes - MKTERMCAP=ncurses - MKTERMCAP=termcap - MKOLDNET=yes -diff --git a/README.net b/README.net -deleted file mode 100644 -index 41db1c5..0000000 ---- a/README.net -+++ /dev/null -@@ -1,36 +0,0 @@ --OpenRC Network Ideals ----------------------- -- --The new style networking for OpenRC is very simplistic - provide a basic means --of configuring static interface address and routes whilst allowing the --possibility to run any command at any point. -- --In a nutshell, init.d/network is a wrapper around ifconfig(8) and --init.d/staticroute is wrapper around route(8). -- --In the Perfect World (TM) ifconfig should be able to configure everything --about the interface easily * . The BSD family almost get this right and Linux --epically fails. -- --* Only static configuration, including link setup. --For dynamic, static, IPv4LL, arping and per ssid IPv4 setup dhcpcd-5.x --provides your needs. -- --It fails because there are many tools to do the same job and often have --vastly different syntax where they could be similar. In other words, there --is no coherence. -- --OpenRC-0.4.x and older (inc Gentoo baselayout-1) had a collection of scripts --for each tool and allowed a script per interface. Over the years, this design --has proven very hard to maintain as each user has their own idea of how --things should work. Also, there were (and still are) race conditions. -- --So where do we go from here? --Well, it's possible to use the new network scripts using the tools --currently available. It's just harder as you have to know them and their --documentation can be lacking at times. --The correct end goal is a BSD style ifconfig tool. --I've started work on it, but the project has stalled somewhat. --It's display only right now and the source is not yet publicly available. --If you have the skills and share the vision then contact me privately and --we'll take it from there. -diff --git a/README.newnet b/README.newnet -new file mode 100644 -index 0000000..2e157e2 ---- /dev/null -+++ b/README.newnet -@@ -0,0 +1,40 @@ -+The following applies only to the newnet stack, which is not presently -+maintained in OpenRC. The oldnet stack is maintained instead. -+- Robin H. Johnson <robbat2@gentoo.org>, 2011/02/21 -+ -+OpenRC Network Ideals -+--------------------- -+ -+The new style networking for OpenRC is very simplistic - provide a basic means -+of configuring static interface address and routes whilst allowing the -+possibility to run any command at any point. -+ -+In a nutshell, init.d/network is a wrapper around ifconfig(8) and -+init.d/staticroute is wrapper around route(8). -+ -+In the Perfect World (TM) ifconfig should be able to configure everything -+about the interface easily * . The BSD family almost get this right and Linux -+epically fails. -+ -+* Only static configuration, including link setup. -+For dynamic, static, IPv4LL, arping and per ssid IPv4 setup dhcpcd-5.x -+provides your needs. -+ -+It fails because there are many tools to do the same job and often have -+vastly different syntax where they could be similar. In other words, there -+is no coherence. -+ -+OpenRC-0.4.x and older (inc Gentoo baselayout-1) had a collection of scripts -+for each tool and allowed a script per interface. Over the years, this design -+has proven very hard to maintain as each user has their own idea of how -+things should work. Also, there were (and still are) race conditions. -+ -+So where do we go from here? -+Well, it's possible to use the new network scripts using the tools -+currently available. It's just harder as you have to know them and their -+documentation can be lacking at times. -+The correct end goal is a BSD style ifconfig tool. -+I've started work on it, but the project has stalled somewhat. -+It's display only right now and the source is not yet publicly available. -+If you have the skills and share the vision then contact me privately and -+we'll take it from there. -diff --git a/STYLE b/STYLE -new file mode 100644 -index 0000000..f1ae5c1 ---- /dev/null -+++ b/STYLE -@@ -0,0 +1,34 @@ -+This is the openrc style manual. It governs the coding style of all code -+in this repository. Follow it. Contact openrc@gentoo.org for any questions -+or fixes you might notice. -+ -+########## -+# C CODE # -+########## -+ -+The BSD Kernel Normal Form (KNF) style is used: -+ http://en.wikipedia.org/wiki/Indent_style#BSD_KNF_style -+Basically, it's like K&R/LKML, but wrapped lines that are indented use 4 spaces. -+ -+Highlights: -+ - no trailing whitespace -+ - indented code use tabs (not line wrapped) -+ - cuddle the braces (except for functions) -+ - space after native statements and before paren (for/if/while/...) -+ - no space between function and paren -+ - pointer asterisk cuddles the variable, not the type -+ -+void foo(int c) -+{ -+ int ret = 0; -+ -+ if (c > 1000) -+ return; -+ -+ while (c--) { -+ bar(c); -+ ret++; -+ } -+ -+ return ret; -+} -diff --git a/TODO b/TODO -index e008fca..4309aa0 100644 ---- a/TODO -+++ b/TODO -@@ -3,3 +3,5 @@ - - add support somehow for optional translations - - - oldnet[bridging]: Review setting of bridge configuration on dynamic interface add -+ -+- Document rc-depend binary. -diff --git a/conf.d/Makefile b/conf.d/Makefile -index 034dc74..374bfdb 100644 ---- a/conf.d/Makefile -+++ b/conf.d/Makefile -@@ -1,5 +1,5 @@ - DIR= ${CONFDIR} --CONF= bootmisc fsck hostname local localmount network staticroute urandom -+CONF= bootmisc fsck hostname localmount network staticroute urandom - - TARGETS+= network staticroute - CLEANFILES+= network staticroute -diff --git a/conf.d/hwclock b/conf.d/hwclock -index 5321ba1..4e66ff9 100644 ---- a/conf.d/hwclock -+++ b/conf.d/hwclock -@@ -9,6 +9,14 @@ clock="UTC" - # You normally don't need to do this if you run a ntp daemon. - clock_systohc="NO" - -+# If you want to set the system time to the current hardware clock -+# during bootup, then say "YES" here. You do not need this if you are -+# running a modern kernel with CONFIG_RTC_HCTOSYS set to y. -+# Also, be aware that if you set this to "NO", the system time will -+# never be saved to the hardware clock unless you set -+# clock_systohc="YES" above. -+clock_hctosys="YES" -+ - # If you wish to pass any other arguments to hwclock during bootup, - # you may do so here. Alpha users may wish to use --arc or --srm here. - clock_args="" -diff --git a/conf.d/local b/conf.d/local -deleted file mode 100644 -index 97dbbcc..0000000 ---- a/conf.d/local -+++ /dev/null -@@ -1,18 +0,0 @@ --# Here is where you can put anything you need to start --# that there is not an init script for. -- --local_start() { -- # This is a good place to load any misc programs -- # on startup (use &>/dev/null to hide output) -- -- # We should always return 0 -- return 0 --} -- --local_stop() { -- # This is a good place to unload any misc. -- # programs you started above. -- -- # We should always return 0 -- return 0 --} -diff --git a/doc/net.example.BSD.in b/doc/net.example.BSD.in -index 977011e..287c644 100644 ---- a/doc/net.example.BSD.in -+++ b/doc/net.example.BSD.in -@@ -23,7 +23,7 @@ - # We now support modular networking scripts which means we can easily - # add support for new interface types and modules while keeping - # compatibility with existing ones. --# -+# - # Modules load by default if the package they need is installed. If - # you specify a module here that doesn't have its package installed - # then you get an error stating which package you need to install. -@@ -212,7 +212,7 @@ - # not find them in a scan - # "forcepreferredonly" means it forcibly connects to the APs in order and - # does not bother to scan --# "forceany" does the same as forcepreferred + connects to any other -+# "forceany" does the same as forcepreferred + connects to any other - # available AP - # Default is "any" - #associate_order="any" -@@ -266,13 +266,13 @@ - # won't have associated then) - - # If you're using anything else to configure wireless on your interface AND --# you have installed wpa_supplicant, you need to disable wpa_supplicant -+# you have installed wpa_supplicant, you need to disable wpa_supplicant - #modules="!iwconfig !wpa_supplicant" - #or - #modules="!wireless" - - ############################################################################## --# WIRELESS SSID IN VARIABLES -+# WIRELESS SSID IN VARIABLES - ############################################################################## - # Remember to change SSID to your SSID. - # Say that your SSID is My NET - the line -@@ -368,7 +368,7 @@ - - ############################################################################## - # ADVANCED CONFIGURATION --# -+# - # Four functions can be defined which will be called surrounding the - # start/stop operations. The functions are called with the interface - # name first so that one function can control multiple adapters. An extra two -diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in -index 42e5477..69c9ba6 100644 ---- a/doc/net.example.Linux.in -+++ b/doc/net.example.Linux.in -@@ -24,7 +24,7 @@ - # We now support modular networking scripts which means we can easily - # add support for new interface types and modules while keeping - # compatibility with existing ones. --# -+# - # Modules load by default if the package they need is installed. If - # you specify a module here that doesn't have its package installed - # then you get an error stating which package you need to install. -@@ -49,7 +49,7 @@ - - ############################################################################## - # INTERFACE HANDLERS --# -+# - # We provide two interface handlers presently: ifconfig and iproute2. - # You need one of these to do any kind of network configuration. - # For ifconfig support, emerge sys-apps/net-tools -@@ -297,7 +297,7 @@ - # Surround each SSID with the " character and separate them with a space - # If the first SSID isn't found then it moves onto the next - # If this isn't defined then it connects to the first one found --#preferred_aps="SSID1 SSID2" -+#preferred_aps="SSID1 SSID2" - - # You can also define a preferred_aps list per interface - #preferred_aps_eth0="SSID3 SSID4" -@@ -371,13 +371,13 @@ - # won't have associated then) - - # If you're using anything else to configure wireless on your interface AND --# you have installed wpa_supplicant, you need to disable wpa_supplicant -+# you have installed wpa_supplicant, you need to disable wpa_supplicant - #modules="!iwconfig !wpa_supplicant" - #or - #modules="!wireless" - - ############################################################################## --# WIRELESS SSID IN VARIABLES -+# WIRELESS SSID IN VARIABLES - ############################################################################## - # Remember to change SSID to your SSID. - # Say that your SSID is My NET - the line -@@ -421,7 +421,7 @@ - # Notes: - # - All clients send the current hostname to the DHCP server by default - # - dhcpcd does not daemonize when the lease time is infinite --# - udhcp-0.9.3-r3 and earlier do not support getting NTP servers -+# - udhcp-0.9.3-r3 and earlier do not support getting NTP servers - # - pump does not support getting NIS servers - # - DHCP tends to erase any existing device information - so add - # static addresses after dhcp if you need them -@@ -467,7 +467,7 @@ - #fallback_eth0="apipa" - - #----------------------------------------------------------------------------- --# ARPING Gateway configuration -+# ARPING Gateway configuration - # and - # Automatic Private IP Addressing (APIPA) - # For arpingnet / apipa support, emerge net-misc/iputils or net-analyzer/arping -@@ -527,7 +527,8 @@ - - #----------------------------------------------------------------------------- - # VLAN (802.1q support) --# For VLAN support, emerge net-misc/vconfig -+# For VLAN support, emerge sys-apps/iproute2 -+# The old vconfig based VLAN support is no longer available. - - # Specify the VLAN numbers for the interface like so - # Please ensure your VLAN IDs are NOT zero-padded -@@ -537,10 +538,17 @@ - # need it up. - #config_eth0="null" - --# You can also configure the VLAN - see for vconfig man page for more details --#vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD" --#vconfig_vlan1="set_flag 1 --#set_egress_map 2 6" -+# You can also configure the VLAN - see for ip man page for more details -+# To change the vlan interface name. If not set, the standard "iface.vlanid" -+# will be used -+#vlan1_name="vlan1" -+#vlan2_name="eth0.2" -+# Set the vlan flags -+#vlan1_flags="reorder_hdr off gvrp on loose_binding on" -+# Configure in/egress maps -+#vlan1_ingress="2:6 3:5" -+#vlan1_egress="1:2" -+ - #config_vlan1="172.16.3.1/23" - #config_vlan2="172.16.2.1/23" - -@@ -553,8 +561,7 @@ - # This means you do not need to create init scripts in /etc/init.d for each - # vlan, you must need to create one for the physical interface. - # If you wish to control the configuration of each vlan through a separate --# script, or wish to rename the vlan interface to something that vconfig --# cannot then you need to do this. -+# script then you need to do this. - #vlan_start_eth0="no" - - # If you do the above then you may want to depend on eth0 like so -@@ -582,7 +589,7 @@ - - - #----------------------------------------------------------------------------- --# Classical IP over ATM -+# Classical IP over ATM - # For CLIP support emerge net-dialup/linux-atm - - # Ensure that you have /etc/atmsigd.conf setup correctly -@@ -620,7 +627,7 @@ - # - # Here you should specify what pppd plugins you want to use - # Available plugins are: pppoe, pppoa, capi, dhcpc, minconn, radius, --# radattr, radrealms and winbind -+# radattr, radrealms and winbind - #plugins_ppp0="pppoe" # Required plugin for PPPoE - #plugins_ppp0="pppoa vc-encaps" # Required plugin for PPPoA with an option - #plugins_ppp0="capi" # Required plugin for ISDN -@@ -660,7 +667,7 @@ - # lcp-echo-interval 15 # Send a LCP echo every 15 seconds - # lcp-echo-failure 3 # Make peer dead after 3 consecutive - # # echo-requests --# -+# - # Compression options - use these to completely disable compression - # noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp - # -@@ -793,7 +800,7 @@ - # empty value variable is fine, but at least one of them must be set: - # brctl_IFVAR - --# You need to configure the ports to null values so dhcp does not get started -+# You need to configure the ports to null values so dhcp does not get started - #config_eth0="null" - #config_eth1="null" - -@@ -820,7 +827,7 @@ - #hairpin_mode_eth0="1" - - #----------------------------------------------------------------------------- --# RFC 2684 Bridge Support -+# RFC 2684 Bridge Support - # For RFC 2684 bridge support emerge net-misc/br2684ctl - - # Interface names have to be of the form nas0, nas1, nas2, etc. -@@ -973,9 +980,75 @@ - #ifplugd_eth0="--api-mode=wlan" - # man ifplugd for more options - -+#----------------------------------------------------------------------------- -+# Interface hardware tuning & configuration via ethtool -+# If you need to change explicit hardware settings on your network card prior -+# to bringing the interface up, the following is available. -+# -+# For a full listing of settings, please consulting ethtool(8) and the output -+# of "ethtool --help". -+# -+# Multiple entries (seperated by newlines) are supported in all of the -+# variables as some settings cannot be changed at the same time. -+# -+# Valid variable name fragments: change pause coalesce ring offload -+# change_eeprom identify nfc flash rxfh_indir ntuple -+ -+# Set Wake-On-Lan to listen for SecureOn MagicPacket(tm), the message level to -+# notify us of WOL changes, and the SecureOn password to 'DE:AD:BE:EF:CA:FE'. -+#ethtool_change_eth0="wol gs -+#msglvl wol on -+#sopass DE:AD:BE:EF:CA:FE" -+ -+# Disable pause auto-negotiation and explicitly enable RX and TX pause. -+#ethtool_pause_eth0="autoneg off -+#rx on tx on" -+ -+# Enasble adaptive RX and TX coalescing -+#ethtool_coalesce_eth0="adaptive-rx on adaptive-tx on" -+ -+# Change ring buffer settings -+#ethtool_ring_eth0="" -+ -+# Enable all offload settings -+#ethtool_offload_eth0="rx on tx on sg on tso on ufo on gso on gro on lro on" -+ -+# Change specific bytes in the EEPROM -+#ethtool_change_eeprom_eth0="" -+ -+# Run the identify sequence on the interface for 1 second (does not return until completion) -+#ethtool_identify_eth0="1" -+ -+# Configure receive network flow classification -+#ethtool_nfc_eth0=" -+#rx-flow-hash tcp4 f -+#rx-flow-hash udp4 s" -+ -+# Flash firmware to all regions -+#ethtool_flash_eth0="/some/path/firmware1 0" -+ -+# Flash firmware to region 1 -+#ethtool_flash_eth0="/some/path/firmware2 1" -+ -+# Set receive flow hash indirection table for even balancing between N receive queues -+#ethtool_rxfh_indir_eth0="equal 4" -+ -+# Configure Rx ntuple filters and actions -+#ethtool_ntuple_eth0="" -+ -+# Additionally, there is a special control variable, if you need to change the -+# order of option processing. The default order is: -+# flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple -+ -+# Set global order to default -+#ethtool_order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple" -+ -+# Hypothetical network card that requires a change-eeprom toggle to enable flashing -+#ethtool_order_eth0="change-eeprom flash change pause coalesce ring offload nfc rxfh-indir ntuple" -+ - ############################################################################## - # ADVANCED CONFIGURATION --# -+# - # Four functions can be defined which will be called surrounding the - # start/stop operations. The functions are called with the interface - # name first so that one function can control multiple adapters. An extra two -@@ -1001,7 +1074,7 @@ - # if mii-tool "${IFACE}" 2> /dev/null | grep -q 'no link'; then - # ewarn "No link on ${IFACE}, aborting configuration" - # return 1 --# fi -+# fi - # - # # Test for link on the interface prior to bringing it up. This - # # only works on some network adapters and requires the ethtool -diff --git a/etc/rc.conf.FreeBSD b/etc/rc.conf.FreeBSD -index 5682e1d..800c6cf 100644 ---- a/etc/rc.conf.FreeBSD -+++ b/etc/rc.conf.FreeBSD -@@ -3,6 +3,10 @@ - # "jail" - FreeBSD jails - # "prefix" - Prefix - # If unset, the old automagic detection code will be triggered. Said old code --# is deprecated and be removed not later than 2010/03/01. -+# is deprecated and will be removed not later than 2011/03/01. -+# -+# This should be set to the value representing what environment this file is -+# PRESENTLY in, not what virtualization the environment is capable of. -+# See the OpenRC migration guide for more details. - rc_sys="" - -diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux -index 001e9c0..b110a81 100644 ---- a/etc/rc.conf.Linux -+++ b/etc/rc.conf.Linux -@@ -8,7 +8,11 @@ - # "xen0" - Xen0 Domain - # "xenU" - XenU Domain - # If unset, the old automagic detection code will be triggered. Said old code --# is deprecated and be removed not later than 2010/03/01. -+# is deprecated and will be removed not later than 2011/03/01. -+# -+# This should be set to the value representing what environment this file is -+# PRESENTLY in, not what virtualization the environment is capable of. -+# See the OpenRC migration guide for more details. - rc_sys="" - - ############################################################################## -diff --git a/etc/rc.conf.NetBSD b/etc/rc.conf.NetBSD -index 25d86a4..b29000b 100644 ---- a/etc/rc.conf.NetBSD -+++ b/etc/rc.conf.NetBSD -@@ -4,6 +4,10 @@ - # "xen0" - Xen0 Domain - # "xenU" - XenU Domain - # If unset, the old automagic detection code will be triggered. Said old code --# is deprecated and be removed not later than 2010/03/01. -+# is deprecated and will be removed not later than 2011/03/01. -+# -+# This should be set to the value representing what environment this file is -+# PRESENTLY in, not what virtualization the environment is capable of. -+# See the OpenRC migration guide for more details. - rc_sys="" - -diff --git a/etc/rc.conf.in b/etc/rc.conf.in -index 6aa3613..3c1210b 100644 ---- a/etc/rc.conf.in -+++ b/etc/rc.conf.in -@@ -95,7 +95,7 @@ - # We can set some things on a per service basis, like the nicelevel. - #export SSD_NICELEVEL="-19" - --# Pass ulimit parameters -+# Pass ulimit parameters - #rc_ulimit="-u 30" - - # It's possible to define extra dependencies for services like so -diff --git a/etc/rc.in b/etc/rc.in -index edd7a5d..d267bec 100644 ---- a/etc/rc.in -+++ b/etc/rc.in -@@ -6,7 +6,7 @@ - # This gives us a nice colour boot :) - [ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@" - --# Handle interrupts -+# Handle interrupts - trap : SIGINT - trap "echo 'Boot interrupted'; exit 1" SIGQUIT - -diff --git a/etc/rc.shutdown.in b/etc/rc.shutdown.in -index e0231c7..115f212 100644 ---- a/etc/rc.shutdown.in -+++ b/etc/rc.shutdown.in -@@ -2,7 +2,7 @@ - # Copyright (c) 2007-2008 Roy Marples <roy@marples.name> - # All rights reserved. Released under the 2-clause BSD license. - --# Handle interrupts -+# Handle interrupts - trap : SIGINT SIGQUIT - - # Try and use stuff in /lib over anywhere else so we can shutdown -diff --git a/init.d.misc/dnsmasq.in b/init.d.misc/dnsmasq.in -index de4bade..958a87e 100644 ---- a/init.d.misc/dnsmasq.in -+++ b/init.d.misc/dnsmasq.in -@@ -10,7 +10,7 @@ required_files=/etc/dnsmasq.conf - extra_started_commands="reload" - - depend() --{ -+{ - provide dns - need localmount net - after bootmisc -diff --git a/init.d.misc/openvpn.in b/init.d.misc/openvpn.in -index eb1360b..a53a3ed 100644 ---- a/init.d.misc/openvpn.in -+++ b/init.d.misc/openvpn.in -@@ -24,7 +24,7 @@ if yesno $openvpn_client; then - command_args="$command_args --up $openvpn_up" - command_args="$command_args --down $openvpn_down" - required_files="$required_files $openvpn_up $openvpn_down" -- -+ - in_background_fake="start stop" - start_inactive=YES - fi -@@ -59,7 +59,7 @@ start_pre() - sysctl -a | grep -q '\.tap\.' || kldload if_tap - fi - fi -- -+ - # If the config file does not specify the cd option, we do - if ! grep -q "^[ \t]*cd[ \t].*" "$openvpn_config"; then - command_args="$command_args --cd $openvpn_dir" -diff --git a/init.d.misc/sshd.in b/init.d.misc/sshd.in -index 3d02cab..403f43b 100644 ---- a/init.d.misc/sshd.in -+++ b/init.d.misc/sshd.in -@@ -31,5 +31,5 @@ start_pre() - eend $? || return 1 - fi - -- $command -t -+ $command -t - } -diff --git a/init.d.misc/wpa_supplicant.in b/init.d.misc/wpa_supplicant.in -index f1d65c5..2426905 100644 ---- a/init.d.misc/wpa_supplicant.in -+++ b/init.d.misc/wpa_supplicant.in -@@ -43,7 +43,7 @@ find_wireless() - done - ;; - esac -- -+ - return 1 - } - -diff --git a/init.d/Makefile b/init.d/Makefile -index 6a0323c..b7490d3 100644 ---- a/init.d/Makefile -+++ b/init.d/Makefile -@@ -5,12 +5,10 @@ SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in netmount.in \ - BIN= ${OBJS} - - # Build our old net foo or not --_OLDNET_SH= case "${MKOLDNET}" in \ -- [Yy][Ee][Ss]) echo "net.lo";; \ -- *) echo "";; \ -- esac --_OLDNET!= ${_OLDNET_SH} --_NET_LO= ${_OLDNET}$(shell ${_OLDNET_SH}) -+ifeq (${MKOLDNET},yes) -+_OLDNET= net.lo -+endif -+_NET_LO= ${_OLDNET} - - INSTALLAFTER= _installafter_${_NET_LO} - CLEANFILES+= ${_NET_LO} -diff --git a/init.d/adjkerntz.in b/init.d/adjkerntz.in -index ee09ac8..807d411 100644 ---- a/init.d/adjkerntz.in -+++ b/init.d/adjkerntz.in -@@ -4,7 +4,7 @@ - - extra_commands="save" - --description="Sets the local clock to UTC or Local Time." -+description="Sets the local clock to UTC or Local Time." - description_save="Saves the current time in the BIOS." - - : ${clock:=${CLOCK:-UTC}} -@@ -26,7 +26,7 @@ depend() - } - - start() --{ -+{ - ebegin "Starting the System Clock Adjuster [${utc}]" - if [ "$clock" != "UTC" ]; then - echo >/etc/wall_cmos_clock -diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in -index 1298740..320e7e8 100644 ---- a/init.d/bootmisc.in -+++ b/init.d/bootmisc.in -@@ -88,7 +88,7 @@ start() - eend 1 "failed to create needed directory $x" - return 1 - fi -- fi -+ fi - done - - if dir_writeable /var/run; then -@@ -137,7 +137,7 @@ start() - # Make sure our X11 stuff have the correct permissions - # Omit the chown as bootmisc is run before network is up - # and users may be using lame LDAP auth #139411 -- rm -rf /tmp/.ICE-unix /tmp/.X11-unix -+ rm -rf /tmp/.ICE-unix /tmp/.X11-unix - mkdir -p /tmp/.ICE-unix /tmp/.X11-unix - chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix - if [ -x /sbin/restorecon ]; then -diff --git a/init.d/consolefont.in b/init.d/consolefont.in -index d3acd75..75c2fd1 100644 ---- a/init.d/consolefont.in -+++ b/init.d/consolefont.in -@@ -61,12 +61,6 @@ start() - done - cp "$font" "$RC_LIBEXECDIR"/console - echo "${font##*/}" >"$RC_LIBEXECDIR"/console/font -- if yesno ${unicode:-${UNICODE}}; then -- echo "" > "$RC_LIBEXECDIR"/console/unicode -- else -- rm -f "$RC_LIBEXECDIR"/console/unicode -- fi -- - fi - - return $retval -diff --git a/init.d/hostid.in b/init.d/hostid.in -index 26ea9d6..a12e34a 100644 ---- a/init.d/hostid.in -+++ b/init.d/hostid.in -@@ -68,7 +68,7 @@ reset() - start() - { - if [ -r "$hostid_file" ]; then -- _set $(cat "$hostid_file") -+ _set $(cat "$hostid_file") - else - reset - fi -diff --git a/init.d/hwclock.in b/init.d/hwclock.in -index e99900f..640d997 100644 ---- a/init.d/hwclock.in -+++ b/init.d/hwclock.in -@@ -4,7 +4,7 @@ - - extra_commands="save show" - --description="Sets the local clock to UTC or Local Time." -+description="Sets the local clock to UTC or Local Time." - description_save="Saves the current time in the BIOS." - description_show="Displays the current time in the BIOS." - -@@ -87,17 +87,21 @@ start() - _hwclock --adjust $utc_cmd - retval=$(($retval + $?)) - fi -- -+ - # If setting UTC, don't bother to run hwclock when first booting - # as that's the default - if [ "$PREVLEVEL" != N -o \ -- "$utc_cmd}" != --utc -o \ -+ "$utc_cmd" != --utc -o \ - -n "$clock_args" ]; - then -- _hwclock --hctosys $utc_cmd $clock_args -+ if yesno $clock_hctosys; then -+ _hwclock --hctosys $utc_cmd $clock_args -+ else -+ _hwclock --systz $utc_cmd $clock_args -+ fi - retval=$(($retval + $?)) - fi -- -+ - eend $retval "Failed to set the system clock" - - return 0 -@@ -126,7 +130,7 @@ stop() - _hwclock --systohc $utc_cmd $clock_args - retval=$? - -- eend $retval "Failed to sync clocks" -+ eend $retval "Failed to sync clocks" - } - - save() -diff --git a/init.d/ipfw.in b/init.d/ipfw.in -index 9d6faa4..ea6e22a 100644 ---- a/init.d/ipfw.in -+++ b/init.d/ipfw.in -@@ -40,11 +40,11 @@ init() { - ipfw add deny all from any to 127.0.0.0/8 - ipfw add deny ip from 127.0.0.0/8 to any - -- if have_ip6; then -+ if have_ip6; then - ipfw add pass ip6 from any to any via lo0 - ipfw add deny ip6 from any to ::1 - ipfw add deny ip6 from ::1 to any -- -+ - ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp - ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp - ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp -@@ -78,7 +78,7 @@ start() { - ipfw add pass udp from 0.0.0.0 68 to 255.255.255.255 67 out - ipfw add pass udp from any 67 to me 68 in - ipfw add pass udp from any 67 to 255.255.255.255 68 in -- # Some servers will ping the IP while trying to decide if it's -+ # Some servers will ping the IP while trying to decide if it's - # still in use. - ipfw add pass icmp from any to any icmptype 8 - -@@ -88,11 +88,11 @@ start() { - if have_ip6; then - # Allow ICMPv6 destination unreach - ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp -- -+ - # Allow NS/NA/toobig (don't filter it out) - ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp - fi -- -+ - # Add permits for this workstations published services below - # Only IPs and nets in firewall_allowservices is allowed in. - for i in $ipfw_ip_in; do -@@ -107,7 +107,7 @@ start() { - for i in $ipfw_ip_trust; do - ipfw add pass ip from $i to me - done -- -+ - ipfw add 65000 count ip from any to any - - # Drop packets to ports where we don't want logging -@@ -117,7 +117,7 @@ start() { - - # Broadcasts and muticasts - ipfw add deny ip from any to 255.255.255.255 -- ipfw add deny ip from any to 224.0.0.0/24 -+ ipfw add deny ip from any to 224.0.0.0/24 - - # Noise from routers - ipfw add deny udp from any to any 520 in -diff --git a/init.d/keymaps.in b/init.d/keymaps.in -index f37fbb5..776f3bb 100644 ---- a/init.d/keymaps.in -+++ b/init.d/keymaps.in -@@ -17,7 +17,7 @@ start() - : ${unicode:=$UNICODE} - : ${keymap:=$KEYMAP} - : ${extended_keymaps:=$EXTENDED_KEYMAPS} -- : ${windowkeys:=$SET_WINDOWSKEYS} -+ : ${windowkeys:=$SET_WINDOWSKEYS} - : ${fix_euro:=$FIX_EURO} - : ${dumpkeys_charset:=${DUMPKEYS_CHARSET}} - -diff --git a/init.d/killprocs.in b/init.d/killprocs.in -index d12f0f6..7132e9e 100644 ---- a/init.d/killprocs.in -+++ b/init.d/killprocs.in -@@ -15,7 +15,7 @@ start() - killall5 -15 - sleep 1 - eend 0 -- ebegin "Killing remaining processes" -+ ebegin "Killing remaining processes" - killall5 -9 - sleep 1 - eend 0 -diff --git a/init.d/local.in b/init.d/local.in -index 63d5e92..4db492e 100644 ---- a/init.d/local.in -+++ b/init.d/local.in -@@ -2,7 +2,7 @@ - # Copyright (c) 2007-2008 Roy Marples <roy@marples.name> - # All rights reserved. Released under the 2-clause BSD license. - --description="Executes user commands in /etc/conf.d/local" -+description="Executes user programs in @SYSCONFDIR@/local.d" - - depend() - { -@@ -12,22 +12,40 @@ depend() - - start() - { -- ebegin "Starting local" -+ einfo "Starting local" -+ -+ local file -+ for file in @SYSCONFDIR@/local.d/*.start ; do -+ [ -x "$file" ] && "$file" -+ done - - if type local_start >/dev/null 2>&1; then -+ ewarn "@SYSCONFDIR@/conf.d/local should be removed." -+ ewarn "Please move the code from the local_start function" -+ ewarn "to scripts with an .start extension" -+ ewarn "in @SYSCONFDIR@/local.d" - local_start - fi - -- eend $? "Failed to start local" -+ return 0 - } - - stop() - { -- ebegin "Stopping local" -+ einfo "Stopping local" -+ -+ local file -+ for file in @SYSCONFDIR@/local.d/*.stop; do -+ [ -x "$file" ] && "$file" -+ done - - if type local_start >/dev/null 2>&1; then -+ ewarn "@SYSCONFDIR@/conf.d/local should be removed." -+ ewarn "Please move the code from the local_stop function" -+ ewarn "to scripts with an .stop extension" -+ ewarn "in @SYSCONFDIR@/local.d" - local_stop - fi - -- eend $? "Failed to stop local" -+ return 0 - } -diff --git a/init.d/localmount.in b/init.d/localmount.in -index 2a8e96f..e2ea801 100644 ---- a/init.d/localmount.in -+++ b/init.d/localmount.in -@@ -58,8 +58,8 @@ stop() - - . "$RC_LIBEXECDIR"/sh/rc-mount.sh - -- # Umount loopback devices -- einfo "Unmounting loopback devices" -+ # Umount loop devices -+ einfo "Unmounting loop devices" - eindent - do_unmount "umount -d" --skip-point-regex "$no_umounts_r" \ - --node-regex "^/dev/loop" -diff --git a/init.d/moused.in b/init.d/moused.in -index a362228..33b8d02 100644 ---- a/init.d/moused.in -+++ b/init.d/moused.in -@@ -21,13 +21,13 @@ depend() - - start() - { -- ebegin "Starting $name" -+ ebegin "Starting $name" - - if [ -z "$moused_device" ]; then - local dev= - for dev in /dev/psm[0-9]* /dev/ums[0-9]*; do - [ -c "$dev" ] || continue -- [ -e /var/run/moused-"${dev##*/}".pid ] && continue -+ [ -e /var/run/moused-"${dev##*/}".pid ] && continue - moused_device=$dev - eindent - einfo "Using mouse on $moused_device" -@@ -37,7 +37,7 @@ start() - fi - - if [ -z "$moused_device" ]; then -- eend 1 "No mouse device found" -+ eend 1 "No mouse device found" - return 1 - fi - -@@ -49,7 +49,7 @@ start() - --pidfile "$pidfile" \ - -- $args -p "$moused_device" -I "$pidfile" - local retval=$? -- -+ - if [ $retval = 0 ]; then - local ttyv= - for ttyv in /dev/ttyv*; do -@@ -57,6 +57,6 @@ start() - : $((retval+= $?)) - done - fi -- -+ - eend $retval "Failed to start moused" - } -diff --git a/init.d/net.lo.in b/init.d/net.lo.in -index 30d0186..b194a23 100644 ---- a/init.d/net.lo.in -+++ b/init.d/net.lo.in -@@ -180,7 +180,7 @@ _gen_module_list() - ${update} || return 0 - fi - -- einfo "Caching network module dependencies" -+ einfo "Caching network module dependencies" - # Run in a subshell to protect the main script - ( - after() { -@@ -215,7 +215,7 @@ _gen_module_list() - - for MODULE in "${MODULESDIR}"/*.sh; do - sh -n "${MODULE}" || continue -- . "${MODULE}" || continue -+ . "${MODULE}" || continue - MODULE=${MODULE#${MODULESDIR}/} - MODULE=${MODULE%.sh} - eval ${MODULE}_depend -@@ -343,7 +343,7 @@ _load_modules() - - # Wrap our provides - local f= -- for f in pre_start start post_start; do -+ for f in pre_start start post_start; do - eval "${provides}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }" - done - -@@ -357,7 +357,7 @@ _load_modules() - *" ${mod} "*) - eval x=\$module_${mod}_provides - [ -z "${x}" ] && continue -- for f in pre_start start post_start; do -+ for f in pre_start start post_start; do - eval "${x}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }" - done - eval module_${x}_providedby="${mod}" -@@ -379,7 +379,7 @@ _load_modules() - MODULES="${MODULES}${MODULES:+ }${mod}" - done - else -- for mod in ${LIST}; do -+ for mod in ${LIST}; do - MODULES="${mod}${MODULES:+ }${MODULES}" - done - fi -@@ -395,7 +395,7 @@ _load_config() - config_index=0 - local IFS="$__IFS" - set -- ${config} -- -+ - # We should support a space separated array for cidr configs - if [ $# = 1 ]; then - unset IFS -@@ -415,7 +415,7 @@ _load_config() - config_0="127.0.0.1/8" - config_index=1 - fi -- else -+ else - if [ -z "$1" ]; then - ewarn "No configuration specified; defaulting to DHCP" - config_0="dhcp" -@@ -500,7 +500,7 @@ start() - fi - - _up 2>/dev/null -- -+ - for module in ${MODULES}; do - if [ "$(command -v "${module}_pre_start")" = "${module}_pre_start" ]; then - ${module}_pre_start || exit $? -@@ -527,7 +527,7 @@ start() - _load_config - config_index=0 - -- eval our_metric=\$metric_${IFVAR} -+ eval our_metric=\$metric_${IFVAR} - if [ -n "${our_metric}" ]; then - metric=${our_metric} - elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then -@@ -536,7 +536,7 @@ start() - - while true; do - eval config=\$config_${config_index} -- [ -z "${config}" ] && break -+ [ -z "${config}" ] && break - - set -- ${config} - ebegin "$1" -@@ -638,7 +638,7 @@ ${routes}" - if [ "$(command -v postup)" = "postup" ]; then - ebegin "Running postup" - eindent -- postup -+ postup - eoutdent - fi - -diff --git a/init.d/netmount.in b/init.d/netmount.in -index 88ce16f..3bdc63b 100644 ---- a/init.d/netmount.in -+++ b/init.d/netmount.in -@@ -39,7 +39,7 @@ depend() - } - - start() --{ -+{ - local myneed= myuse= pmap="portmap" nfsmounts= - [ -x @SYSCONFDIR@/init.d/rpcbind ] && pmap="rpcbind" - -diff --git a/init.d/network.in b/init.d/network.in -index 01e88ce..a563332 100644 ---- a/init.d/network.in -+++ b/init.d/network.in -@@ -222,7 +222,7 @@ start() - einfo "Starting network" - routeflush - if [ "$RC_UNAME" = "Linux" ]; then -- ifconfig lo 127.0.0.1 netmask 255.0.0.0 || cr=1 -+ ifconfig lo 127.0.0.1 netmask 255.0.0.0 || cr=1 - route add -net 127.0.0.0 netmask 255.0.0.0 \ - gw 127.0.0.1 reject 2>/dev/null - else -@@ -287,7 +287,7 @@ start() - [ $r != 0 ] - veend $? - fi -- -+ - if [ -n "$defaultroute" ]; then - ebegin "Setting default route $defaultroute" - route add default $defaultroute -diff --git a/init.d/pf.in b/init.d/pf.in -index 15c9fc5..a36df26 100644 ---- a/init.d/pf.in -+++ b/init.d/pf.in -@@ -44,7 +44,7 @@ reload() - { - ebegin "Reloading $name rules." - pfctl -q -n -f "$pf_conf" && \ -- { -+ { - # Flush everything but existing state entries that way when - # rules are read in, it doesn't break established connections. - pfctl -q -Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp -diff --git a/init.d/swap-blk.in b/init.d/swap-blk.in -index 3c1c52c..f7d4367 100644 ---- a/init.d/swap-blk.in -+++ b/init.d/swap-blk.in -@@ -13,11 +13,11 @@ start() - ebegin "Activating block swap devices" - swapctl -A -t blk >/dev/null - eend 0 # If swapon has nothing todo it errors, so always return 0 --} -+} - - stop() - { - ebegin "Deactivating block swap devices" - swapctl -U -t blk >/dev/null -- eend 0 -+ eend 0 - } -diff --git a/init.d/swap.in b/init.d/swap.in -index d99b9b8..a1a931f 100644 ---- a/init.d/swap.in -+++ b/init.d/swap.in -@@ -16,7 +16,7 @@ start() - *) swapon -a >/dev/null;; - esac - eend 0 # If swapon has nothing todo it errors, so always return 0 --} -+} - - stop() - { -@@ -31,5 +31,5 @@ stop() - NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;; - *) swapoff -a >/dev/null;; - esac -- eend 0 -+ eend 0 - } -diff --git a/init.d/syscons.in b/init.d/syscons.in -index cb584b3..ba22bf5 100644 ---- a/init.d/syscons.in -+++ b/init.d/syscons.in -@@ -15,13 +15,13 @@ start() { - done - eend $? - fi -- -+ - if [ -n "$keymap" ]; then - ebegin "Setting keymap to $keymap" - kbdcontrol -l $keymap </dev/console - eend $? - fi -- -+ - if [ -n "$keyrate" ]; then - ebegin "Setting keyrate to $keyrate" - kbdcontrol -r $keyrate </dev/console -@@ -40,7 +40,7 @@ start() { - done - eoutdent - fi -- -+ - if [ -n "$cursor" ]; then - ebegin "Setting cursor" - vidcontrol -c $cursor -diff --git a/init.d/termencoding.in b/init.d/termencoding.in -index 734d220..fea27ee 100644 ---- a/init.d/termencoding.in -+++ b/init.d/termencoding.in -@@ -31,5 +31,16 @@ start() - printf "\033%s" "$termencoding" >$ttydev$n - n=$(($n + 1)) - done -+ -+ # Save the encoding for use immediately at boot -+ if [ -w "$RC_LIBEXECDIR" ]; then -+ mkdir -p "$RC_LIBEXECDIR"/console -+ if yesno ${unicode:-${UNICODE}}; then -+ echo "" > "$RC_LIBEXECDIR"/console/unicode -+ else -+ rm -f "$RC_LIBEXECDIR"/console/unicode -+ fi -+ fi -+ - eend 0 - } -diff --git a/init.d/ttys.in b/init.d/ttys.in -index 178f182..b8a051d 100644 ---- a/init.d/ttys.in -+++ b/init.d/ttys.in -@@ -2,7 +2,7 @@ - # Copyright (c) 2008 Roy Marples <roy@marples.name> - # All rights reserved. Released under the 2-clause BSD license. - --depend() -+depend() - { - after fsck - keyword -prefix -@@ -13,7 +13,7 @@ start() - ebegin "Setting tty flags" - ttyflags -a - eend $? || return $? -- -+ - if [ -c /dev/ttyp0 ]; then - chmod 666 /dev/tty[p-uw-zP-T][0-9a-zA-Z] - fi -diff --git a/init.d/wscons.in b/init.d/wscons.in -index 3b18a24..916e27b 100644 ---- a/init.d/wscons.in -+++ b/init.d/wscons.in -@@ -27,10 +27,10 @@ start() - font) - cmd=$wsfld - [ "$arg2" != "-" ] && cmd="$cmd -w $arg2" -- [ "$arg3" != "-" ] && cmd="$cmd -h $arg3" -+ [ "$arg3" != "-" ] && cmd="$cmd -h $arg3" - [ "$arg4" != "-" ] && cmd="$cmd -e $arg4" - cmd="$cmd -N $arg1 $arg5" -- eval "$cmd" -+ eval "$cmd" - ;; - - screen) -diff --git a/local.d/Makefile b/local.d/Makefile -new file mode 100644 -index 0000000..7a7d31d ---- /dev/null -+++ b/local.d/Makefile -@@ -0,0 +1,6 @@ -+DIR= ${LOCALDIR} -+CONF= README -+ -+MK= ../mk -+include ${MK}/os.mk -+include ${MK}/scripts.mk -diff --git a/local.d/README b/local.d/README -new file mode 100644 -index 0000000..d3c1156 ---- /dev/null -+++ b/local.d/README -@@ -0,0 +1,9 @@ -+This directory should contain programs or scripts which are to be run -+when the local service is started or stopped. -+ -+If a file in this directory is executable and it has a .start extension, -+it will be run when the local service is started. If a file is -+executable and it has a .stop extension, it will be run when the local -+service is stopped. -+ -+All files are processed in lexical order. -diff --git a/mk/.mk b/mk/.mk -deleted file mode 100644 -index e69de29..0000000 -diff --git a/mk/cc.mk b/mk/cc.mk -index 2c912d5..06556f0 100644 ---- a/mk/cc.mk -+++ b/mk/cc.mk -@@ -5,9 +5,9 @@ CFLAGS?= -O2 - - # Default to using the C99 standard - CSTD?= c99 --_CSTD_SH= if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi --_CSTD!= ${_CSTD_SH} --CFLAGS+= ${_CSTD}$(shell ${_CSTD_SH}) -+ifneq (${CSTD},) -+CFLAGS+= -std=${CSTD} -+endif - - # Try and use some good cc flags if we're building from git - # We don't use -pedantic as it will warn about our perfectly valid -@@ -29,5 +29,5 @@ _CC_FLAGS_SH= for f in ${_CCFLAGS}; do \ - ${CC} $$f -S -xc -o /dev/null - ; \ - then printf "%s" "$$f "; fi \ - done; --_CC_FLAGS!= ${_CC_FLAGS_SH} --CFLAGS+= ${_CC_FLAGS}$(shell ${_CC_FLAGS_SH}) -+_CC_FLAGS:= $(shell ${_CC_FLAGS_SH}) -+CFLAGS+= ${_CC_FLAGS} -diff --git a/mk/debug.mk b/mk/debug.mk -index 67e9ad1..bc98b58 100644 ---- a/mk/debug.mk -+++ b/mk/debug.mk -@@ -3,14 +3,14 @@ - # All rights reserved. Released under the 2-clause BSD license. - - _RC_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-DRC_DEBUG";; esac --_RC_DEBUG!= ${_RC_DEBUG_SH} --CPPFLAGS+= ${_RC_DEBUG}$(shell ${_RC_DEBUG_SH}) -+_RC_DEBUG:= $(shell ${_RC_DEBUG_SH}) -+CPPFLAGS+= ${_RC_DEBUG} - - # Should we enable this with a different flag? - _LD_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-Wl,--rpath=../librc -Wl,--rpath=../libeinfo";; esac --_LD_DEBUG!= ${_LD_DEBUG_SH} --LDFLAGS+= ${_LD_DEBUG}$(shell ${_LD_DEBUG_SH}) -+_LD_DEBUG:= $(shell ${_LD_DEBUG_SH}) -+LDFLAGS+= ${_LD_DEBUG} - - _GGDB_SH= case "${DEBUG}" in "") echo "";; *) echo "-ggdb";; esac --_GGDB!= ${_GGDB_SH} --CFLAGS+= ${_GGDB}$(shell ${_GGDB_SH}) -+_GGDB:= $(shell ${_GGDB_SH}) -+CFLAGS+= ${_GGDB} -diff --git a/mk/depend-.mk b/mk/depend-.mk -deleted file mode 100644 -index 9d13b52..0000000 ---- a/mk/depend-.mk -+++ /dev/null -@@ -1,2 +0,0 @@ --# This space left intentionally blank because gmake does not load .depend --# by default -diff --git a/mk/depend-gmake.mk b/mk/depend-gmake.mk -deleted file mode 100644 -index 947843e..0000000 ---- a/mk/depend-gmake.mk -+++ /dev/null -@@ -1,3 +0,0 @@ --# Tell gmake to include the optional dependency file. --# This sucks, but I don't know any other way of portably making this work. ---include .depend -diff --git a/mk/depend.mk b/mk/depend.mk -index 067c1ef..44af378 100644 ---- a/mk/depend.mk -+++ b/mk/depend.mk -@@ -10,9 +10,4 @@ IGNOREFILES+= .depend - - depend: .depend extra_depend - --# Nasty hack. depend-.mk is a blank file, depend-gmake.mk has a gmake specific --# command to optionally include .depend. --# Someone should patch gmake to optionally include .depend if it exists. --_INC_DEP= $(shell if ${MAKE} --version | grep -q "^GNU "; then \ -- echo "gmake"; else echo ""; fi) --include ${MK}/depend-${_INC_DEP}.mk -+-include .depend -diff --git a/mk/dist.mk b/mk/dist.mk -index 24ce130..fb58edc 100644 ---- a/mk/dist.mk -+++ b/mk/dist.mk -@@ -9,14 +9,21 @@ DISTFILE?= ${DISTPREFIX}.tar.bz2 - CLEANFILES+= ${NAME}-*.tar.bz2 - - _SNAP_SH= date -u +%Y%m%d%H%M --_SNAP!= ${_SNAP_SH} --SNAP= ${_SNAP}$(shell ${_SNAP_SH}) -+_SNAP:= $(shell ${_SNAP_SH}) -+SNAP= ${_SNAP} - SNAPDIR= ${DISTPREFIX}-${SNAP} - SNAPFILE= ${SNAPDIR}.tar.bz2 - - dist: - git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE} - -+distcheck: dist -+ rm -rf ${DISTPREFIX} -+ tar xf ${DISTFILE} -+ MAKEFLAGS= $(MAKE) -C ${DISTPREFIX} -+ MAKEFLAGS= $(MAKE) -C ${DISTPREFIX} check -+ rm -rf ${DISTPREFIX} -+ - snapshot: - rm -rf /tmp/${SNAPDIR} - mkdir /tmp/${SNAPDIR} -diff --git a/mk/git.mk b/mk/git.mk -index 54a98ef..62cae5a 100644 ---- a/mk/git.mk -+++ b/mk/git.mk -@@ -4,5 +4,5 @@ _GITVER_SH= if git rev-parse --short HEAD >/dev/null 2>&1; then \ - else \ - echo ""; \ - fi --_GITVER!= ${_GITVER_SH} --GITVER= ${_GITVER}$(shell ${_GITVER_SH}) -+_GITVER:= $(shell ${_GITVER_SH}) -+GITVER= ${_GITVER} -diff --git a/mk/lib.mk b/mk/lib.mk -index 16c16a5..a5682dd 100644 ---- a/mk/lib.mk -+++ b/mk/lib.mk -@@ -38,7 +38,7 @@ ${SHLIB_NAME}: ${SOBJS} - @${ECHO} building shared library $@ - @rm -f $@ ${SHLIB_LINK} - @ln -fs $@ ${SHLIB_LINK} -- ${CC} ${LDFLAGS} -shared -Wl,-x \ -+ ${CC} ${CFLAGS} ${LDFLAGS} -shared -Wl,-x \ - -o $@ -Wl,-soname,${SONAME} \ - ${SOBJS} ${LDADD} - -diff --git a/mk/ncurses.mk b/mk/ncurses.mk -deleted file mode 100644 -index d93e8fb..0000000 ---- a/mk/ncurses.mk -+++ /dev/null -@@ -1,3 +0,0 @@ --LIBTERMCAP?= -lncurses --CPPFLAGS+= -DHAVE_TERMCAP --LDADD+= ${LIBTERMCAP} -diff --git a/mk/os.mk b/mk/os.mk -index 09f2aef..0cde8ae 100644 ---- a/mk/os.mk -+++ b/mk/os.mk -@@ -4,8 +4,8 @@ - # Generic definitions - - _OS_SH= uname -s --_OS!= ${_OS_SH} --OS?= ${_OS}$(shell ${_OS_SH}) -+_OS:= $(shell ${_OS_SH}) -+OS?= ${_OS} - include ${MK}/os-${OS}.mk - - RC_LIB= /$(LIBNAME)/rc -diff --git a/mk/pam.mk b/mk/pam.mk -index 65115d5..15ffb54 100644 ---- a/mk/pam.mk -+++ b/mk/pam.mk -@@ -1,6 +1,10 @@ -+ifeq (${MKPAM},pam) - LIBPAM?= -lpam - CPPFLAGS+= -DHAVE_PAM - LDADD+= ${LIBPAM} - - PAMDIR?= /etc/pam.d - PAMMODE?= 0644 -+else ifneq (${MKPAM},) -+$(error if MKPAM is defined, it must be "pam") -+endif -diff --git a/mk/prog.mk b/mk/prog.mk -index 33929fb..5bddf18 100644 ---- a/mk/prog.mk -+++ b/mk/prog.mk -@@ -15,8 +15,8 @@ _DYNLINK_SH= if test "${PREFIX}" = "" && test -e /libexec/ld.elf_so; then \ - else \ - echo ""; \ - fi --_DYNLINK!= ${_DYNLINK_SH} --LDFLAGS+= ${_DYNLINK}$(shell ${_DYNLINK_SH}) -+_DYNLINK:= $(shell ${_DYNLINK_SH}) -+LDFLAGS+= ${_DYNLINK} - LDFLAGS+= -Wl,-rpath=${PREFIX}/${LIBNAME} - LDFLAGS+= ${PROGLDFLAGS} - -@@ -28,7 +28,7 @@ all: depend ${PROG} - ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ - - ${PROG}: ${SCRIPTS} ${OBJS} -- ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} -+ ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} - - clean: - rm -f ${CLEANFILES} -diff --git a/mk/scripts.mk b/mk/scripts.mk -index bd7ec6b..3517aab 100644 ---- a/mk/scripts.mk -+++ b/mk/scripts.mk -@@ -8,11 +8,11 @@ include ${MK}/os.mk - OBJS+= ${SRCS:.in=} - - _PKG_SED_SH= if test "${PREFIX}" = "${PKG_PREFIX}"; then echo "-e 's:@PKG_PREFIX@::g'"; else echo "-e 's:@PKG_PREFIX@:${PKG_PREFIX}:g'"; fi --_PKG_SED!= ${_PKG_SED_SH} -+_PKG_SED:= $(shell ${_PKG_SED_SH}) - _LCL_SED_SH= if test "${PREFIX}" = "${LOCAL_PREFIX}"; then echo "-e 's:@LOCAL_PREFIX@::g'"; else echo "-e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g'"; fi --_LCL_SED!= ${_LCL_SED_SH} -+_LCL_SED:= $(shell ${_LCL_SED_SH}) - --SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' ${_PKG_SED}$(shell ${_PKG_SED_SH}) ${_LCL_SED}$(shell ${_LCL_SED_SH}) -+SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' ${_PKG_SED} ${_LCL_SED} - - # Tweak our shell scripts - .SUFFIXES: .sh.in .in -diff --git a/mk/sys.mk b/mk/sys.mk -index e22731b..b68afdb 100644 ---- a/mk/sys.mk -+++ b/mk/sys.mk -@@ -12,8 +12,8 @@ SH= /bin/sh - - PREFIX?= - _UPREFIX_SH= case "${PREFIX}" in "") echo /usr;; *) echo "${PREFIX}";; esac --_UPREFIX!= ${_UPREFIX_SH} --UPREFIX= ${_UPREFIX}$(shell ${_UPREFIX_SH}) -+_UPREFIX:= $(shell ${_UPREFIX_SH}) -+UPREFIX= ${_UPREFIX} - LOCAL_PREFIX= /usr/local - - PICFLAG?= -fPIC -@@ -21,6 +21,7 @@ PICFLAG?= -fPIC - SYSCONFDIR?= ${PREFIX}/etc - INITDIR?= ${SYSCONFDIR}/init.d - CONFDIR?= ${SYSCONFDIR}/conf.d -+LOCALDIR?= ${SYSCONFDIR}/local.d - - BINDIR?= ${PREFIX}/sbin - BINMODE?= 0755 -@@ -29,8 +30,8 @@ INCDIR?= ${UPREFIX}/include - INCMODE?= 0444 - - _LIBNAME_SH= case `readlink /lib` in /lib64|lib64) echo "lib64";; *) echo "lib";; esac --_LIBNAME!= ${_LIBNAME_SH} --LIBNAME?= ${_LIBNAME}$(shell ${_LIBNAME_SH}) -+_LIBNAME:= $(shell ${_LIBNAME_SH}) -+LIBNAME?= ${_LIBNAME} - LIBDIR?= ${UPREFIX}/${LIBNAME} - LIBMODE?= 0444 - SHLIBDIR?= ${PREFIX}/${LIBNAME} -diff --git a/mk/termcap.mk b/mk/termcap.mk -index 7a603e3..b716276 100644 ---- a/mk/termcap.mk -+++ b/mk/termcap.mk -@@ -1,3 +1,11 @@ -+ifeq (${MKTERMCAP},ncurses) -+LIBTERMCAP?= -lncurses -+CPPFLAGS+= -DHAVE_TERMCAP -+LDADD+= ${LIBTERMCAP} -+else ifeq (${MKTERMCAP},termcap) - LIBTERMCAP?= -ltermcap - CPPFLAGS+= -DHAVE_TERMCAP - LDADD+= ${LIBTERMCAP} -+else ifneq (${MKTERMCAP},) -+$(error If MKTERMCAP is defined, it must be ncurses or termcap) -+endif -diff --git a/net/Makefile.Linux b/net/Makefile.Linux -index 7006d74..f7fb087 100644 ---- a/net/Makefile.Linux -+++ b/net/Makefile.Linux -@@ -1,7 +1,7 @@ - SRCS+= iwconfig.sh.in - INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \ -- ccwgroup.sh clip.sh iproute2.sh ifplugd.sh ip6to4.sh ipppd.sh \ -- iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ -+ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \ -+ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \ - vlan.sh - - .SUFFIXES: .sh.Linux.in -diff --git a/net/apipa.sh b/net/apipa.sh -index f4e5f73..0ca3bda 100644 ---- a/net/apipa.sh -+++ b/net/apipa.sh -@@ -21,7 +21,7 @@ apipa_start() - local iface="$1" i1= i2= addr= i=0 - - _exists true || return 1 -- -+ - einfo "Searching for free addresses in 169.254.0.0/16" - eindent - -diff --git a/net/arping.sh b/net/arping.sh -index 307e8ef..b04f05d 100644 ---- a/net/arping.sh -+++ b/net/arping.sh -@@ -19,7 +19,7 @@ arping_address() - esac - - # We need to bring the interface up to test -- _exists "${iface}" || return 1 -+ _exists "${iface}" || return 1 - _up "${iface}" - - eval w=\$arping_wait_${IFVAR} -@@ -43,7 +43,7 @@ arping_address() - sed -n -e 'y/abcdef/ABCDEF/' -e 's/.*\[\([^]]*\)\].*/\1/p')" - fi - [ -z "${foundmac}" ] && return 1 -- -+ - if [ -n "${mac}" ]; then - if [ "${mac}" != "${foundmac}" ]; then - vewarn "Found ${ip} but MAC ${foundmac} does not match" -@@ -74,7 +74,7 @@ arping_start() - fi - - eindent -- -+ - for x in ${gateways}; do - local IFS=, - set -- ${x} -@@ -119,7 +119,7 @@ arping_start() - fi - done - unset IFS -- -+ - _load_config - return 0 - fi -diff --git a/net/bonding.sh b/net/bonding.sh -index 415306c..209d4f0 100644 ---- a/net/bonding.sh -+++ b/net/bonding.sh -@@ -115,7 +115,7 @@ bonding_pre_start() - - bonding_stop() - { -- _is_bond || return 0 -+ _is_bond || return 0 - - local slaves= s= - slaves=$( \ -diff --git a/net/br2684ctl.sh b/net/br2684ctl.sh -index 3eea0d9..77dafc9 100644 ---- a/net/br2684ctl.sh -+++ b/net/br2684ctl.sh -@@ -17,7 +17,7 @@ br2684ctl_depend() - } - - _config_vars="$_config_vars bridge bridge_add brctl" -- -+ - br2684ctl_pre_start() - { - local opts= -@@ -40,7 +40,7 @@ br2684ctl_pre_start() - return 1 - ;; - esac -- -+ - einfo "Starting RFC 2684 Bridge control on ${IFACE}" - start-stop-daemon --start --exec $(_br2684ctl) --background \ - --make-pidfile --pidfile "/var/run/br2684ctl-${IFACE}.pid" \ -@@ -52,7 +52,7 @@ br2684ctl_post_stop() - { - local pidfile="/var/run/br2684ctl-${IFACE}.pid" - [ -e "${pidfile}" ] || return 0 -- -+ - einfo "Stopping RFC 2684 Bridge control on ${IFACE}" - start-stop-daemon --stop --quiet --pidfile "${pidfile}" - eend $? -diff --git a/net/bridge.sh b/net/bridge.sh -index c0172ed..91e68d6 100644 ---- a/net/bridge.sh -+++ b/net/bridge.sh -@@ -38,15 +38,15 @@ bridge_pre_start() - local opts="$(_get_array "brctl_${IFVAR}")" - # brif is used for dynamic add - eval brif=\$bridge_add_${IFVAR} -- -+ - # we need a way to if the bridge exists in a variable name, not just the - # contents of a variable. Eg if somebody has only bridge_add_eth0='br0', - # with no other lines mentioning br0. - eval bridge_unset=\${bridge_${IFVAR}-y\} - eval brctl_unset=\${brctl_${IFVAR}-y\} -- -- if [ -z "${brif}" -a "${brctl_unset}" == 'y' ]; then -- if [ -z "${ports}" -a "${bridge_unset}" == "y" ]; then -+ -+ if [ -z "${brif}" -a "${brctl_unset}" = 'y' ]; then -+ if [ -z "${ports}" -a "${bridge_unset}" = "y" ]; then - #eerror "Misconfigured static bridge detected (see net.example)" - return 0 - fi -@@ -186,6 +186,6 @@ bridge_post_stop() - brctl delbr "${iface}" - eend $? - fi -- -+ - return 0 - } -diff --git a/net/ccwgroup.sh b/net/ccwgroup.sh -index cf08943..6fcba1d 100644 ---- a/net/ccwgroup.sh -+++ b/net/ccwgroup.sh -@@ -5,7 +5,7 @@ _config_vars="$_config_vars ccwgroup" - - ccwgroup_depend() - { -- before interface -+ before interface - } - - ccwgroup_pre_start() -@@ -42,7 +42,7 @@ ccwgroup_pre_stop() - { - # Erase any existing ccwgroup to be safe - service_set_value ccwgroup_device "" -- -+ - [ ! -L /sys/class/net/"${FACE}"/driver ] && return 0 - local driver="$(readlink /sys/class/net/"${IFACE}"/driver)" - case "${diver}" in -@@ -59,7 +59,7 @@ ccwgroup_post_stop() - { - local device="$(service_get_value ccwgroup_device)" - [ -z "${device}" ] && return 0 -- -+ - einfo "Disabling ccwgroup on ${iface}" - echo "0" >/sys/devices/qeth/"${device}"/online - echo "1" >/sys/devices/qeth/"${device}"/ungroup -diff --git a/net/clip.sh b/net/clip.sh -index 3cb84e7..35efa3f 100644 ---- a/net/clip.sh -+++ b/net/clip.sh -@@ -97,7 +97,7 @@ clip_pre_start() - return 1 - fi - fi -- -+ - local started_here= - if ! are_atmclip_svcs_running; then - atmclip_svcs_start || return 1 -diff --git a/net/ethtool.sh b/net/ethtool.sh -new file mode 100644 -index 0000000..64b44a6 ---- /dev/null -+++ b/net/ethtool.sh -@@ -0,0 +1,54 @@ -+# Copyright (c) 2011 by Gentoo Foundation -+# All rights reserved. Released under the 2-clause BSD license. -+ -+_ethtool() { -+ echo /usr/sbin/ethtool -+} -+ -+ethtool_depend() -+{ -+ program $(_ethtool) -+ before interface -+} -+ -+# This is just to trim whitespace, do not add any quoting! -+_trim() { -+ echo $* -+} -+ -+ethtool_pre_start() { -+ local order opt OFS="${OIFS}" -+ eval order=\$ethtool_order_${IFVAR} -+ [ -z "${order}" ] && eval order=\$ethtool_order -+ [ -z "${order}" ] && order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple" -+ # ethtool options not used: --driver, --register-dump, --eeprom-dump, --negotiate, --test, --statistics -+ eindent -+ for opt in ${order} ; do -+ local args -+ eval args=\$ethtool_${opt//-/_}_${IFVAR} -+ -+ # Skip everything if no arguments -+ [ -z "${args}" ] && continue -+ -+ # Split on \n -+ local IFS="$__IFS" -+ -+ for p in ${args} ; do -+ IFS="${OIFS}" -+ local args_pretty="$(_trim "${p}")" -+ # Do nothing if empty -+ [ -z "${args_prety}" ] && continue -+ args_pretty="--${opt} $IFACE ${args_pretty}" -+ args="--${opt} $IFACE ${args}" -+ ebegin "ethtool ${args_pretty}" -+ $(_ethtool) ${args} -+ rc=$? -+ eend $rc "ethtool exit code $rc" -+ # TODO: ethtool has MANY different exit codes, with no -+ # documentation as to which ones are fatal or not. For now we -+ # simply print the exit code and don't stop the start sequence. -+ done -+ IFS="${OIFS}" -+ done -+ eoutdent -+} -diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in -index 74fcc9f..f5c2064 100644 ---- a/net/ifconfig.sh.Linux.in -+++ b/net/ifconfig.sh.Linux.in -@@ -139,7 +139,7 @@ _add_address() - return 0 - fi - -- case "$1" in -+ case "$1" in - *:*) ifconfig "${IFACE}" inet6 add "$@"; return $?;; - esac - -@@ -225,7 +225,7 @@ _delete_addresses() - while true; do - local addr=$(_get_inet_address) - [ -z "${addr}" ] && break -- -+ - if [ "${addr}" = "127.0.0.1/8" ]; then - # Don't delete the loopback address - [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] && break -@@ -246,7 +246,7 @@ _delete_addresses() - einfo "${addr}" - ifconfig "${IFACE}" inet6 del "${addr}" - done -- -+ - return 0 - } - -diff --git a/net/ifplugd.sh b/net/ifplugd.sh -index 5831720..9f6c884 100644 ---- a/net/ifplugd.sh -+++ b/net/ifplugd.sh -@@ -57,7 +57,7 @@ ifplugd_pre_start() - ewarn "WARNING: infinite timeout set for ${IFACE} to come up" - elif [ ${timeout} -lt 0 ]; then - einfo "Backgrounding ..." -- exit 1 -+ exit 1 - fi - - veinfo "Waiting for ${IFACE} to be marked as started" -@@ -84,7 +84,7 @@ ifplugd_stop() - - local pidfile="/var/run/ifplugd.${IFACE}.pid" - [ ! -e "${pidfile}" ] && return 0 -- -+ - ebegin "Stopping ifplugd on ${IFACE}" - start-stop-daemon --stop --quiet --exec /usr/sbin/ifplugd \ - --pidfile "${pidfile}" --signal QUIT -diff --git a/net/ifwatchd.sh b/net/ifwatchd.sh -index d9da15e..4e6b1c6 100644 ---- a/net/ifwatchd.sh -+++ b/net/ifwatchd.sh -@@ -50,7 +50,7 @@ ifwatchd_stop() - -- -c "${RC_LIBEXECDIR}/sh/ifwatchd-carrier.sh" \ - -n "${RC_LIBEXECDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ - || return 0 -- -+ - ebegin "Stopping ifwatchd on" "${IFACE}" - start-stop-daemon --stop --exec /usr/sbin/ifwatchd \ - -- -c "${RC_LIBEXECDIR}/sh/ifwatchd-carrier.sh" \ -diff --git a/net/ip6to4.sh b/net/ip6to4.sh -index 6bddb7e..2349429 100644 ---- a/net/ip6to4.sh -+++ b/net/ip6to4.sh -@@ -56,7 +56,7 @@ ip6to4_start() - [ ${i} -lt 32 ] && continue - ;; - esac -- -+ - veinfo "IPv4 address on ${host}: ${ip}/${subnet}" - local ipa= ip6= IFS="${IFS}." - for i in ${ip}; do -@@ -87,7 +87,7 @@ ip6to4_start() - eend $? || return 1 - _up - fi -- -+ - # Now apply our config - eval config_${config_index}=\'"${new}"\' - config_index=$((${config_index} - 1)) -diff --git a/net/iproute2.sh b/net/iproute2.sh -index 1cd4f42..a2e9db7 100644 ---- a/net/iproute2.sh -+++ b/net/iproute2.sh -@@ -117,14 +117,14 @@ _add_address() - shift; shift; shift - set -- "${one}/$(_netmask2cidr "${three}")" "$@" - fi -- -+ - # tunnel keyword is 'peer' in iproute2, but 'pointopoint' in ifconfig. - if [ "$2" = "pointopoint" ]; then - local one="$1" - shift; shift - set -- "${one}" "peer" "$@" - fi -- -+ - # Always scope lo addresses as host unless specified otherwise - if [ "${IFACE}" = "lo" ]; then - set -- "$@" "scope" "host" -@@ -162,7 +162,7 @@ _add_route() - set -- "${one}" "${two}" via "$@" - fi - -- local cmd= have_metric=false -+ local cmd= have_metric=false - while [ -n "$1" ]; do - case "$1" in - metric) cmd="${cmd} $1"; have_metric=true;; -@@ -221,7 +221,7 @@ _ip_rule_runner() { - local IFS="$__IFS" - for ru in $rules ; do - unset IFS -- ruN="$(trim "${ru}")" -+ ruN="$(_trim "${ru}")" - [ -z "${ruN}" ] && continue - vebegin "${cmd} ${ruN}" - ip rule ${cmd} ${ru} -@@ -239,9 +239,14 @@ iproute2_pre_start() - if [ -n "${tunnel}" ]; then - # Set our base metric to 1000 - metric=1000 -+ # Bug#347657: If the mode is 'ipip6' or 'ip6ip6', the -6 must be passed -+ # to iproute2 during tunnel creation. -+ local ipproto='' -+ [ "${tunnel##mode ipip6}" != "${tunnel}" ] && ipproto='-6' -+ [ "${tunnel##mode ip6ip6}" != "${tunnel}" ] && ipproto='-6' - - ebegin "Creating tunnel ${IFVAR}" -- ip tunnel add ${tunnel} name "${IFACE}" -+ ip ${ipproto} tunnel add ${tunnel} name "${IFACE}" - eend $? || return 1 - _up - fi -diff --git a/net/iwconfig.sh.BSD.in b/net/iwconfig.sh.BSD.in -index ec88e66..f94246b 100644 ---- a/net/iwconfig.sh.BSD.in -+++ b/net/iwconfig.sh.BSD.in -@@ -477,7 +477,7 @@ iwconfig_defaults() - #ifconfig "${iface}" txpower 100 2>/dev/null - ifconfig "${IFACE}" bssid - - ifconfig "${IFACE}" ssid - -- ifconfig "${IFACE}" wepkey 1:- wepkey 2:- wepkey 3:- wepkey 4:- -+ ifconfig "${IFACE}" wepkey 1:- wepkey 2:- wepkey 3:- wepkey 4:- - ifconfig "${IFACE}" authmode open - ifconfig "${IFACE}" -mediaopt adhoc - ifconfig "${IFACE}" -mediaopt hostap -@@ -563,8 +563,8 @@ iwconfig_pre_start() - return 0 - fi - -- iwconfig_defaults -- iwconfig_user_config -+ iwconfig_defaults -+ iwconfig_user_config - - # Set the base metric to be 2000 - metric=2000 -diff --git a/net/iwconfig.sh.Linux.in b/net/iwconfig.sh.Linux.in -index 28cdd23..600ffe7 100644 ---- a/net/iwconfig.sh.Linux.in -+++ b/net/iwconfig.sh.Linux.in -@@ -47,7 +47,7 @@ _get_ssid() - - _get_ap_mac_address() - { -- local mac="$(iwgetid --raw --ap "${IFACE}")" -+ local mac="$(iwgetid --raw --ap "${IFACE}")" - case "${mac}" in - "00:00:00:00:00:00") return 1;; - "44:44:44:44:44:44") return 1;; -@@ -163,7 +163,7 @@ iwconfig_setup_specific() - local key=$(iwconfig_get_wep_key) - - iwconfig_set_mode "${mode}" -- -+ - # Now set the key - if ! eval iwconfig "${IFACE}" key "${key}"; then - if [ "${key}" != "off" ]; then -@@ -185,10 +185,10 @@ iwconfig_setup_specific() - ewarn "${IFACE} does not support setting the channel to \"${channel:-3}\"" - return 1 - fi -- -+ - # Finally apply the user Config - iwconfig_user_config -- -+ - iwconfig_report - return 0 - } -@@ -226,7 +226,7 @@ iwconfig_wait_for_association() - /proc/net/wireless)" != "0" ] && return 0 - fi - fi -- -+ - sleep 1 - [ ${timeout} -eq 0 ] && continue - i=$((${i} + 1)) -@@ -281,7 +281,7 @@ iwconfig_associate() - iwconfig "${IFACE}" freq "${freq}" - fi - [ -n "${mac}" ] && iwconfig "${IFACE}" ap "${mac}" -- -+ - # Finally apply the user Config - iwconfig_user_config - -@@ -377,10 +377,10 @@ iwconfig_scan() - for line; do - case "${line}" in - *Address:*) -- APS=$((${APS} + 1)) -+ APS=$((${APS} + 1)) - eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\"" - eval QUALITY_${APS}=0 -- ;; -+ ;; - *ESSID:*) - x=${line#*\"} - x=${x%*\"} -@@ -455,7 +455,7 @@ iwconfig_scan() - eval a=\$QUALITY_${i} - eval b=\$QUALITY_${k} - local u=${k} -- # We need to split this into two tests, otherwise bash errors -+ # We need to split this into two tests, otherwise bash errors - [ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i} - unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u} - fi -@@ -581,7 +581,7 @@ iwconfig_connect_not_preferred() - break - fi - done -- -+ - if ! ${pref}; then - SSID=${e} - eval mode=\$MODE_${i} -@@ -711,10 +711,10 @@ iwconfig_pre_start() - # wait if our scan returns nothing - LC_ALL=C iwconfig "${IFACE}" | sed -e '1d' | grep -q "Tx-Power=off" - local txpowerwasoff=$? -- -+ - iwconfig_defaults - iwconfig_user_config -- -+ - # Set the base metric to be 2000 - metric=2000 - -diff --git a/net/macchanger.sh b/net/macchanger.sh -index 32bbdc9..9126d30 100644 ---- a/net/macchanger.sh -+++ b/net/macchanger.sh -@@ -24,7 +24,7 @@ macchanger_pre_start() - - # The interface needs to be up for macchanger to work most of the time - _down -- -+ - mac=$(echo "${mac}" | tr '[:upper:]' '[:lower:]') - local hex="[0-9a-f][0-9a-f]" - case "${mac}" in -diff --git a/net/netplugd.sh b/net/netplugd.sh -index 0f46643..8f36ef2 100644 ---- a/net/netplugd.sh -+++ b/net/netplugd.sh -@@ -59,7 +59,7 @@ netplugd_pre_start() - ewarn "WARNING: infinite timeout set for ${IFACE} to come up" - elif [ ${timeout} -lt 0 ]; then - einfo "Backgrounding ..." -- exit 1 -+ exit 1 - fi - - veinfo "Waiting for ${IFACE} to be marked as started" -@@ -86,7 +86,7 @@ netplugd_stop() - - local pidfile="/var/run/netplugd-${IFACE}.pid" - [ ! -e "${pidfile}" ] && return 0 -- -+ - ebegin "Stopping netplug on" "${IFACE}" - start-stop-daemon --stop --quiet --exec /sbin/netplugd \ - --pidfile "${pidfile}" -diff --git a/net/pppd.sh b/net/pppd.sh -index a8c8882..c7cfa44 100644 ---- a/net/pppd.sh -+++ b/net/pppd.sh -@@ -31,7 +31,7 @@ pppd_pre_start() - if yesno ${IN_BACKGROUND}; then - local config= - eval config=\$config_${IFVAR} -- # If no config for ppp then don't default to DHCP -+ # If no config for ppp then don't default to DHCP - if [ -z "${config}" ]; then - eval config_${IFVAR}=null - fi -@@ -39,7 +39,7 @@ pppd_pre_start() - fi - - local link= i= unit="${IFACE#ppp}" opts= -- -+ - # PPP requires a link to communicate over - normally a serial port - # PPPoE communicates over Ethernet - # PPPoA communicates over ATM -@@ -92,7 +92,7 @@ pppd_pre_start() - && [ -n "${password}" -o -z "${passwordset}" ]; then - opts="plugin passwordfd.so ${opts} passwordfd 0" - fi -- -+ - if ! ${hasdefaultmetric}; then - local m= - eval m=\$metric_${IFVAR} -@@ -122,7 +122,7 @@ pppd_pre_start() - - # Set unit - opts="unit ${unit} ${opts}" -- -+ - # Setup connect script - local chatprog="/usr/sbin/chat -e -E -v" phone= - eval phone=\$phone_number_${IFVAR} -diff --git a/net/pump.sh b/net/pump.sh -index d03e2c8..ecceff0 100644 ---- a/net/pump.sh -+++ b/net/pump.sh -@@ -35,7 +35,7 @@ pump_start() - - ebegin "Running pump" - eval pump "${args}" -- eend $? || return 1 -+ eend $? || return 1 - - _show_address - return 0 -@@ -48,7 +48,7 @@ pump_stop() - start-stop-daemon --quiet --test --stop --exec /sbin/pump || return 0 - - # Check that pump is running on the interface -- if ! pump --status --interface "${IFACE}" >/dev/null 2>&1; then -+ if ! pump --status --interface "${IFACE}" >/dev/null 2>&1; then - return 0 - fi - -diff --git a/net/system.sh b/net/system.sh -index b22eee6..6680a7d 100644 ---- a/net/system.sh -+++ b/net/system.sh -@@ -80,10 +80,10 @@ _system_nis() - - eval servers=\$nis_servers_${IFVAR} - [ -z "${servers}" ] && servers=${nis_servers} -- -+ - eval domain=\$nis_domain_${IFVAR} - [ -z "${domain}" ] && domain=${nis_domain} -- -+ - [ -z "${servers}" -a -z "${domain}" ] && return 0 - - buffer="# Generated by net-scripts for interface ${iface}\n" -@@ -110,8 +110,8 @@ _system_nis() - system_pre_start() - { - _system_dns -- _system_ntp -- _system_nis -+ _system_ntp -+ _system_nis - - return 0 - } -diff --git a/net/vlan.sh b/net/vlan.sh -index c245051..1d50d4f 100644 ---- a/net/vlan.sh -+++ b/net/vlan.sh -@@ -1,9 +1,18 @@ - # Copyright (c) 2007-2008 Roy Marples <roy@marples.name> - # All rights reserved. Released under the 2-clause BSD license. - -+_ip() -+{ -+ if [ -x /bin/ip ]; then -+ echo /bin/ip -+ else -+ echo /sbin/ip -+ fi -+} -+ - vlan_depend() - { -- program /sbin/vconfig -+ program $(_ip) - after interface - before dhcp - } -@@ -36,31 +45,12 @@ _check_vlan() - - vlan_pre_start() - { -- local vc="$(_get_array "vconfig_${IFVAR}")" -- [ -z "${vc}" ] && return 0 -- -- _check_vlan || return 1 -- _exists || return 1 -- -- local v= x= e= -- local IFS="$__IFS" -- for v in ${vc}; do -- unset IFS -- case "${v}" in -- set_name_type" "*) x=${v};; -- *) -- set -- ${v} -- x="$1 ${IFACE}" -- shift -- x="${x} $@" -- ;; -- esac -- -- e="$(vconfig ${x} 2>&1 1>/dev/null)" -- [ -z "${e}" ] && continue -- eerror "${e}" -+ local vconfig -+ eval vconfig=\$vconfig_${IFVAR} -+ if [ -n "${vconfig}" ]; then -+ eerror "You must convert your vconfig_ VLAN entries to vlan${N} entries." - return 1 -- done -+ fi - } - - vlan_post_start() -@@ -68,14 +58,26 @@ vlan_post_start() - local vlans= - eval vlans=\$vlans_${IFVAR} - [ -z "${vlans}" ] && return 0 -- -+ - _check_vlan || return 1 - _exists || return 1 - -- local vlan= e= s= -+ local vlan= e= s= vname= vflags= vingress= vegress= - for vlan in ${vlans}; do - einfo "Adding VLAN ${vlan} to ${IFACE}" -- e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)" -+ # We need to gather all interface configuration options -+ # 1) naming. Default to the standard "${IFACE}.${vlan}" but it can be anything -+ eval vname=\$vlan${vlan}_name -+ [ -z "${vname}" ] && vname="${IFACE}.${vlan}" -+ # 2) flags -+ eval vflags=\$vlan${vlan}_flags -+ # 3) ingress/egress map -+ eval vingress=\$vlan${vlan}_ingress -+ [ -z "${vingress}" ] || vingress="ingress-qos-map ${vingress}" -+ eval vegress=\$vlan${vlan}_egress -+ [ -z "${vegress}" ] || vegress="egress-qos-map ${vegress}" -+ -+ e="$(ip link add link "${IFACE}" name "${vname}" type vlan id "${vlan}" ${vflags} ${vingress} ${vegress} 2>&1 1>/dev/null)" - if [ -n "${e}" ]; then - eend 1 "${e}" - continue -@@ -95,7 +97,7 @@ vlan_post_start() - start - ) || mark_service_stopped "net.${ifname}" - done -- -+ - return 0 - } - -@@ -110,7 +112,7 @@ vlan_post_stop() - stop - ) && { - mark_service_stopped "net.${vlan}" -- vconfig rem "${vlan}" >/dev/null -+ ip link delete "${vlan}" type vlan >/dev/null - } - done - -diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh -index 379e615..c619f99 100644 ---- a/net/wpa_supplicant.sh -+++ b/net/wpa_supplicant.sh -@@ -149,7 +149,7 @@ wpa_supplicant_pre_start() - if [ -z "${wpac}" ]; then - if service_started devd; then - ebegin "Backgrounding ..." -- exit 1 -+ exit 1 - fi - return 0 - fi -@@ -167,7 +167,7 @@ wpa_supplicant_pre_start() - -P "/var/run/wpa_cli-${IFACE}.pid" -B - if eend $?; then - ebegin "Backgrounding ..." -- exit 1 -+ exit 1 - fi - - # wpa_cli failed to start? OK, error here -diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in -index 0e581c1..9b04557 100644 ---- a/sh/init.sh.Linux.in -+++ b/sh/init.sh.Linux.in -@@ -34,7 +34,7 @@ mount_svcdir() - [ $? -eq 0 ] && return 0 - fi - fi -- -+ - if grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then - fs="ramfs" - # ramfs has no special options -@@ -65,19 +65,27 @@ mount_svcdir() - # By default VServer already has /proc mounted, but OpenVZ does not! - # However, some of our users have an old proc image in /proc - # NFC how they managed that, but the end result means we have to test if --# /proc actually works or not. We to this by comparing uptime to one a second --# ago -+# /proc actually works or not. We to this by comparing two reads of -+# /proc/self/stat. They will not match, because at least the minor fault count -+# field (field 10) should have changed. -+# -+# We can use any file here that fills the following requirements: -+# - changes between sequential reads -+# - is world-readable (not blocked in hardened kernel) -+# - Is only a single line (ergo entire check is doable with no forks) - mountproc=true --if [ -e /proc/uptime ]; then -- up="$(cat /proc/uptime)" -- sleep 1 -- if [ "$up" = "$(cat /proc/uptime)" ]; then -+f=/proc/self/stat -+if [ -e $f ]; then -+ exec 9<$f ; read a <&9 ; exec 9<&- -+ exec 9<$f ; read b <&9 ; exec 9<&- -+ if [ "$a" = "$b" ]; then - eerror "You have cruft in /proc that should be deleted" - else - einfo "/proc is already mounted, skipping" - mountproc=false - fi - fi -+unset a b f - - if $mountproc; then - procfs="proc" -diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in -index 947c2f7..229d1ee 100644 ---- a/sh/runscript.sh.in -+++ b/sh/runscript.sh.in -@@ -111,7 +111,7 @@ start() - [ -n "$command" ] || return 0 - local _background= - ebegin "Starting ${name:-$RC_SVCNAME}" -- if yesno "${command_background}"; then -+ if yesno "${command_background}"; then - _background="--background --pidfile" - fi - if yesno "$start_inactive"; then -@@ -252,7 +252,7 @@ while [ -n "$1" ]; do - eerror "$RC_SVCNAME: function \`$1' defined but does not exist" - exit 1 - fi -- fi -+ fi - fi - done - eerror "$RC_SVCNAME: unknown function \`$1'" -diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile -index 1569f8f..b93b5e5 100644 ---- a/src/libeinfo/Makefile -+++ b/src/libeinfo/Makefile -@@ -10,4 +10,4 @@ MK= ../../mk - include ${MK}/lib.mk - include ${MK}/cc.mk - include ${MK}/debug.mk --include ${MK}/${MKTERMCAP}.mk -+include ${MK}/termcap.mk -diff --git a/src/librc/Makefile b/src/librc/Makefile -index d3f9cc4..574aa2a 100644 ---- a/src/librc/Makefile -+++ b/src/librc/Makefile -@@ -19,21 +19,26 @@ SED_CMD= -e 's:@PREFIX@:${PREFIX}:g' - SED_CMD+= -e 's:@LIB@:${LIBNAME}:g' - SED_CMD+= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' - SED_CMD+= -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' --_PKG_PREFIX_SH= if test -n "${PKG_PREFIX}" && test "${PKG_PREFIX}" != "/" && test "${PKG_PREFIX}" != "${PREFIX}"; then \ -- echo "-e 's:@PKG_PREFIX@:${PKG_PREFIX}:g'"; \ -- else \ -- echo "-e 's:.*@PKG_PREFIX@.*:\#undef RC_PKG_PREFIX:g'"; \ -- fi --_PKG_PREFIX!= ${_PKG_PREFIX_SH} --SED_CMD+= ${_PKG_PREFIX}$(shell ${_PKG_PREFIX_SH}) -- --_LCL_PREFIX_SH= if test -n "${LOCAL_PREFIX}" && test "${LOCAL_PREFIX}" != "/" && test "${LOCAL_PREFIX}" != "${PREFIX}"; then \ -- echo "-e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g'"; \ -- else \ -- echo "-e 's:@LOCAL_PREFIX@::g'"; \ -- fi --_LCL_PREFIX!= ${_LCL_PREFIX_SH} --SED_CMD+= ${_LCL_PREFIX}$(shell ${_LCL_PREFIX_SH}) -+ -+_PKG_PREFIX= -e 's:.*@PKG_PREFIX@.*:\#undef RC_PKG_PREFIX:g' -+ifneq (${PKG_PREFIX},) -+ifneq (${PKG_PREFIX},/) -+ifneq (${PKG_PREFIX},${PREFIX}) -+_PKG_PREFIX= -e 's:@PKG_PREFIX@:${PKG_PREFIX}:g' -+endif -+endif -+endif -+SED_CMD+= ${_PKG_PREFIX} -+ -+_LCL_PREFIX= -e 's:@LOCAL_PREFIX@::g' -+ifneq (${LOCAL_PREFIX},) -+ifneq (${LOCAL_PREFIX},/) -+ifneq (${LOCAL_PREFIX},${PREFIX}) -+_LCL_PREFIX= -e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g' -+endif -+endif -+endif -+SED_CMD+= ${_LCL_PREFIX} - - .SUFFIXES: .h.in .h - .h.in.h: -diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c -index 1bedf29..dde62f9 100644 ---- a/src/librc/librc-daemon.c -+++ b/src/librc/librc-daemon.c -@@ -40,7 +40,7 @@ pid_is_exec(pid_t pid, const char *exec) - int c; - bool retval = false; - -- exec = basename_c(exec); -+ exec = basename_c(exec); - snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid); - if ((fp = fopen(buffer, "r"))) { - while ((c = getc(fp)) != EOF && c != '(') -@@ -283,7 +283,7 @@ _match_daemon(const char *path, const char *file, RC_STRINGLIST *match) - } - - static RC_STRINGLIST * --_match_list(const char *exec, const char* const* argv, const char *pidfile) -+_match_list(const char *exec, const char *const *argv, const char *pidfile) - { - RC_STRINGLIST *match = rc_stringlist_new(); - int i = 0; -@@ -297,7 +297,7 @@ _match_list(const char *exec, const char* const* argv, const char *pidfile) - rc_stringlist_add(match, m); - free(m); - } -- -+ - while (argv && argv[i]) { - l = strlen(*argv) + strlen("argv_=") + 16; - m = xmalloc(sizeof(char) * l); -@@ -323,7 +323,7 @@ rc_service_daemon_set(const char *service, const char *exec, - const char *pidfile, bool started) - { - char dirpath[PATH_MAX]; -- char file[PATH_MAX]; -+ char file[PATH_MAX]; - int nfiles = 0; - char oldfile[PATH_MAX] = { '\0' }; - bool retval = false; -diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c -index 765f595..54cd72a 100644 ---- a/src/librc/librc-depend.c -+++ b/src/librc/librc-depend.c -@@ -114,7 +114,13 @@ get_deptype(const RC_DEPINFO *depinfo, const char *type) - } - - RC_DEPTREE * --rc_deptree_load(void) -+rc_deptree_load(void) { -+ return rc_deptree_load_file(RC_DEPTREE_CACHE); -+} -+librc_hidden_def(rc_deptree_load) -+ -+RC_DEPTREE * -+rc_deptree_load_file(const char *deptree_file) - { - FILE *fp; - RC_DEPTREE *deptree; -@@ -127,7 +133,7 @@ rc_deptree_load(void) - char *e; - int i; - -- if (!(fp = fopen(RC_DEPTREE_CACHE, "r"))) -+ if (!(fp = fopen(deptree_file, "r"))) - return NULL; - - deptree = xmalloc(sizeof(*deptree)); -@@ -172,16 +178,16 @@ rc_deptree_load(void) - } - fclose(fp); - free(line); -- -+ - return deptree; - } --librc_hidden_def(rc_deptree_load) -+librc_hidden_def(rc_deptree_load_file) - - static bool - valid_service(const char *runlevel, const char *service, const char *type) - { - RC_SERVICE state; -- -+ - if (!runlevel || - strcmp(type, "ineed") == 0 || - strcmp(type, "needsme") == 0) -@@ -393,7 +399,7 @@ visit_service(const RC_DEPTREE *deptree, - if (!(di = get_depinfo(deptree, service->value))) - continue; - provided = get_provided(di, runlevel, options); -- -+ - if (TAILQ_FIRST(provided)) { - TAILQ_FOREACH(p, provided, entries) { - di = get_depinfo(deptree, p->value); -@@ -767,14 +773,14 @@ rc_deptree_update(void) - if (!depinfo || strcmp(depinfo->service, service) != 0) { - deptype = NULL; - depinfo = get_depinfo(deptree, service); -- if (!depinfo) { -+ if (!depinfo) { - depinfo = xmalloc(sizeof(*depinfo)); - TAILQ_INIT(&depinfo->depends); - depinfo->service = xstrdup(service); - TAILQ_INSERT_TAIL(deptree, depinfo, entries); - } - } -- -+ - /* We may not have any depends */ - if (!type || !depends) - continue; -@@ -815,7 +821,7 @@ rc_deptree_update(void) - depend[l - 2] == 's' && - depend[l - 1] == 'h') - continue; -- -+ - /* Remove our dependency if instructed */ - if (depend[0] == '!') { - rc_stringlist_delete(deptype->services, depend + 1); -diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c -index 97cec38..aa038a3 100644 ---- a/src/librc/librc-misc.c -+++ b/src/librc/librc-misc.c -@@ -61,7 +61,7 @@ rc_getline(char **line, size_t *len, FILE *fp) - char *p; - size_t last = 0; - -- while(!feof(fp)) { -+ while (!feof(fp)) { - if (*line == NULL || last != 0) { - *len += BUFSIZ; - *line = xrealloc(*line, *len); -@@ -218,3 +218,52 @@ rc_config_value(RC_STRINGLIST *list, const char *entry) - return NULL; - } - librc_hidden_def(rc_config_value) -+ -+/* Global for caching the strings loaded from rc.conf to avoid reparsing for -+ * each rc_conf_value call */ -+static RC_STRINGLIST *rc_conf = NULL; -+ -+char * -+rc_conf_value(const char *setting) -+{ -+ RC_STRINGLIST *old; -+ RC_STRING *s; -+ char *p; -+ -+ if (! rc_conf) { -+ rc_conf = rc_config_load(RC_CONF); -+#ifdef DEBUG_MEMORY -+ atexit(_free_rc_conf); -+#endif -+ -+ /* Support old configs */ -+ if (exists(RC_CONF_OLD)) { -+ old = rc_config_load(RC_CONF_OLD); -+ TAILQ_CONCAT(rc_conf, old, entries); -+#ifdef DEBUG_MEMORY -+ free(old); -+#endif -+ } -+ -+ /* Convert old uppercase to lowercase */ -+ TAILQ_FOREACH(s, rc_conf, entries) { -+ p = s->value; -+ while (p && *p && *p != '=') { -+ if (isupper((unsigned char)*p)) -+ *p = tolower((unsigned char)*p); -+ p++; -+ } -+ } -+ } -+ -+ return rc_config_value(rc_conf, setting); -+} -+librc_hidden_def(rc_conf_value) -+ -+#ifdef DEBUG_MEMORY -+static void -+_free_rc_conf(void) -+{ -+ rc_stringlist_free(rc_conf); -+} -+#endif -diff --git a/src/librc/librc-stringlist.c b/src/librc/librc-stringlist.c -index c3825cb..818a31c 100644 ---- a/src/librc/librc-stringlist.c -+++ b/src/librc/librc-stringlist.c -@@ -146,7 +146,7 @@ librc_hidden_def(rc_stringlist_sort) - void - rc_stringlist_free(RC_STRINGLIST *list) - { -- RC_STRING *s1; -+ RC_STRING *s1; - RC_STRING *s2; - - if (!list) -diff --git a/src/librc/librc.c b/src/librc/librc.c -index 8a9fd79..e134547 100644 ---- a/src/librc/librc.c -+++ b/src/librc/librc.c -@@ -72,7 +72,7 @@ ls_dir(const char *dir, int options) - { - DIR *dp; - struct dirent *d; -- RC_STRINGLIST *list = NULL; -+ RC_STRINGLIST *list = NULL; - struct stat buf; - size_t l; - char file[PATH_MAX]; -@@ -198,23 +198,24 @@ file_regex(const char *file, const char *regex) - } - #endif - -+/* New sys identification code -+ * Not to be used for any binaries outside of openrc. */ - const char * - rc_sys_v2(void) - { --#define __STRING_SWITCH(x) { char* __string_switch = x; if(false) {} --#define __STRING_CASE(y) else if(strcmp(__string_switch,y) == 0) -+#define __STRING_SWITCH(x) { char *__string_switch = x; if (false) {} -+#define __STRING_CASE(y) else if (strcmp(__string_switch,y) == 0) - #define __STRING_SWITCH_END() } -- char* systype = rc_conf_value("rc_sys"); -- /* New sys identification code */ -- if(systype) { -- char* s = systype; -- // Convert to uppercase -- while(s && *s) { -- if(islower((unsigned char)*s)) -- *s = toupper((unsigned char)*s); -+ char *systype = rc_conf_value("rc_sys"); -+ if (systype) { -+ char *s = systype; -+ /* Convert to uppercase */ -+ while (s && *s) { -+ if (islower((unsigned char) *s)) -+ *s = toupper((unsigned char) *s); - s++; - } -- // Now do detection -+ /* Now do detection */ - __STRING_SWITCH(systype) - __STRING_CASE(RC_SYS_PREFIX) { return RC_SYS_PREFIX; } - #ifdef __FreeBSD__ -@@ -241,13 +242,14 @@ rc_sys_v2(void) - } - librc_hidden_def(rc_sys_v2) - --/* Old sys identification code */ -+/* Old sys identification code. -+ * Not to be used for any binaries outside of openrc. */ - const char * - rc_sys_v1(void) - { - #ifdef PREFIX - return RC_SYS_PREFIX; --#else -+#else - - #ifdef __FreeBSD__ - int jailed = 0; -@@ -290,7 +292,7 @@ librc_hidden_def(rc_sys_v1) - const char * - rc_sys(void) - { -- if(rc_conf_value("rc_sys")) { -+ if (rc_conf_value("rc_sys")) { - return rc_sys_v2(); - } else { - return rc_sys_v1(); -@@ -389,7 +391,7 @@ bool - rc_runlevel_stack(const char *dst, const char *src) - { - char d[PATH_MAX], s[PATH_MAX]; -- -+ - if (!rc_runlevel_exists(dst) || !rc_runlevel_exists(src)) - return false; - snprintf(s, sizeof(s), "../%s", src); -@@ -402,7 +404,7 @@ bool - rc_runlevel_unstack(const char *dst, const char *src) - { - char path[PATH_MAX]; -- -+ - snprintf(path, sizeof(path), "%s/%s/%s", RC_RUNLEVELDIR, dst, src); - return (unlink(path) == 0 ? true : false); - } -@@ -638,7 +640,7 @@ rc_service_mark(const char *service, const RC_SERVICE state) - } - skip_state = state; - } -- -+ - if (state == RC_SERVICE_HOTPLUGGED || state == RC_SERVICE_FAILED) { - free(init); - return true; -@@ -786,7 +788,7 @@ rc_service_value_set(const char *service, const char *option, - { - FILE *fp; - char file[PATH_MAX]; -- char *p = file; -+ char *p = file; - - p += snprintf(file, sizeof(file), RC_SVCDIR "/options/%s", service); - if (mkdir(file, 0755) != 0 && errno != EEXIST) -diff --git a/src/librc/librc.h b/src/librc/librc.h -index dc97f1d..f04750d 100644 ---- a/src/librc/librc.h -+++ b/src/librc/librc.h -@@ -72,6 +72,7 @@ - #define librc_hidden_proto(x) hidden_proto(x) - #define librc_hidden_def(x) hidden_def(x) - -+librc_hidden_proto(rc_conf_value) - librc_hidden_proto(rc_config_list) - librc_hidden_proto(rc_config_load) - librc_hidden_proto(rc_config_value) -@@ -79,6 +80,7 @@ librc_hidden_proto(rc_deptree_depend) - librc_hidden_proto(rc_deptree_depends) - librc_hidden_proto(rc_deptree_free) - librc_hidden_proto(rc_deptree_load) -+librc_hidden_proto(rc_deptree_load_file) - librc_hidden_proto(rc_deptree_order) - librc_hidden_proto(rc_deptree_update) - librc_hidden_proto(rc_deptree_update_needed) -diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in -index 3d0ffb4..5b06de2 100644 ---- a/src/librc/rc.h.in -+++ b/src/librc/rc.h.in -@@ -43,6 +43,14 @@ __BEGIN_DECLS - #define RC_CONFDIR RC_SYSCONFDIR "/conf.d" - #define RC_PLUGINDIR RC_LIBDIR "/plugins" - -+#define RC_PROFILE_ENV RC_SYSCONFDIR "/profile.env" -+#define RC_SYS_WHITELIST RC_LIBEXECDIR "/conf.d/env_whitelist" -+#define RC_USR_WHITELIST RC_SYSCONFDIR "/conf.d/env_whitelist" -+#define RC_CONF RC_SYSCONFDIR "/rc.conf" -+#define RC_CONF_OLD RC_SYSCONFDIR "/conf.d/rc" -+ -+#define RC_PATH_PREFIX RC_LIBEXECDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin" -+ - /* PKG_PREFIX is where packages are installed if different from the base OS - * On Gentoo this is normally unset, on FreeBSD /usr/local and on NetBSD - * /usr/pkg. */ -@@ -342,7 +350,7 @@ typedef void *RC_DEPTREE; - * @param target - * @param mtime of newest target - * @param filename of the newest target (needs mtime param) -- * @return true if source is newer than target, otherwise false */ -+ * @return true if source is newer than target, otherwise false */ - bool rc_newer_than(const char *, const char *, time_t *, char *); - - /*! Check to see if source is older than target. -@@ -351,7 +359,7 @@ bool rc_newer_than(const char *, const char *, time_t *, char *); - * @param target - * @param mtime of oldest target - * @param filename of the oldest target (needs mtime param) -- * @return true if source is older than target, otherwise false */ -+ * @return true if source is older than target, otherwise false */ - bool rc_older_than(const char *, const char *, time_t *, char *); - - /*! Update the cached dependency tree if it's older than any init script, -@@ -375,6 +383,11 @@ bool rc_deptree_update_needed(time_t *, char *); - * @return pointer to the dependency tree */ - RC_DEPTREE *rc_deptree_load(void); - -+/*! Load a cached dependency tree from the specified file and return a pointer -+ * to it. This pointer should be freed with rc_deptree_free when done. -+ * @return pointer to the dependency tree */ -+RC_DEPTREE *rc_deptree_load_file(const char *); -+ - /*! List the depend for the type of service - * @param deptree to search - * @param type to use (keywords, etc) -@@ -457,6 +470,9 @@ RC_STRINGLIST *rc_config_load(const char *); - /*! Return the value of the entry from a key=value list. */ - char *rc_config_value(RC_STRINGLIST *, const char *); - -+/*! Return the value of the entry from rc.conf. */ -+char *rc_conf_value(const char *); -+ - /*! Check if a variable is a boolean and return its value. - * If variable is not a boolean then we set errno to be ENOENT when it does - * not exist or EINVAL if it's not a boolean. -@@ -503,7 +519,7 @@ RC_STRING *rc_stringlist_find(RC_STRINGLIST *, const char *); - RC_STRINGLIST *rc_stringlist_split(const char *, const char *); - - --/*! Sort the list according to C locale -+/*! Sort the list according to C locale - * @param list to sort */ - void rc_stringlist_sort(RC_STRINGLIST **); - -diff --git a/src/librc/rc.map b/src/librc/rc.map -index 113f2d7..c5f10ad 100644 ---- a/src/librc/rc.map -+++ b/src/librc/rc.map -@@ -1,5 +1,6 @@ - RC_1.0 { - global: -+ rc_conf_value; - rc_config_list; - rc_config_load; - rc_config_value; -@@ -7,6 +8,7 @@ global: - rc_deptree_depends; - rc_deptree_free; - rc_deptree_load; -+ rc_deptree_load_file; - rc_deptree_order; - rc_deptree_update; - rc_deptree_update_needed; -diff --git a/src/rc/Makefile b/src/rc/Makefile -index 9d33192..5397415 100644 ---- a/src/rc/Makefile -+++ b/src/rc/Makefile -@@ -41,9 +41,25 @@ include ${MK}/prog.mk - include ${MK}/git.mk - include ${MK}/cc.mk - --include ${MK}/${MKTERMCAP}.mk -+include ${MK}/termcap.mk - LDADD+= ${LIBDL} ${LIBKVM} --include ${MK}/${MKPAM}.mk -+include ${MK}/pam.mk -+ -+# create symlinks to rc if not an SELINUX system, otherwise create a wrapper -+# script to call rc with the proper name of the applet to execute. -+# $1 is a list of the links -+# $2 is the path+name of the target to link to (usually 'rc' or '/sbin/rc') -+# $3 is the path where the links are created -+define make-links -+ for x in $(1); do \ -+ if test -n "${MKSELINUX}"; then \ -+ printf '#!/bin/sh\nexec ${2} --applet %s "$$@"\n' $$x >${3}/$$x; \ -+ chmod ${BINMODE} ${3}/$$x; \ -+ else \ -+ ln -sf ${2} ${3}/$$x; \ -+ fi; \ -+ done; -+endef - - ${SRCS}: version.h - -@@ -61,13 +77,13 @@ install: all - ${INSTALL} -d ${DESTDIR}${SBINDIR} - ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR} - ${INSTALL} -d ${DESTDIR}${BINDIR} -- for x in ${BINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done -+ $(call make-links,${BINLINKS},${SBINDIR}/${PROG},${DESTDIR}${BINDIR}) - ${INSTALL} -d ${DESTDIR}${SBINDIR} -- for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${SBINDIR}/$$x; done -+ $(call make-links,${SBINLINKS},${SBINDIR}/${PROG},${DESTDIR}${SBINDIR}) - ${INSTALL} -d ${DESTDIR}${LINKDIR}/bin -- for x in $(RC_BINLINKS); do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/bin/$$x; done -+ $(call make-links,${RC_BINLINKS},${SBINDIR}/${PROG},${DESTDIR}${LINKDIR}/bin) - ${INSTALL} -d ${DESTDIR}${LINKDIR}/sbin -- for x in ${RC_SBINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/sbin/$$x; done -+ $(call make-links, ${RC_SBINLINKS},${SBINDIR}/${PROG},${DESTDIR}${LINKDIR}/sbin) - if test "${MKPAM}" = pam; then \ - ${INSTALL} -d ${DESTDIR}${PAMDIR}; \ - ${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \ -@@ -76,4 +92,4 @@ install: all - check test:: - - links: rc -- for l in ${ALL_LINKS}; do ln -sf rc $$l || exit $$? ; done -+ $(call make-links,${ALL_LINKS},rc,.) -diff --git a/src/rc/_usage.c b/src/rc/_usage.c -index ec1ce1d..175634a 100644 ---- a/src/rc/_usage.c -+++ b/src/rc/_usage.c -@@ -1,7 +1,7 @@ - /* - * Copyright (c) 2007-2008 Roy Marples <roy@marples.name> - * All rights reserved -- -+ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: -@@ -24,6 +24,8 @@ - * SUCH DAMAGE. - */ - -+#include "version.h" -+ - #if lint - # define _noreturn - #endif -@@ -34,6 +36,22 @@ - #endif - - _noreturn static void -+show_version(void) -+{ -+ const char *bootlevel = NULL; -+ -+ printf("%s (OpenRC", applet); -+ if ((bootlevel = rc_sys())) -+ printf(" [%s]", bootlevel); -+ printf(") %s", VERSION); -+#ifdef BRANDING -+ printf(" (%s)", BRANDING); -+#endif -+ printf("\n"); -+ exit(EXIT_SUCCESS); -+} -+ -+_noreturn static void - usage(int exit_status) - { - const char * const has_arg[] = { "", "<arg>", "[arg]" }; -diff --git a/src/rc/_usage.h b/src/rc/_usage.h -index d65e05e..5e116c9 100644 ---- a/src/rc/_usage.h -+++ b/src/rc/_usage.h -@@ -1,7 +1,7 @@ - /* - * Copyright (c) 2007-2008 Roy Marples <roy@marples.name> - * All rights reserved -- -+ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: -@@ -24,11 +24,12 @@ - * SUCH DAMAGE. - */ - --#define getoptstring_COMMON "Chqv" -+#define getoptstring_COMMON "ChqVv" - - #define longopts_COMMON \ - { "help", 0, NULL, 'h'}, \ - { "nocolor", 0, NULL, 'C'}, \ -+ { "version", 0, NULL, 'V'}, \ - { "verbose", 0, NULL, 'v'}, \ - { "quiet", 0, NULL, 'q'}, \ - { NULL, 0, NULL, 0 } -@@ -36,11 +37,13 @@ - #define longopts_help_COMMON \ - "Display this help output", \ - "Disable color output", \ -+ "Display software version", \ - "Run verbosely", \ - "Run quietly" - - #define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1); - #define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS); -+#define case_RC_COMMON_getopt_case_V if (argc == 2) show_version(); - #define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1); - #define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1); - #define case_RC_COMMON_getopt_default usage (EXIT_FAILURE); -@@ -48,6 +51,7 @@ - #define case_RC_COMMON_GETOPT \ - case 'C': case_RC_COMMON_getopt_case_C; break; \ - case 'h': case_RC_COMMON_getopt_case_h; break; \ -+ case 'V': case_RC_COMMON_getopt_case_V; break; \ - case 'v': case_RC_COMMON_getopt_case_v; break; \ - case 'q': case_RC_COMMON_getopt_case_q; break; \ - default: case_RC_COMMON_getopt_default; break; -diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c -index a05bfae..69b5bbd 100644 ---- a/src/rc/fstabinfo.c -+++ b/src/rc/fstabinfo.c -@@ -109,7 +109,7 @@ do_mount(struct ENT *ent) - argv[6] = ENT_FILE(*ent); - argv[7] = NULL; - switch (pid = vfork()) { -- case -1: -+ case -1: - eerrorx("%s: vfork: %s", applet, strerror(errno)); - /* NOTREACHED */ - case 0: -diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c -index 11bc2d5..6068cb6 100644 ---- a/src/rc/rc-applets.c -+++ b/src/rc/rc-applets.c -@@ -152,7 +152,7 @@ do_e(int argc, char **argv) - ts.tv_nsec = WAIT_INTERVAL; - for (i = 0; i < argc; i++) { - ebeginv("Waiting for %s", argv[i]); -- for (;;){ -+ for (;;) { - if (exists(argv[i])) - break; - if (nanosleep(&ts, NULL) == -1) -@@ -298,7 +298,7 @@ do_service(int argc, char **argv) - } - } - ok = rc_service_started_daemon(service, exec, NULL, idx); -- -+ - } else if (strcmp(applet, "service_crashed") == 0) { - ok = (_rc_can_find_pids() && - rc_service_daemons_crashed(service) && -@@ -429,6 +429,17 @@ run_applets(int argc, char **argv) - char *p; - pid_t pid = 0; - -+ /* Bug 351712: We need an extra way to explicitly select an applet OTHER -+ * than trusting argv[0], as argv[0] is not going to be the applet value if -+ * we are doing SELinux context switching. For this, we allow calls such as -+ * 'rc --applet APPLET', and shift ALL of argv down by two array items. */ -+ if (strcmp(applet, "rc") == 0 && argc >= 3 && -+ (strcmp(argv[1],"--applet") == 0 || strcmp(argv[1], "-a") == 0)) { -+ applet = argv[2]; -+ argv += 2; -+ argc -= 2; -+ } -+ - /* These are designed to be applications in their own right */ - if (strcmp(applet, "fstabinfo") == 0) - exit(fstabinfo(argc, argv)); -@@ -476,7 +487,7 @@ run_applets(int argc, char **argv) - exit(EXIT_FAILURE); - } - exit(EXIT_SUCCESS); -- }; -+ }; - - if (applet[0] == 'e' || (applet[0] == 'v' && applet[1] == 'e')) - exit(do_e(argc, argv)); -diff --git a/src/rc/rc-depend.c b/src/rc/rc-depend.c -index 29f23d2..3d00d1a 100644 ---- a/src/rc/rc-depend.c -+++ b/src/rc/rc-depend.c -@@ -106,7 +106,7 @@ _rc_deptree_load(int force, int *regen) { - } - - #include "_usage.h" --#define getoptstring "aot:suT" getoptstring_COMMON -+#define getoptstring "aot:suTF:" getoptstring_COMMON - static const struct option longopts[] = { - { "starting", 0, NULL, 'a'}, - { "stopping", 0, NULL, 'o'}, -@@ -114,6 +114,7 @@ static const struct option longopts[] = { - { "notrace", 0, NULL, 'T'}, - { "strict", 0, NULL, 's'}, - { "update", 0, NULL, 'u'}, -+ { "deptree-file", 1, NULL, 'F'}, - longopts_COMMON - }; - static const char * const longopts_help[] = { -@@ -123,6 +124,7 @@ static const char * const longopts_help[] = { - "Don't trace service dependencies", - "Only use what is in the runlevels", - "Force an update of the dependency tree", -+ "File to load cached deptree from", - longopts_help_COMMON - }; - #include "_usage.c" -@@ -141,6 +143,7 @@ rc_depend(int argc, char **argv) - char *runlevel = xstrdup(getenv("RC_RUNLEVEL")); - int opt; - char *token; -+ char *deptree_file = NULL; - - types = rc_stringlist_new(); - while ((opt = getopt_long(argc, argv, getoptstring, -@@ -166,13 +169,21 @@ rc_depend(int argc, char **argv) - case 'T': - options &= RC_DEP_TRACE; - break; -+ case 'F': -+ deptree_file = xstrdup(optarg); -+ break; - -- case_RC_COMMON_GETOPT -+ case_RC_COMMON_GETOPT - } - } - -- if (!(deptree = _rc_deptree_load(update, NULL))) -- eerrorx("failed to load deptree"); -+ if (deptree_file) { -+ if (!(deptree = rc_deptree_load_file(deptree_file))) -+ eerrorx("failed to load deptree"); -+ } else { -+ if (!(deptree = _rc_deptree_load(update, NULL))) -+ eerrorx("failed to load deptree"); -+ } - - if (!runlevel) - runlevel = rc_runlevel_get(); -diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c -index 4734989..e45c327 100644 ---- a/src/rc/rc-logger.c -+++ b/src/rc/rc-logger.c -@@ -172,7 +172,7 @@ rc_logger_open(const char *level) - ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws); - if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws)) - return; -- } else -+ } else - if (openpty(&rc_logger_tty, &slave_tty, NULL, NULL, NULL)) - return; - -diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c -index 0239f9d..64edf68 100644 ---- a/src/rc/rc-misc.c -+++ b/src/rc/rc-misc.c -@@ -52,61 +52,7 @@ - #include "rc-misc.h" - #include "version.h" - --#define PROFILE_ENV RC_SYSCONFDIR "/profile.env" --#define SYS_WHITELIST RC_LIBEXECDIR "/conf.d/env_whitelist" --#define USR_WHITELIST RC_SYSCONFDIR "/conf.d/env_whitelist" --#define RC_CONF RC_SYSCONFDIR "/rc.conf" --#define RC_CONF_OLD RC_SYSCONFDIR "/conf.d/rc" -- --#define PATH_PREFIX RC_LIBEXECDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin" -- --static RC_STRINGLIST *rc_conf = NULL; -- --extern char** environ; -- --#ifdef DEBUG_MEMORY --static void --_free_rc_conf(void) --{ -- rc_stringlist_free(rc_conf); --} --#endif -- --char * --rc_conf_value(const char *setting) --{ -- RC_STRINGLIST *old; -- RC_STRING *s; -- char *p; -- -- if (! rc_conf) { -- rc_conf = rc_config_load(RC_CONF); --#ifdef DEBUG_MEMORY -- atexit(_free_rc_conf); --#endif -- -- /* Support old configs */ -- if (exists(RC_CONF_OLD)) { -- old = rc_config_load(RC_CONF_OLD); -- TAILQ_CONCAT(rc_conf, old, entries); --#ifdef DEBUG_MEMORY -- free(old); --#endif -- } -- -- /* Convert old uppercase to lowercase */ -- TAILQ_FOREACH(s, rc_conf, entries) { -- p = s->value; -- while (p && *p && *p != '=') { -- if (isupper((unsigned char)*p)) -- *p = tolower((unsigned char)*p); -- p++; -- } -- } -- } -- -- return rc_config_value(rc_conf, setting); --} -+extern char **environ; - - bool - rc_conf_yesno(const char *setting) -@@ -135,7 +81,7 @@ env_filter(void) - - /* Add the user defined list of vars */ - env_allow = rc_stringlist_split(rc_conf_value("rc_env_allow"), " "); -- profile = rc_config_load(PROFILE_ENV); -+ profile = rc_config_load(RC_PROFILE_ENV); - - /* Copy the env and work from this so we can manipulate it safely */ - env_list = rc_stringlist_new(); -@@ -181,7 +127,7 @@ env_filter(void) - void - env_config(void) - { -- size_t pplen = strlen(PATH_PREFIX); -+ size_t pplen = strlen(RC_PATH_PREFIX); - char *path; - char *p; - char *e; -@@ -199,16 +145,16 @@ env_config(void) - for a little extra security */ - path = getenv("PATH"); - if (! path) -- setenv("PATH", PATH_PREFIX, 1); -- else if (strncmp (PATH_PREFIX, path, pplen) != 0) { -+ setenv("PATH", RC_PATH_PREFIX, 1); -+ else if (strncmp (RC_PATH_PREFIX, path, pplen) != 0) { - l = strlen(path) + pplen + 3; - e = p = xmalloc(sizeof(char) * l); -- p += snprintf(p, l, "%s", PATH_PREFIX); -+ p += snprintf(p, l, "%s", RC_PATH_PREFIX); - - /* Now go through the env var and only add bits not in our - * PREFIX */ - while ((token = strsep(&path, ":"))) { -- np = npp = xstrdup(PATH_PREFIX); -+ np = npp = xstrdup(RC_PATH_PREFIX); - while ((tok = strsep(&npp, ":"))) - if (strcmp(tok, token) == 0) - break; -@@ -316,7 +262,7 @@ exec_service(const char *service, const char *arg) - fd = svc_lock(basename_c(service)); - if (fd == -1) - return -1; -- -+ - file = rc_service_resolve(service); - if (!exists(file)) { - rc_service_mark(service, RC_SERVICE_STOPPED); -diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c -index 592eb09..d82e9a9 100644 ---- a/src/rc/rc-plugin.c -+++ b/src/rc/rc-plugin.c -@@ -105,7 +105,7 @@ rc_plugin_load(void) - continue; - } - -- fptr = (int (*)(RC_HOOK, const char*)) -+ fptr = (int (*)(RC_HOOK, const char *)) - dlfunc(h, RC_PLUGIN_HOOK); - if (fptr == NULL) { - eerror("%s: cannot find symbol `%s'", -@@ -200,7 +200,7 @@ rc_plugin_run(RC_HOOK hook, const char *value) - sigaction(SIGUSR1, &sa, NULL); - sigaction(SIGWINCH, &sa, NULL); - sigprocmask(SIG_SETMASK, &old, NULL); -- -+ - rc_in_plugin = true; - close(pfd[0]); - rc_environ_fd = fdopen(pfd[1], "w"); -diff --git a/src/rc/rc.c b/src/rc/rc.c -index b062349..140667a 100644 ---- a/src/rc/rc.c -+++ b/src/rc/rc.c -@@ -153,7 +153,7 @@ cleanup(void) - - #ifdef DEBUG_MEMORY - while (p1) { -- p2 = LIST_NEXT(p1, entries); -+ p2 = LIST_NEXT(p1, entries); - free(p1); - p1 = p2; - } -@@ -315,7 +315,7 @@ open_shell(void) - { - const char *shell; - struct passwd *pw; -- -+ - #ifdef __linux__ - const char *sys = rc_sys(); - -@@ -586,7 +586,7 @@ do_stop_services(const char *newlevel, bool parallel, bool going_down) - } - - crashed = rc_conf_yesno("rc_crashed_stop"); -- -+ - nostop = rc_stringlist_split(rc_conf_value("rc_nostop"), " "); - TAILQ_FOREACH_REVERSE(service, stop_services, rc_stringlist, entries) - { -@@ -773,14 +773,16 @@ handle_bad_signal(int sig) - #endif - - #include "_usage.h" --#define getoptstring "o:s:S" getoptstring_COMMON -+#define getoptstring "a:o:s:S" getoptstring_COMMON - static const struct option longopts[] = { -+ { "applet", 1, NULL, 'a' }, - { "override", 1, NULL, 'o' }, - { "service", 1, NULL, 's' }, - { "sys", 0, NULL, 'S' }, - longopts_COMMON - }; - static const char * const longopts_help[] = { -+ "runs the applet specified by the next argument", - "override the next runlevel to change into\n" - "when leaving single user or boot runlevels", - "runs the service specified with the rest\nof the arguments", -@@ -804,6 +806,7 @@ main(int argc, char **argv) - int opt; - bool parallel; - int regen = 0; -+ int i; - #ifdef __linux__ - char *proc; - char *p; -@@ -822,18 +825,6 @@ main(int argc, char **argv) - if (!applet) - eerrorx("arguments required"); - -- if (argc > 1 && (strcmp(argv[1], "--version") == 0)) { -- printf("%s (OpenRC", applet); -- if ((bootlevel = rc_sys())) -- printf(" [%s]", bootlevel); -- printf(") " VERSION --#ifdef BRANDING -- " (" BRANDING ")" --#endif -- "\n"); -- exit(EXIT_SUCCESS); -- } -- - /* Run our built in applets. If we ran one, we don't return. */ - run_applets(argc, argv); - -@@ -855,6 +846,10 @@ main(int argc, char **argv) - longopts, (int *) 0)) != -1) - { - switch (opt) { -+ case 'a': -+ /* Do nothing, actual logic in run_applets, this -+ * is a placeholder */ -+ break; - case 'o': - if (*optarg == '\0') - optarg = NULL; -@@ -880,18 +875,18 @@ main(int argc, char **argv) - case 'S': - if (rc_conf_value("rc_sys")) { - bootlevel = rc_sys_v2(); -- if(bootlevel) -+ if (bootlevel) - printf("%s\n", bootlevel); - } else { - ewarn("WARNING: rc_sys not defined in rc.conf. Falling back to automatic detection"); - bootlevel = rc_sys_v1(); -- if(bootlevel) -+ if (bootlevel) - printf("%s\n", bootlevel); - } - exit(EXIT_SUCCESS); - /* NOTREACHED */ -- case_RC_COMMON_GETOPT -- } -+ case_RC_COMMON_GETOPT -+ } - } - - newlevel = argv[optind++]; -diff --git a/src/rc/runscript.c b/src/rc/runscript.c -index 1c60c24..0eca487 100644 ---- a/src/rc/runscript.c -+++ b/src/rc/runscript.c -@@ -451,7 +451,7 @@ svc_exec(const char *arg1, const char *arg2) - signal_pipe[0] = signal_pipe[1] = -1; - - sigprocmask (SIG_SETMASK, &oldmask, NULL); -- -+ - if (master_tty >= 0) { - /* Why did we do this? */ - /* signal (SIGWINCH, SIG_IGN); */ -@@ -572,7 +572,7 @@ svc_start_check(void) - RC_SERVICE state; - - state = rc_service_state(service); -- -+ - if (in_background) { - if (!(state & (RC_SERVICE_INACTIVE | RC_SERVICE_STOPPED))) - exit(EXIT_FAILURE); -@@ -583,7 +583,7 @@ svc_start_check(void) - " next runlevel", applet); - } - -- if (exclusive_fd == -1) -+ if (exclusive_fd == -1) - exclusive_fd = svc_lock(applet); - if (exclusive_fd == -1) { - if (errno == EACCES) -@@ -603,7 +603,7 @@ svc_start_check(void) - else if (state & RC_SERVICE_INACTIVE && !in_background) - ewarnx("WARNING: %s has already started, but is inactive", - applet); -- -+ - rc_service_mark(service, RC_SERVICE_STARTING); - hook_out = RC_HOOK_SERVICE_START_OUT; - rc_plugin_run(RC_HOOK_SERVICE_START_IN, applet); -@@ -619,7 +619,7 @@ svc_start_deps(void) - size_t len; - char *p, *tmp; - pid_t pid; -- -+ - errno = 0; - if (rc_conf_yesno("rc_depend_strict") || errno == ENOENT) - depoptions |= RC_DEP_STRICT; -@@ -725,7 +725,7 @@ svc_start_deps(void) - n = 0; - TAILQ_FOREACH(svc, tmplist, entries) { - rc_service_schedule_start(svc->value, service); -- use_services = rc_deptree_depend(deptree, -+ use_services = rc_deptree_depend(deptree, - "iprovide", svc->value); - TAILQ_FOREACH(svc2, use_services, entries) - rc_service_schedule_start(svc2->value, service); -@@ -760,7 +760,7 @@ static void svc_start_real() - { - bool started; - RC_STRING *svc, *svc2; -- -+ - if (ibsave) - setenv("IN_BACKGROUND", ibsave, 1); - hook_out = RC_HOOK_SERVICE_START_DONE; -@@ -873,7 +873,7 @@ svc_stop_deps(RC_SERVICE state) - - if (state & RC_SERVICE_WASINACTIVE) - return; -- -+ - errno = 0; - if (rc_conf_yesno("rc_depend_strict") || errno == ENOENT) - depoptions |= RC_DEP_STRICT; -@@ -941,7 +941,7 @@ svc_stop_deps(RC_SERVICE state) - } - rc_stringlist_free(tmplist); - tmplist = NULL; -- -+ - /* We now wait for other services that may use us and are - * stopping. This is important when a runlevel stops */ - services = rc_deptree_depends(deptree, types_mua, applet_list, -@@ -959,7 +959,7 @@ static void - svc_stop_real(void) - { - bool stopped; -- -+ - /* If we're stopping localmount, set LC_ALL=C so that - * bash doesn't load anything blocking the unmounting of /usr */ - if (strcmp(applet, "localmount") == 0) -@@ -1138,7 +1138,7 @@ runscript(int argc, char **argv) - file = basename_c(argv[1]); - else - file = basename_c(lnk); -- dir = save; -+ dir = save; - } else - file = basename_c(argv[1]); - ll = strlen(dir) + strlen(file) + 2; -@@ -1206,7 +1206,7 @@ runscript(int argc, char **argv) - #endif - - deps = true; -- -+ - /* Punt the first arg as its our service name */ - argc--; - argv++; -@@ -1363,7 +1363,7 @@ runscript(int argc, char **argv) - RC_SERVICE_INACTIVE) - { - TAILQ_FOREACH(svc, -- restart_services, -+ restart_services, - entries) - if (rc_service_state(svc->value) & - RC_SERVICE_STOPPED) -diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c -index bd6c7bf..72b8aff 100644 ---- a/src/rc/start-stop-daemon.c -+++ b/src/rc/start-stop-daemon.c -@@ -43,7 +43,7 @@ - #include <sys/ioctl.h> - #include <sys/resource.h> - #include <sys/stat.h> --#include <sys/termios.h> -+#include <termios.h> - #include <sys/time.h> - #include <sys/wait.h> - -@@ -322,7 +322,7 @@ get_pid(const char *pidfile, bool quiet) - fclose(fp); - return -1; - } -- -+ - fclose(fp); - - return pid; -@@ -631,7 +631,7 @@ static const struct option longopts[] = { - longopts_COMMON - }; - static const char * const longopts_help[] = { -- "Set an ionice class:data when starting", -+ "Set an ionice class:data when starting", - "Stop daemon", - "Set a nicelevel when starting", - "Retry schedule to use when stopping", -@@ -1210,7 +1210,7 @@ start_stop_daemon(int argc, char **argv) - /* Clean the environment of any RC_ variables */ - env_list = rc_stringlist_new(); - i = 0; -- while(environ[i]) -+ while (environ[i]) - rc_stringlist_add(env_list, environ[i++]); - - #ifdef HAVE_PAM -@@ -1343,7 +1343,7 @@ start_stop_daemon(int argc, char **argv) - if (start_wait > 0) { - struct timespec ts; - bool alive = false; -- -+ - ts.tv_sec = start_wait / 1000; - ts.tv_nsec = (start_wait % 1000) * ONE_MS; - if (nanosleep(&ts, NULL) == -1) { -diff --git a/src/test/.gitignore b/src/test/.gitignore -index c4816ef..1b79b9f 100644 ---- a/src/test/.gitignore -+++ b/src/test/.gitignore -@@ -1,5 +1,6 @@ - einfo.data.out - einfo.funcs.out - librc.funcs.hidden.out -+librc.funcs.hidden.list - rc.data.out --rc.funcs.out -\ No newline at end of file -+rc.funcs.out -diff --git a/src/test/librc.funcs.hidden.list b/src/test/librc.funcs.hidden.list -deleted file mode 100644 -index b661850..0000000 ---- a/src/test/librc.funcs.hidden.list -+++ /dev/null -@@ -1,56 +0,0 @@ --rc_config_list --rc_config_load --rc_config_value --rc_deptree_depend --rc_deptree_depends --rc_deptree_free --rc_deptree_load --rc_deptree_order --rc_deptree_update --rc_deptree_update_needed --rc_find_pids --rc_getline --rc_newer_than --rc_older_than --rc_runlevel_exists --rc_runlevel_get --rc_runlevel_list --rc_runlevel_set --rc_runlevel_stack --rc_runlevel_stacks --rc_runlevel_starting --rc_runlevel_stopping --rc_runlevel_unstack --rc_service_add --rc_service_daemon_set --rc_service_daemons_crashed --rc_service_delete --rc_service_description --rc_service_exists --rc_service_extra_commands --rc_service_in_runlevel --rc_service_mark --rc_service_resolve --rc_service_schedule_clear --rc_service_schedule_start --rc_service_started_daemon --rc_service_state --rc_service_value_get --rc_service_value_set --rc_services_in_runlevel --rc_services_in_runlevel_stacked --rc_services_in_state --rc_services_scheduled --rc_services_scheduled_by --rc_stringlist_add --rc_stringlist_addu --rc_stringlist_delete --rc_stringlist_find --rc_stringlist_free --rc_stringlist_new --rc_stringlist_sort --rc_stringlist_split --rc_sys --rc_sys_v1 --rc_sys_v2 --rc_yesno -diff --git a/src/test/rc.funcs.list b/src/test/rc.funcs.list -index 0aac8f9..a8b011f 100644 ---- a/src/test/rc.funcs.list -+++ b/src/test/rc.funcs.list -@@ -1,3 +1,5 @@ -+rc_conf_value -+rc_conf_value@@RC_1.0 - rc_config_list - rc_config_list@@RC_1.0 - rc_config_load -@@ -12,6 +14,8 @@ rc_deptree_free - rc_deptree_free@@RC_1.0 - rc_deptree_load - rc_deptree_load@@RC_1.0 -+rc_deptree_load_file -+rc_deptree_load_file@@RC_1.0 - rc_deptree_order - rc_deptree_order@@RC_1.0 - rc_deptree_update -diff --git a/src/test/runtests.sh b/src/test/runtests.sh -index 076bd75..4731bd7 100755 ---- a/src/test/runtests.sh -+++ b/src/test/runtests.sh -@@ -57,6 +57,7 @@ sed -n '/^librc_hidden_proto/s:.*(\(.*\))$:\1:p' ${librc_srcdir}/librc.h \ - | LC_ALL=C sort -u \ - > librc.funcs.hidden.list - readelf -Wr $(grep -l '#include[[:space:]]"librc\.h"' ${librc_srcdir}/*.c | sed 's:\.c$:.o:') \ -+ | egrep -v -e 'R_PARISC_(DP|SEG)REL' \ - | awk '$5 ~ /^rc_/ {print $5}' \ - | LC_ALL=C sort -u \ - | egrep -v '^rc_environ_fd$' \ -@@ -66,6 +67,50 @@ syms=$(diff -u librc.funcs.hidden.list librc.funcs.hidden.out | sed -n '/^+[^+]/ - eend $? "Missing hidden defs:"$'\n'"${syms}" - ret=$(($ret + $?)) - -+ebegin "Checking trailing whitespace in code" -+# XXX: Should we check man pages too ? -+out=$(cd ${top_srcdir}; find */ \ -+ '(' -name '*.[ch]' -o -name '*.in' -o -name '*.sh' ')' \ -+ -exec grep -n -E '[[:space:]]+$' {} +) -+[ -z "${out}" ] -+eend $? "Trailing whitespace needs to be deleted:"$'\n'"${out}" -+ -+ebegin "Checking trailing newlines in code" -+out=$(cd ${top_srcdir}; -+ for f in `find */ -name '*.[ch]'` ; do -+ sed -n -e :a -e '/^\n*$/{$q1;N;ba' -e '}' $f || echo $f -+ done) -+[ -z "${out}" ] -+eend $? "Trailing newlines need to be deleted:"$'\n'"${out}" -+ -+ebegin "Checking for obsolete functions" -+out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ -+ -exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +) -+[ -z "${out}" ] -+eend $? "Avoid these obsolete functions:"$'\n'"${out}" -+ -+ebegin "Checking for x* func usage" -+out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ -+ -exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \ -+ | grep -v \ -+ -e src/includes/rc-misc.h \ -+ -e src/libeinfo/libeinfo.c) -+[ -z "${out}" ] -+eend $? "These need to be using the x* variant:"$'\n'"${out}" -+ -+ebegin "Checking spacing style" -+out=$(cd ${top_srcdir}; find src -name '*.[ch]' \ -+ -exec grep -n -E \ -+ -e '\<(for|if|switch|while)\(' \ -+ -e '\<(for|if|switch|while) \( ' \ -+ -e ' ;' \ -+ -e '[[:space:]]$' \ -+ -e '\){' \ -+ -e '(^|[^:])//' \ -+ {} +) -+[ -z "${out}" ] -+eend $? "These lines violate style rules:"$'\n'"${out}" -+ - einfo "Running unit tests" - eindent - for u in units/*; do -diff --git a/test/setup_env.sh b/test/setup_env.sh -index 6794913..9f3a3fd 100755 ---- a/test/setup_env.sh -+++ b/test/setup_env.sh -@@ -9,14 +9,18 @@ srcdir=${srcdir:-.} - top_builddir=${top_builddir:-${top_srcdir}} - builddir=${builddir:-${srcdir}} - --if ! . ${top_srcdir}/sh/functions.sh; then -+export LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBRARY_PATH} -+export PATH=${top_builddir}/src/rc:${PATH} -+ -+ -+if [ ! -f ${top_srcdir}/sh/functions.sh ] ; then -+ echo "functions.sh not yet created !?" 1>&2 -+ exit 1 -+elif ! . ${top_srcdir}/sh/functions.sh; then - echo "Sourcing functions.sh failed !?" 1>&2 - exit 1 - fi - --export LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBRARY_PATH} --export PATH=${top_builddir}/src/rc:${PATH} -- - cd ${top_srcdir}/src/rc - ${MAKE:-make} links >/dev/null - cd - |