aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-04-12 09:01:39 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-04-12 09:01:39 +0000
commit69bf2d9f5040293c67d41224db35f7b54c5c45b8 (patch)
treeaf70ad76715b88208b9ca50ba1b601b11c63c6e9
parent8e12dafc749dd1f09cf4238f2d2dd6b461324fd1 (diff)
downloadalpine_aports-69bf2d9f5040293c67d41224db35f7b54c5c45b8.tar.bz2
alpine_aports-69bf2d9f5040293c67d41224db35f7b54c5c45b8.tar.xz
alpine_aports-69bf2d9f5040293c67d41224db35f7b54c5c45b8.zip
main/openrc: upgrgadee to 0.8.0
-rw-r--r--main/openrc/0001-Use-rc_sys_v1-when-rc_sys-variable-is-defined-but-em.patch27
-rw-r--r--main/openrc/APKBUILD12
-rw-r--r--main/openrc/openrc-0.7.0-git_20110222.patch3879
3 files changed, 4 insertions, 3914 deletions
diff --git a/main/openrc/0001-Use-rc_sys_v1-when-rc_sys-variable-is-defined-but-em.patch b/main/openrc/0001-Use-rc_sys_v1-when-rc_sys-variable-is-defined-but-em.patch
deleted file mode 100644
index d0a3547016..0000000000
--- a/main/openrc/0001-Use-rc_sys_v1-when-rc_sys-variable-is-defined-but-em.patch
+++ /dev/null
@@ -1,27 +0,0 @@
1From 9b7f57c47e1a5c73d22a0f5bff132c702e6f352b Mon Sep 17 00:00:00 2001
2From: Natanael Copa <ncopa@alpinelinux.org>
3Date: Thu, 3 Mar 2011 18:16:50 +0000
4Subject: [PATCH] Use rc_sys_v1() when rc_sys variable is defined but empty.
5
6This makes current vserver boot
7---
8 src/librc/librc.c | 3 ++-
9 1 files changed, 2 insertions(+), 1 deletions(-)
10
11diff --git a/src/librc/librc.c b/src/librc/librc.c
12index e134547..8292f6e 100644
13--- a/src/librc/librc.c
14+++ b/src/librc/librc.c
15@@ -292,7 +292,8 @@ librc_hidden_def(rc_sys_v1)
16 const char *
17 rc_sys(void)
18 {
19- if (rc_conf_value("rc_sys")) {
20+ char *val = rc_conf_value("rc_sys");
21+ if (val && *val) {
22 return rc_sys_v2();
23 } else {
24 return rc_sys_v1();
25--
261.7.4.1
27
diff --git a/main/openrc/APKBUILD b/main/openrc/APKBUILD
index fbdf9de2e5..e71772994d 100644
--- a/main/openrc/APKBUILD
+++ b/main/openrc/APKBUILD
@@ -1,18 +1,16 @@
1# Maintainer: Natanael Copa <ncopa@alpinelinux.org> 1# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
2pkgname=openrc 2pkgname=openrc
3pkgver=0.7.0_git20110222 3pkgver=0.8.0
4_ver=${pkgver/_git*/} 4_ver=${pkgver/_git*/}
5pkgrel=1 5pkgrel=0
6pkgdesc="OpenRC manages the services, startup and shutdown of a host" 6pkgdesc="OpenRC manages the services, startup and shutdown of a host"
7url="http://roy.marples.name/openrc" 7url="http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git"
8arch="all" 8arch="all"
9license='BSD-2' 9license='BSD-2'
10depends="" 10depends=""
11subpackages="$pkgname-doc $pkgname-dev" 11subpackages="$pkgname-doc $pkgname-dev"
12install="$pkgname.post-install $pkgname.post-upgrade" 12install="$pkgname.post-install $pkgname.post-upgrade"
13source="http://distfiles.gentoo.org/distfiles/$pkgname-$_ver.tar.bz2 13source="http://distfiles.gentoo.org/distfiles/$pkgname-$_ver.tar.bz2
14 openrc-0.7.0-git_20110222.patch
15 0001-Use-rc_sys_v1-when-rc_sys-variable-is-defined-but-em.patch
16 openrc-0.4.3-mkmntdirs.patch 14 openrc-0.4.3-mkmntdirs.patch
17 15
18 0001-Force-root-be-rw-before-localmount.patch 16 0001-Force-root-be-rw-before-localmount.patch
@@ -64,9 +62,7 @@ package() {
64 install -Dm644 ../local.start "$pkgdir"/etc/conf.d/local.start 62 install -Dm644 ../local.start "$pkgdir"/etc/conf.d/local.start
65} 63}
66 64
67md5sums="80efd9dd83d4713ddfb7e41a6433cc9c openrc-0.7.0.tar.bz2 65md5sums="54978ba3a1ff9fb8f04aae422c0416af openrc-0.8.0.tar.bz2
6885b667dcadf8aab78384bc942babc89a openrc-0.7.0-git_20110222.patch
69c3dfd1a0ee9e88a0d491d815ca634bda 0001-Use-rc_sys_v1-when-rc_sys-variable-is-defined-but-em.patch
708c2c1c2ee0509b63966b7187a2079f4b openrc-0.4.3-mkmntdirs.patch 668c2c1c2ee0509b63966b7187a2079f4b openrc-0.4.3-mkmntdirs.patch
714fd036ff07ed9ad7fb76af6a3ffc0695 0001-Force-root-be-rw-before-localmount.patch 674fd036ff07ed9ad7fb76af6a3ffc0695 0001-Force-root-be-rw-before-localmount.patch
72fb8baeaf32f4d53491312675f28a9939 0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch 68fb8baeaf32f4d53491312675f28a9939 0001-fsck-add-C0-and-T-options-unless-fsck-is-busybox.patch
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 @@
1diff --git a/FEATURE-REMOVAL-SCHEDULE b/FEATURE-REMOVAL-SCHEDULE
2new file mode 100644
3index 0000000..50c81f8
4--- /dev/null
5+++ b/FEATURE-REMOVAL-SCHEDULE
6@@ -0,0 +1,70 @@
7+The following is a list of files and features that are going to be removed in
8+the source tree. Every entry should contain what exactly is going away, why it
9+is happening, and who is going to be doing the work. When the feature is
10+removed, it should also be removed from this file.
11+
12+---------------------------
13+
14+What: rc_sys automatic detection code
15+ - Functions for removal: rc_sys_v1, rc_sys_v2
16+
17+When: 2011/03/01
18+
19+Why: The original automatic sub-system detection is flawed in that it cannot
20+ safely detect some variables (Using cgroups confused it to think you were
21+ using LXC, and Prefix cannot be detect by definition). Also, almost all of
22+ the detection requires that /proc is available and readable. During early
23+ boot, /proc may not be mounted yet, leading to mis-detection. The readable
24+ condition can also fail under some hardened kernels when running as an
25+ unprivileged user.
26+
27+ The new rc_sys_v2 function uses the rc_sys variable from rc.conf. After
28+ the removal, the contents of the rc_sys_v2 function will move into the
29+ rc_sys function.
30+
31+Who: Robin H. Johnson <robbat2@gentoo.org>
32+
33+---------------------------
34+
35+What: oldnet ADSL rp-pppoe mode
36+
37+When: undecided
38+
39+Why: Replaced by the oldnet PPP module
40+
41+Who: Robin H. Johnson <robbat2@gentoo.org>
42+
43+---------------------------
44+
45+What: oldnet /etc/conf.d/wireless
46+
47+When: undecided
48+
49+Why: All configuration moved to /etc/conf.d/net
50+
51+Who: Robin H. Johnson <robbat2@gentoo.org>
52+
53+---------------------------
54+
55+What: Service pause action
56+
57+When: Removed already, compatbility warning in place.
58+
59+Why: ...
60+
61+Who:
62+
63+---------------------------
64+
65+What: Service --startas, --chuid , --oknodo
66+
67+When: undecided
68+
69+Why: Obsolete or replaced by other options.
70+ --startas => use --name or --exec
71+ --chuid => use --user
72+ --oknodo => ignore return code instead
73+
74+Who:
75+
76+---------------------------
77diff --git a/Makefile b/Makefile
78index 8f9cc95..dd427d0 100644
79--- a/Makefile
80+++ b/Makefile
81@@ -4,23 +4,18 @@
82
83 include Makefile.inc
84
85-SUBDIR= conf.d etc init.d man scripts sh src
86+SUBDIR= conf.d etc init.d local.d man scripts sh src
87
88 # Build our old net foo or not
89-_OLDNET_SH= case "${MKOLDNET}" in \
90- [Yy][Ee][Ss]) echo "net doc";; \
91- *) echo "";; \
92- esac
93-_OLDNET!= ${_OLDNET_SH}
94-SUBDIR+= ${_OLDNET}$(shell ${_OLDNET_SH})
95+ifeq (${MKOLDNET},yes)
96+SUBDIR+= net doc
97+endif
98
99 # Build pkgconfig or not
100-_PKGCONFIG_SH= case "${MKPKGCONFIG}" in \
101- [Yy][Ee][Ss]|"") echo "pkgconfig";; \
102- *) echo "";; \
103- esac
104-_PKGCONFIG!= ${_PKGCONFIG_SH}
105-SUBDIR+= ${_PKGCONFIG}$(shell ${_PKGCONFIG_SH})
106+MKPKGCONFIG?= yes
107+ifeq (${MKPKGCONFIG},yes)
108+SUBDIR+= pkgconfig
109+endif
110
111 # We need to ensure that runlevels is done last
112 SUBDIR+= runlevels
113diff --git a/README b/README
114index 07f181f..2a2eac3 100644
115--- a/README
116+++ b/README
117@@ -4,7 +4,7 @@ OpenRC README
118 Installation
119 ------------
120 make install
121-Yup, that simple. Works with GNU make and BSD make.
122+Yup, that simple. Works with GNU make.
123
124 You may wish to tweak the installation with the below arguments
125 PROGLDFLAGS=-static
126@@ -12,6 +12,7 @@ LIBNAME=lib64
127 DESTDIR=/tmp/openrc-image
128 MKPAM=pam
129 MKPKGCONFIG=no
130+MKSELINUX=yes
131 MKTERMCAP=ncurses
132 MKTERMCAP=termcap
133 MKOLDNET=yes
134diff --git a/README.net b/README.net
135deleted file mode 100644
136index 41db1c5..0000000
137--- a/README.net
138+++ /dev/null
139@@ -1,36 +0,0 @@
140-OpenRC Network Ideals
141----------------------
142-
143-The new style networking for OpenRC is very simplistic - provide a basic means
144-of configuring static interface address and routes whilst allowing the
145-possibility to run any command at any point.
146-
147-In a nutshell, init.d/network is a wrapper around ifconfig(8) and
148-init.d/staticroute is wrapper around route(8).
149-
150-In the Perfect World (TM) ifconfig should be able to configure everything
151-about the interface easily * . The BSD family almost get this right and Linux
152-epically fails.
153-
154-* Only static configuration, including link setup.
155-For dynamic, static, IPv4LL, arping and per ssid IPv4 setup dhcpcd-5.x
156-provides your needs.
157-
158-It fails because there are many tools to do the same job and often have
159-vastly different syntax where they could be similar. In other words, there
160-is no coherence.
161-
162-OpenRC-0.4.x and older (inc Gentoo baselayout-1) had a collection of scripts
163-for each tool and allowed a script per interface. Over the years, this design
164-has proven very hard to maintain as each user has their own idea of how
165-things should work. Also, there were (and still are) race conditions.
166-
167-So where do we go from here?
168-Well, it's possible to use the new network scripts using the tools
169-currently available. It's just harder as you have to know them and their
170-documentation can be lacking at times.
171-The correct end goal is a BSD style ifconfig tool.
172-I've started work on it, but the project has stalled somewhat.
173-It's display only right now and the source is not yet publicly available.
174-If you have the skills and share the vision then contact me privately and
175-we'll take it from there.
176diff --git a/README.newnet b/README.newnet
177new file mode 100644
178index 0000000..2e157e2
179--- /dev/null
180+++ b/README.newnet
181@@ -0,0 +1,40 @@
182+The following applies only to the newnet stack, which is not presently
183+maintained in OpenRC. The oldnet stack is maintained instead.
184+- Robin H. Johnson <robbat2@gentoo.org>, 2011/02/21
185+
186+OpenRC Network Ideals
187+---------------------
188+
189+The new style networking for OpenRC is very simplistic - provide a basic means
190+of configuring static interface address and routes whilst allowing the
191+possibility to run any command at any point.
192+
193+In a nutshell, init.d/network is a wrapper around ifconfig(8) and
194+init.d/staticroute is wrapper around route(8).
195+
196+In the Perfect World (TM) ifconfig should be able to configure everything
197+about the interface easily * . The BSD family almost get this right and Linux
198+epically fails.
199+
200+* Only static configuration, including link setup.
201+For dynamic, static, IPv4LL, arping and per ssid IPv4 setup dhcpcd-5.x
202+provides your needs.
203+
204+It fails because there are many tools to do the same job and often have
205+vastly different syntax where they could be similar. In other words, there
206+is no coherence.
207+
208+OpenRC-0.4.x and older (inc Gentoo baselayout-1) had a collection of scripts
209+for each tool and allowed a script per interface. Over the years, this design
210+has proven very hard to maintain as each user has their own idea of how
211+things should work. Also, there were (and still are) race conditions.
212+
213+So where do we go from here?
214+Well, it's possible to use the new network scripts using the tools
215+currently available. It's just harder as you have to know them and their
216+documentation can be lacking at times.
217+The correct end goal is a BSD style ifconfig tool.
218+I've started work on it, but the project has stalled somewhat.
219+It's display only right now and the source is not yet publicly available.
220+If you have the skills and share the vision then contact me privately and
221+we'll take it from there.
222diff --git a/STYLE b/STYLE
223new file mode 100644
224index 0000000..f1ae5c1
225--- /dev/null
226+++ b/STYLE
227@@ -0,0 +1,34 @@
228+This is the openrc style manual. It governs the coding style of all code
229+in this repository. Follow it. Contact openrc@gentoo.org for any questions
230+or fixes you might notice.
231+
232+##########
233+# C CODE #
234+##########
235+
236+The BSD Kernel Normal Form (KNF) style is used:
237+ http://en.wikipedia.org/wiki/Indent_style#BSD_KNF_style
238+Basically, it's like K&R/LKML, but wrapped lines that are indented use 4 spaces.
239+
240+Highlights:
241+ - no trailing whitespace
242+ - indented code use tabs (not line wrapped)
243+ - cuddle the braces (except for functions)
244+ - space after native statements and before paren (for/if/while/...)
245+ - no space between function and paren
246+ - pointer asterisk cuddles the variable, not the type
247+
248+void foo(int c)
249+{
250+ int ret = 0;
251+
252+ if (c > 1000)
253+ return;
254+
255+ while (c--) {
256+ bar(c);
257+ ret++;
258+ }
259+
260+ return ret;
261+}
262diff --git a/TODO b/TODO
263index e008fca..4309aa0 100644
264--- a/TODO
265+++ b/TODO
266@@ -3,3 +3,5 @@
267 - add support somehow for optional translations
268
269 - oldnet[bridging]: Review setting of bridge configuration on dynamic interface add
270+
271+- Document rc-depend binary.
272diff --git a/conf.d/Makefile b/conf.d/Makefile
273index 034dc74..374bfdb 100644
274--- a/conf.d/Makefile
275+++ b/conf.d/Makefile
276@@ -1,5 +1,5 @@
277 DIR= ${CONFDIR}
278-CONF= bootmisc fsck hostname local localmount network staticroute urandom
279+CONF= bootmisc fsck hostname localmount network staticroute urandom
280
281 TARGETS+= network staticroute
282 CLEANFILES+= network staticroute
283diff --git a/conf.d/hwclock b/conf.d/hwclock
284index 5321ba1..4e66ff9 100644
285--- a/conf.d/hwclock
286+++ b/conf.d/hwclock
287@@ -9,6 +9,14 @@ clock="UTC"
288 # You normally don't need to do this if you run a ntp daemon.
289 clock_systohc="NO"
290
291+# If you want to set the system time to the current hardware clock
292+# during bootup, then say "YES" here. You do not need this if you are
293+# running a modern kernel with CONFIG_RTC_HCTOSYS set to y.
294+# Also, be aware that if you set this to "NO", the system time will
295+# never be saved to the hardware clock unless you set
296+# clock_systohc="YES" above.
297+clock_hctosys="YES"
298+
299 # If you wish to pass any other arguments to hwclock during bootup,
300 # you may do so here. Alpha users may wish to use --arc or --srm here.
301 clock_args=""
302diff --git a/conf.d/local b/conf.d/local
303deleted file mode 100644
304index 97dbbcc..0000000
305--- a/conf.d/local
306+++ /dev/null
307@@ -1,18 +0,0 @@
308-# Here is where you can put anything you need to start
309-# that there is not an init script for.
310-
311-local_start() {
312- # This is a good place to load any misc programs
313- # on startup (use &>/dev/null to hide output)
314-
315- # We should always return 0
316- return 0
317-}
318-
319-local_stop() {
320- # This is a good place to unload any misc.
321- # programs you started above.
322-
323- # We should always return 0
324- return 0
325-}
326diff --git a/doc/net.example.BSD.in b/doc/net.example.BSD.in
327index 977011e..287c644 100644
328--- a/doc/net.example.BSD.in
329+++ b/doc/net.example.BSD.in
330@@ -23,7 +23,7 @@
331 # We now support modular networking scripts which means we can easily
332 # add support for new interface types and modules while keeping
333 # compatibility with existing ones.
334-#
335+#
336 # Modules load by default if the package they need is installed. If
337 # you specify a module here that doesn't have its package installed
338 # then you get an error stating which package you need to install.
339@@ -212,7 +212,7 @@
340 # not find them in a scan
341 # "forcepreferredonly" means it forcibly connects to the APs in order and
342 # does not bother to scan
343-# "forceany" does the same as forcepreferred + connects to any other
344+# "forceany" does the same as forcepreferred + connects to any other
345 # available AP
346 # Default is "any"
347 #associate_order="any"
348@@ -266,13 +266,13 @@
349 # won't have associated then)
350
351 # If you're using anything else to configure wireless on your interface AND
352-# you have installed wpa_supplicant, you need to disable wpa_supplicant
353+# you have installed wpa_supplicant, you need to disable wpa_supplicant
354 #modules="!iwconfig !wpa_supplicant"
355 #or
356 #modules="!wireless"
357
358 ##############################################################################
359-# WIRELESS SSID IN VARIABLES
360+# WIRELESS SSID IN VARIABLES
361 ##############################################################################
362 # Remember to change SSID to your SSID.
363 # Say that your SSID is My NET - the line
364@@ -368,7 +368,7 @@
365
366 ##############################################################################
367 # ADVANCED CONFIGURATION
368-#
369+#
370 # Four functions can be defined which will be called surrounding the
371 # start/stop operations. The functions are called with the interface
372 # name first so that one function can control multiple adapters. An extra two
373diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in
374index 42e5477..69c9ba6 100644
375--- a/doc/net.example.Linux.in
376+++ b/doc/net.example.Linux.in
377@@ -24,7 +24,7 @@
378 # We now support modular networking scripts which means we can easily
379 # add support for new interface types and modules while keeping
380 # compatibility with existing ones.
381-#
382+#
383 # Modules load by default if the package they need is installed. If
384 # you specify a module here that doesn't have its package installed
385 # then you get an error stating which package you need to install.
386@@ -49,7 +49,7 @@
387
388 ##############################################################################
389 # INTERFACE HANDLERS
390-#
391+#
392 # We provide two interface handlers presently: ifconfig and iproute2.
393 # You need one of these to do any kind of network configuration.
394 # For ifconfig support, emerge sys-apps/net-tools
395@@ -297,7 +297,7 @@
396 # Surround each SSID with the " character and separate them with a space
397 # If the first SSID isn't found then it moves onto the next
398 # If this isn't defined then it connects to the first one found
399-#preferred_aps="SSID1 SSID2"
400+#preferred_aps="SSID1 SSID2"
401
402 # You can also define a preferred_aps list per interface
403 #preferred_aps_eth0="SSID3 SSID4"
404@@ -371,13 +371,13 @@
405 # won't have associated then)
406
407 # If you're using anything else to configure wireless on your interface AND
408-# you have installed wpa_supplicant, you need to disable wpa_supplicant
409+# you have installed wpa_supplicant, you need to disable wpa_supplicant
410 #modules="!iwconfig !wpa_supplicant"
411 #or
412 #modules="!wireless"
413
414 ##############################################################################
415-# WIRELESS SSID IN VARIABLES
416+# WIRELESS SSID IN VARIABLES
417 ##############################################################################
418 # Remember to change SSID to your SSID.
419 # Say that your SSID is My NET - the line
420@@ -421,7 +421,7 @@
421 # Notes:
422 # - All clients send the current hostname to the DHCP server by default
423 # - dhcpcd does not daemonize when the lease time is infinite
424-# - udhcp-0.9.3-r3 and earlier do not support getting NTP servers
425+# - udhcp-0.9.3-r3 and earlier do not support getting NTP servers
426 # - pump does not support getting NIS servers
427 # - DHCP tends to erase any existing device information - so add
428 # static addresses after dhcp if you need them
429@@ -467,7 +467,7 @@
430 #fallback_eth0="apipa"
431
432 #-----------------------------------------------------------------------------
433-# ARPING Gateway configuration
434+# ARPING Gateway configuration
435 # and
436 # Automatic Private IP Addressing (APIPA)
437 # For arpingnet / apipa support, emerge net-misc/iputils or net-analyzer/arping
438@@ -527,7 +527,8 @@
439
440 #-----------------------------------------------------------------------------
441 # VLAN (802.1q support)
442-# For VLAN support, emerge net-misc/vconfig
443+# For VLAN support, emerge sys-apps/iproute2
444+# The old vconfig based VLAN support is no longer available.
445
446 # Specify the VLAN numbers for the interface like so
447 # Please ensure your VLAN IDs are NOT zero-padded
448@@ -537,10 +538,17 @@
449 # need it up.
450 #config_eth0="null"
451
452-# You can also configure the VLAN - see for vconfig man page for more details
453-#vconfig_eth0="set_name_type VLAN_PLUS_VID_NO_PAD"
454-#vconfig_vlan1="set_flag 1
455-#set_egress_map 2 6"
456+# You can also configure the VLAN - see for ip man page for more details
457+# To change the vlan interface name. If not set, the standard "iface.vlanid"
458+# will be used
459+#vlan1_name="vlan1"
460+#vlan2_name="eth0.2"
461+# Set the vlan flags
462+#vlan1_flags="reorder_hdr off gvrp on loose_binding on"
463+# Configure in/egress maps
464+#vlan1_ingress="2:6 3:5"
465+#vlan1_egress="1:2"
466+
467 #config_vlan1="172.16.3.1/23"
468 #config_vlan2="172.16.2.1/23"
469
470@@ -553,8 +561,7 @@
471 # This means you do not need to create init scripts in /etc/init.d for each
472 # vlan, you must need to create one for the physical interface.
473 # If you wish to control the configuration of each vlan through a separate
474-# script, or wish to rename the vlan interface to something that vconfig
475-# cannot then you need to do this.
476+# script then you need to do this.
477 #vlan_start_eth0="no"
478
479 # If you do the above then you may want to depend on eth0 like so
480@@ -582,7 +589,7 @@
481
482
483 #-----------------------------------------------------------------------------
484-# Classical IP over ATM
485+# Classical IP over ATM
486 # For CLIP support emerge net-dialup/linux-atm
487
488 # Ensure that you have /etc/atmsigd.conf setup correctly
489@@ -620,7 +627,7 @@
490 #
491 # Here you should specify what pppd plugins you want to use
492 # Available plugins are: pppoe, pppoa, capi, dhcpc, minconn, radius,
493-# radattr, radrealms and winbind
494+# radattr, radrealms and winbind
495 #plugins_ppp0="pppoe" # Required plugin for PPPoE
496 #plugins_ppp0="pppoa vc-encaps" # Required plugin for PPPoA with an option
497 #plugins_ppp0="capi" # Required plugin for ISDN
498@@ -660,7 +667,7 @@
499 # lcp-echo-interval 15 # Send a LCP echo every 15 seconds
500 # lcp-echo-failure 3 # Make peer dead after 3 consecutive
501 # # echo-requests
502-#
503+#
504 # Compression options - use these to completely disable compression
505 # noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp
506 #
507@@ -793,7 +800,7 @@
508 # empty value variable is fine, but at least one of them must be set:
509 # brctl_IFVAR
510
511-# You need to configure the ports to null values so dhcp does not get started
512+# You need to configure the ports to null values so dhcp does not get started
513 #config_eth0="null"
514 #config_eth1="null"
515
516@@ -820,7 +827,7 @@
517 #hairpin_mode_eth0="1"
518
519 #-----------------------------------------------------------------------------
520-# RFC 2684 Bridge Support
521+# RFC 2684 Bridge Support
522 # For RFC 2684 bridge support emerge net-misc/br2684ctl
523
524 # Interface names have to be of the form nas0, nas1, nas2, etc.
525@@ -973,9 +980,75 @@
526 #ifplugd_eth0="--api-mode=wlan"
527 # man ifplugd for more options
528
529+#-----------------------------------------------------------------------------
530+# Interface hardware tuning & configuration via ethtool
531+# If you need to change explicit hardware settings on your network card prior
532+# to bringing the interface up, the following is available.
533+#
534+# For a full listing of settings, please consulting ethtool(8) and the output
535+# of "ethtool --help".
536+#
537+# Multiple entries (seperated by newlines) are supported in all of the
538+# variables as some settings cannot be changed at the same time.
539+#
540+# Valid variable name fragments: change pause coalesce ring offload
541+# change_eeprom identify nfc flash rxfh_indir ntuple
542+
543+# Set Wake-On-Lan to listen for SecureOn MagicPacket(tm), the message level to
544+# notify us of WOL changes, and the SecureOn password to 'DE:AD:BE:EF:CA:FE'.
545+#ethtool_change_eth0="wol gs
546+#msglvl wol on
547+#sopass DE:AD:BE:EF:CA:FE"
548+
549+# Disable pause auto-negotiation and explicitly enable RX and TX pause.
550+#ethtool_pause_eth0="autoneg off
551+#rx on tx on"
552+
553+# Enasble adaptive RX and TX coalescing
554+#ethtool_coalesce_eth0="adaptive-rx on adaptive-tx on"
555+
556+# Change ring buffer settings
557+#ethtool_ring_eth0=""
558+
559+# Enable all offload settings
560+#ethtool_offload_eth0="rx on tx on sg on tso on ufo on gso on gro on lro on"
561+
562+# Change specific bytes in the EEPROM
563+#ethtool_change_eeprom_eth0=""
564+
565+# Run the identify sequence on the interface for 1 second (does not return until completion)
566+#ethtool_identify_eth0="1"
567+
568+# Configure receive network flow classification
569+#ethtool_nfc_eth0="
570+#rx-flow-hash tcp4 f
571+#rx-flow-hash udp4 s"
572+
573+# Flash firmware to all regions
574+#ethtool_flash_eth0="/some/path/firmware1 0"
575+
576+# Flash firmware to region 1
577+#ethtool_flash_eth0="/some/path/firmware2 1"
578+
579+# Set receive flow hash indirection table for even balancing between N receive queues
580+#ethtool_rxfh_indir_eth0="equal 4"
581+
582+# Configure Rx ntuple filters and actions
583+#ethtool_ntuple_eth0=""
584+
585+# Additionally, there is a special control variable, if you need to change the
586+# order of option processing. The default order is:
587+# flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple
588+
589+# Set global order to default
590+#ethtool_order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple"
591+
592+# Hypothetical network card that requires a change-eeprom toggle to enable flashing
593+#ethtool_order_eth0="change-eeprom flash change pause coalesce ring offload nfc rxfh-indir ntuple"
594+
595 ##############################################################################
596 # ADVANCED CONFIGURATION
597-#
598+#
599 # Four functions can be defined which will be called surrounding the
600 # start/stop operations. The functions are called with the interface
601 # name first so that one function can control multiple adapters. An extra two
602@@ -1001,7 +1074,7 @@
603 # if mii-tool "${IFACE}" 2> /dev/null | grep -q 'no link'; then
604 # ewarn "No link on ${IFACE}, aborting configuration"
605 # return 1
606-# fi
607+# fi
608 #
609 # # Test for link on the interface prior to bringing it up. This
610 # # only works on some network adapters and requires the ethtool
611diff --git a/etc/rc.conf.FreeBSD b/etc/rc.conf.FreeBSD
612index 5682e1d..800c6cf 100644
613--- a/etc/rc.conf.FreeBSD
614+++ b/etc/rc.conf.FreeBSD
615@@ -3,6 +3,10 @@
616 # "jail" - FreeBSD jails
617 # "prefix" - Prefix
618 # If unset, the old automagic detection code will be triggered. Said old code
619-# is deprecated and be removed not later than 2010/03/01.
620+# is deprecated and will be removed not later than 2011/03/01.
621+#
622+# This should be set to the value representing what environment this file is
623+# PRESENTLY in, not what virtualization the environment is capable of.
624+# See the OpenRC migration guide for more details.
625 rc_sys=""
626
627diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux
628index 001e9c0..b110a81 100644
629--- a/etc/rc.conf.Linux
630+++ b/etc/rc.conf.Linux
631@@ -8,7 +8,11 @@
632 # "xen0" - Xen0 Domain
633 # "xenU" - XenU Domain
634 # If unset, the old automagic detection code will be triggered. Said old code
635-# is deprecated and be removed not later than 2010/03/01.
636+# is deprecated and will be removed not later than 2011/03/01.
637+#
638+# This should be set to the value representing what environment this file is
639+# PRESENTLY in, not what virtualization the environment is capable of.
640+# See the OpenRC migration guide for more details.
641 rc_sys=""
642
643 ##############################################################################
644diff --git a/etc/rc.conf.NetBSD b/etc/rc.conf.NetBSD
645index 25d86a4..b29000b 100644
646--- a/etc/rc.conf.NetBSD
647+++ b/etc/rc.conf.NetBSD
648@@ -4,6 +4,10 @@
649 # "xen0" - Xen0 Domain
650 # "xenU" - XenU Domain
651 # If unset, the old automagic detection code will be triggered. Said old code
652-# is deprecated and be removed not later than 2010/03/01.
653+# is deprecated and will be removed not later than 2011/03/01.
654+#
655+# This should be set to the value representing what environment this file is
656+# PRESENTLY in, not what virtualization the environment is capable of.
657+# See the OpenRC migration guide for more details.
658 rc_sys=""
659
660diff --git a/etc/rc.conf.in b/etc/rc.conf.in
661index 6aa3613..3c1210b 100644
662--- a/etc/rc.conf.in
663+++ b/etc/rc.conf.in
664@@ -95,7 +95,7 @@
665 # We can set some things on a per service basis, like the nicelevel.
666 #export SSD_NICELEVEL="-19"
667
668-# Pass ulimit parameters
669+# Pass ulimit parameters
670 #rc_ulimit="-u 30"
671
672 # It's possible to define extra dependencies for services like so
673diff --git a/etc/rc.in b/etc/rc.in
674index edd7a5d..d267bec 100644
675--- a/etc/rc.in
676+++ b/etc/rc.in
677@@ -6,7 +6,7 @@
678 # This gives us a nice colour boot :)
679 [ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@"
680
681-# Handle interrupts
682+# Handle interrupts
683 trap : SIGINT
684 trap "echo 'Boot interrupted'; exit 1" SIGQUIT
685
686diff --git a/etc/rc.shutdown.in b/etc/rc.shutdown.in
687index e0231c7..115f212 100644
688--- a/etc/rc.shutdown.in
689+++ b/etc/rc.shutdown.in
690@@ -2,7 +2,7 @@
691 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
692 # All rights reserved. Released under the 2-clause BSD license.
693
694-# Handle interrupts
695+# Handle interrupts
696 trap : SIGINT SIGQUIT
697
698 # Try and use stuff in /lib over anywhere else so we can shutdown
699diff --git a/init.d.misc/dnsmasq.in b/init.d.misc/dnsmasq.in
700index de4bade..958a87e 100644
701--- a/init.d.misc/dnsmasq.in
702+++ b/init.d.misc/dnsmasq.in
703@@ -10,7 +10,7 @@ required_files=/etc/dnsmasq.conf
704 extra_started_commands="reload"
705
706 depend()
707-{
708+{
709 provide dns
710 need localmount net
711 after bootmisc
712diff --git a/init.d.misc/openvpn.in b/init.d.misc/openvpn.in
713index eb1360b..a53a3ed 100644
714--- a/init.d.misc/openvpn.in
715+++ b/init.d.misc/openvpn.in
716@@ -24,7 +24,7 @@ if yesno $openvpn_client; then
717 command_args="$command_args --up $openvpn_up"
718 command_args="$command_args --down $openvpn_down"
719 required_files="$required_files $openvpn_up $openvpn_down"
720-
721+
722 in_background_fake="start stop"
723 start_inactive=YES
724 fi
725@@ -59,7 +59,7 @@ start_pre()
726 sysctl -a | grep -q '\.tap\.' || kldload if_tap
727 fi
728 fi
729-
730+
731 # If the config file does not specify the cd option, we do
732 if ! grep -q "^[ \t]*cd[ \t].*" "$openvpn_config"; then
733 command_args="$command_args --cd $openvpn_dir"
734diff --git a/init.d.misc/sshd.in b/init.d.misc/sshd.in
735index 3d02cab..403f43b 100644
736--- a/init.d.misc/sshd.in
737+++ b/init.d.misc/sshd.in
738@@ -31,5 +31,5 @@ start_pre()
739 eend $? || return 1
740 fi
741
742- $command -t
743+ $command -t
744 }
745diff --git a/init.d.misc/wpa_supplicant.in b/init.d.misc/wpa_supplicant.in
746index f1d65c5..2426905 100644
747--- a/init.d.misc/wpa_supplicant.in
748+++ b/init.d.misc/wpa_supplicant.in
749@@ -43,7 +43,7 @@ find_wireless()
750 done
751 ;;
752 esac
753-
754+
755 return 1
756 }
757
758diff --git a/init.d/Makefile b/init.d/Makefile
759index 6a0323c..b7490d3 100644
760--- a/init.d/Makefile
761+++ b/init.d/Makefile
762@@ -5,12 +5,10 @@ SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in netmount.in \
763 BIN= ${OBJS}
764
765 # Build our old net foo or not
766-_OLDNET_SH= case "${MKOLDNET}" in \
767- [Yy][Ee][Ss]) echo "net.lo";; \
768- *) echo "";; \
769- esac
770-_OLDNET!= ${_OLDNET_SH}
771-_NET_LO= ${_OLDNET}$(shell ${_OLDNET_SH})
772+ifeq (${MKOLDNET},yes)
773+_OLDNET= net.lo
774+endif
775+_NET_LO= ${_OLDNET}
776
777 INSTALLAFTER= _installafter_${_NET_LO}
778 CLEANFILES+= ${_NET_LO}
779diff --git a/init.d/adjkerntz.in b/init.d/adjkerntz.in
780index ee09ac8..807d411 100644
781--- a/init.d/adjkerntz.in
782+++ b/init.d/adjkerntz.in
783@@ -4,7 +4,7 @@
784
785 extra_commands="save"
786
787-description="Sets the local clock to UTC or Local Time."
788+description="Sets the local clock to UTC or Local Time."
789 description_save="Saves the current time in the BIOS."
790
791 : ${clock:=${CLOCK:-UTC}}
792@@ -26,7 +26,7 @@ depend()
793 }
794
795 start()
796-{
797+{
798 ebegin "Starting the System Clock Adjuster [${utc}]"
799 if [ "$clock" != "UTC" ]; then
800 echo >/etc/wall_cmos_clock
801diff --git a/init.d/bootmisc.in b/init.d/bootmisc.in
802index 1298740..320e7e8 100644
803--- a/init.d/bootmisc.in
804+++ b/init.d/bootmisc.in
805@@ -88,7 +88,7 @@ start()
806 eend 1 "failed to create needed directory $x"
807 return 1
808 fi
809- fi
810+ fi
811 done
812
813 if dir_writeable /var/run; then
814@@ -137,7 +137,7 @@ start()
815 # Make sure our X11 stuff have the correct permissions
816 # Omit the chown as bootmisc is run before network is up
817 # and users may be using lame LDAP auth #139411
818- rm -rf /tmp/.ICE-unix /tmp/.X11-unix
819+ rm -rf /tmp/.ICE-unix /tmp/.X11-unix
820 mkdir -p /tmp/.ICE-unix /tmp/.X11-unix
821 chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix
822 if [ -x /sbin/restorecon ]; then
823diff --git a/init.d/consolefont.in b/init.d/consolefont.in
824index d3acd75..75c2fd1 100644
825--- a/init.d/consolefont.in
826+++ b/init.d/consolefont.in
827@@ -61,12 +61,6 @@ start()
828 done
829 cp "$font" "$RC_LIBEXECDIR"/console
830 echo "${font##*/}" >"$RC_LIBEXECDIR"/console/font
831- if yesno ${unicode:-${UNICODE}}; then
832- echo "" > "$RC_LIBEXECDIR"/console/unicode
833- else
834- rm -f "$RC_LIBEXECDIR"/console/unicode
835- fi
836-
837 fi
838
839 return $retval
840diff --git a/init.d/hostid.in b/init.d/hostid.in
841index 26ea9d6..a12e34a 100644
842--- a/init.d/hostid.in
843+++ b/init.d/hostid.in
844@@ -68,7 +68,7 @@ reset()
845 start()
846 {
847 if [ -r "$hostid_file" ]; then
848- _set $(cat "$hostid_file")
849+ _set $(cat "$hostid_file")
850 else
851 reset
852 fi
853diff --git a/init.d/hwclock.in b/init.d/hwclock.in
854index e99900f..640d997 100644
855--- a/init.d/hwclock.in
856+++ b/init.d/hwclock.in
857@@ -4,7 +4,7 @@
858
859 extra_commands="save show"
860
861-description="Sets the local clock to UTC or Local Time."
862+description="Sets the local clock to UTC or Local Time."
863 description_save="Saves the current time in the BIOS."
864 description_show="Displays the current time in the BIOS."
865
866@@ -87,17 +87,21 @@ start()
867 _hwclock --adjust $utc_cmd
868 retval=$(($retval + $?))
869 fi
870-
871+
872 # If setting UTC, don't bother to run hwclock when first booting
873 # as that's the default
874 if [ "$PREVLEVEL" != N -o \
875- "$utc_cmd}" != --utc -o \
876+ "$utc_cmd" != --utc -o \
877 -n "$clock_args" ];
878 then
879- _hwclock --hctosys $utc_cmd $clock_args
880+ if yesno $clock_hctosys; then
881+ _hwclock --hctosys $utc_cmd $clock_args
882+ else
883+ _hwclock --systz $utc_cmd $clock_args
884+ fi
885 retval=$(($retval + $?))
886 fi
887-
888+
889 eend $retval "Failed to set the system clock"
890
891 return 0
892@@ -126,7 +130,7 @@ stop()
893 _hwclock --systohc $utc_cmd $clock_args
894 retval=$?
895
896- eend $retval "Failed to sync clocks"
897+ eend $retval "Failed to sync clocks"
898 }
899
900 save()
901diff --git a/init.d/ipfw.in b/init.d/ipfw.in
902index 9d6faa4..ea6e22a 100644
903--- a/init.d/ipfw.in
904+++ b/init.d/ipfw.in
905@@ -40,11 +40,11 @@ init() {
906 ipfw add deny all from any to 127.0.0.0/8
907 ipfw add deny ip from 127.0.0.0/8 to any
908
909- if have_ip6; then
910+ if have_ip6; then
911 ipfw add pass ip6 from any to any via lo0
912 ipfw add deny ip6 from any to ::1
913 ipfw add deny ip6 from ::1 to any
914-
915+
916 ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp
917 ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp
918 ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp
919@@ -78,7 +78,7 @@ start() {
920 ipfw add pass udp from 0.0.0.0 68 to 255.255.255.255 67 out
921 ipfw add pass udp from any 67 to me 68 in
922 ipfw add pass udp from any 67 to 255.255.255.255 68 in
923- # Some servers will ping the IP while trying to decide if it's
924+ # Some servers will ping the IP while trying to decide if it's
925 # still in use.
926 ipfw add pass icmp from any to any icmptype 8
927
928@@ -88,11 +88,11 @@ start() {
929 if have_ip6; then
930 # Allow ICMPv6 destination unreach
931 ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp
932-
933+
934 # Allow NS/NA/toobig (don't filter it out)
935 ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp
936 fi
937-
938+
939 # Add permits for this workstations published services below
940 # Only IPs and nets in firewall_allowservices is allowed in.
941 for i in $ipfw_ip_in; do
942@@ -107,7 +107,7 @@ start() {
943 for i in $ipfw_ip_trust; do
944 ipfw add pass ip from $i to me
945 done
946-
947+
948 ipfw add 65000 count ip from any to any
949
950 # Drop packets to ports where we don't want logging
951@@ -117,7 +117,7 @@ start() {
952
953 # Broadcasts and muticasts
954 ipfw add deny ip from any to 255.255.255.255
955- ipfw add deny ip from any to 224.0.0.0/24
956+ ipfw add deny ip from any to 224.0.0.0/24
957
958 # Noise from routers
959 ipfw add deny udp from any to any 520 in
960diff --git a/init.d/keymaps.in b/init.d/keymaps.in
961index f37fbb5..776f3bb 100644
962--- a/init.d/keymaps.in
963+++ b/init.d/keymaps.in
964@@ -17,7 +17,7 @@ start()
965 : ${unicode:=$UNICODE}
966 : ${keymap:=$KEYMAP}
967 : ${extended_keymaps:=$EXTENDED_KEYMAPS}
968- : ${windowkeys:=$SET_WINDOWSKEYS}
969+ : ${windowkeys:=$SET_WINDOWSKEYS}
970 : ${fix_euro:=$FIX_EURO}
971 : ${dumpkeys_charset:=${DUMPKEYS_CHARSET}}
972
973diff --git a/init.d/killprocs.in b/init.d/killprocs.in
974index d12f0f6..7132e9e 100644
975--- a/init.d/killprocs.in
976+++ b/init.d/killprocs.in
977@@ -15,7 +15,7 @@ start()
978 killall5 -15
979 sleep 1
980 eend 0
981- ebegin "Killing remaining processes"
982+ ebegin "Killing remaining processes"
983 killall5 -9
984 sleep 1
985 eend 0
986diff --git a/init.d/local.in b/init.d/local.in
987index 63d5e92..4db492e 100644
988--- a/init.d/local.in
989+++ b/init.d/local.in
990@@ -2,7 +2,7 @@
991 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
992 # All rights reserved. Released under the 2-clause BSD license.
993
994-description="Executes user commands in /etc/conf.d/local"
995+description="Executes user programs in @SYSCONFDIR@/local.d"
996
997 depend()
998 {
999@@ -12,22 +12,40 @@ depend()
1000
1001 start()
1002 {
1003- ebegin "Starting local"
1004+ einfo "Starting local"
1005+
1006+ local file
1007+ for file in @SYSCONFDIR@/local.d/*.start ; do
1008+ [ -x "$file" ] && "$file"
1009+ done
1010
1011 if type local_start >/dev/null 2>&1; then
1012+ ewarn "@SYSCONFDIR@/conf.d/local should be removed."
1013+ ewarn "Please move the code from the local_start function"
1014+ ewarn "to scripts with an .start extension"
1015+ ewarn "in @SYSCONFDIR@/local.d"
1016 local_start
1017 fi
1018
1019- eend $? "Failed to start local"
1020+ return 0
1021 }
1022
1023 stop()
1024 {
1025- ebegin "Stopping local"
1026+ einfo "Stopping local"
1027+
1028+ local file
1029+ for file in @SYSCONFDIR@/local.d/*.stop; do
1030+ [ -x "$file" ] && "$file"
1031+ done
1032
1033 if type local_start >/dev/null 2>&1; then
1034+ ewarn "@SYSCONFDIR@/conf.d/local should be removed."
1035+ ewarn "Please move the code from the local_stop function"
1036+ ewarn "to scripts with an .stop extension"
1037+ ewarn "in @SYSCONFDIR@/local.d"
1038 local_stop
1039 fi
1040
1041- eend $? "Failed to stop local"
1042+ return 0
1043 }
1044diff --git a/init.d/localmount.in b/init.d/localmount.in
1045index 2a8e96f..e2ea801 100644
1046--- a/init.d/localmount.in
1047+++ b/init.d/localmount.in
1048@@ -58,8 +58,8 @@ stop()
1049
1050 . "$RC_LIBEXECDIR"/sh/rc-mount.sh
1051
1052- # Umount loopback devices
1053- einfo "Unmounting loopback devices"
1054+ # Umount loop devices
1055+ einfo "Unmounting loop devices"
1056 eindent
1057 do_unmount "umount -d" --skip-point-regex "$no_umounts_r" \
1058 --node-regex "^/dev/loop"
1059diff --git a/init.d/moused.in b/init.d/moused.in
1060index a362228..33b8d02 100644
1061--- a/init.d/moused.in
1062+++ b/init.d/moused.in
1063@@ -21,13 +21,13 @@ depend()
1064
1065 start()
1066 {
1067- ebegin "Starting $name"
1068+ ebegin "Starting $name"
1069
1070 if [ -z "$moused_device" ]; then
1071 local dev=
1072 for dev in /dev/psm[0-9]* /dev/ums[0-9]*; do
1073 [ -c "$dev" ] || continue
1074- [ -e /var/run/moused-"${dev##*/}".pid ] && continue
1075+ [ -e /var/run/moused-"${dev##*/}".pid ] && continue
1076 moused_device=$dev
1077 eindent
1078 einfo "Using mouse on $moused_device"
1079@@ -37,7 +37,7 @@ start()
1080 fi
1081
1082 if [ -z "$moused_device" ]; then
1083- eend 1 "No mouse device found"
1084+ eend 1 "No mouse device found"
1085 return 1
1086 fi
1087
1088@@ -49,7 +49,7 @@ start()
1089 --pidfile "$pidfile" \
1090 -- $args -p "$moused_device" -I "$pidfile"
1091 local retval=$?
1092-
1093+
1094 if [ $retval = 0 ]; then
1095 local ttyv=
1096 for ttyv in /dev/ttyv*; do
1097@@ -57,6 +57,6 @@ start()
1098 : $((retval+= $?))
1099 done
1100 fi
1101-
1102+
1103 eend $retval "Failed to start moused"
1104 }
1105diff --git a/init.d/net.lo.in b/init.d/net.lo.in
1106index 30d0186..b194a23 100644
1107--- a/init.d/net.lo.in
1108+++ b/init.d/net.lo.in
1109@@ -180,7 +180,7 @@ _gen_module_list()
1110 ${update} || return 0
1111 fi
1112
1113- einfo "Caching network module dependencies"
1114+ einfo "Caching network module dependencies"
1115 # Run in a subshell to protect the main script
1116 (
1117 after() {
1118@@ -215,7 +215,7 @@ _gen_module_list()
1119
1120 for MODULE in "${MODULESDIR}"/*.sh; do
1121 sh -n "${MODULE}" || continue
1122- . "${MODULE}" || continue
1123+ . "${MODULE}" || continue
1124 MODULE=${MODULE#${MODULESDIR}/}
1125 MODULE=${MODULE%.sh}
1126 eval ${MODULE}_depend
1127@@ -343,7 +343,7 @@ _load_modules()
1128
1129 # Wrap our provides
1130 local f=
1131- for f in pre_start start post_start; do
1132+ for f in pre_start start post_start; do
1133 eval "${provides}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
1134 done
1135
1136@@ -357,7 +357,7 @@ _load_modules()
1137 *" ${mod} "*)
1138 eval x=\$module_${mod}_provides
1139 [ -z "${x}" ] && continue
1140- for f in pre_start start post_start; do
1141+ for f in pre_start start post_start; do
1142 eval "${x}_${f}() { [ "$(command -v "${mod}_${f}")" = "${mod}_${f}" ] || return 0; ${mod}_${f} \"\$@\"; }"
1143 done
1144 eval module_${x}_providedby="${mod}"
1145@@ -379,7 +379,7 @@ _load_modules()
1146 MODULES="${MODULES}${MODULES:+ }${mod}"
1147 done
1148 else
1149- for mod in ${LIST}; do
1150+ for mod in ${LIST}; do
1151 MODULES="${mod}${MODULES:+ }${MODULES}"
1152 done
1153 fi
1154@@ -395,7 +395,7 @@ _load_config()
1155 config_index=0
1156 local IFS="$__IFS"
1157 set -- ${config}
1158-
1159+
1160 # We should support a space separated array for cidr configs
1161 if [ $# = 1 ]; then
1162 unset IFS
1163@@ -415,7 +415,7 @@ _load_config()
1164 config_0="127.0.0.1/8"
1165 config_index=1
1166 fi
1167- else
1168+ else
1169 if [ -z "$1" ]; then
1170 ewarn "No configuration specified; defaulting to DHCP"
1171 config_0="dhcp"
1172@@ -500,7 +500,7 @@ start()
1173 fi
1174
1175 _up 2>/dev/null
1176-
1177+
1178 for module in ${MODULES}; do
1179 if [ "$(command -v "${module}_pre_start")" = "${module}_pre_start" ]; then
1180 ${module}_pre_start || exit $?
1181@@ -527,7 +527,7 @@ start()
1182 _load_config
1183 config_index=0
1184
1185- eval our_metric=\$metric_${IFVAR}
1186+ eval our_metric=\$metric_${IFVAR}
1187 if [ -n "${our_metric}" ]; then
1188 metric=${our_metric}
1189 elif [ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
1190@@ -536,7 +536,7 @@ start()
1191
1192 while true; do
1193 eval config=\$config_${config_index}
1194- [ -z "${config}" ] && break
1195+ [ -z "${config}" ] && break
1196
1197 set -- ${config}
1198 ebegin "$1"
1199@@ -638,7 +638,7 @@ ${routes}"
1200 if [ "$(command -v postup)" = "postup" ]; then
1201 ebegin "Running postup"
1202 eindent
1203- postup
1204+ postup
1205 eoutdent
1206 fi
1207
1208diff --git a/init.d/netmount.in b/init.d/netmount.in
1209index 88ce16f..3bdc63b 100644
1210--- a/init.d/netmount.in
1211+++ b/init.d/netmount.in
1212@@ -39,7 +39,7 @@ depend()
1213 }
1214
1215 start()
1216-{
1217+{
1218 local myneed= myuse= pmap="portmap" nfsmounts=
1219 [ -x @SYSCONFDIR@/init.d/rpcbind ] && pmap="rpcbind"
1220
1221diff --git a/init.d/network.in b/init.d/network.in
1222index 01e88ce..a563332 100644
1223--- a/init.d/network.in
1224+++ b/init.d/network.in
1225@@ -222,7 +222,7 @@ start()
1226 einfo "Starting network"
1227 routeflush
1228 if [ "$RC_UNAME" = "Linux" ]; then
1229- ifconfig lo 127.0.0.1 netmask 255.0.0.0 || cr=1
1230+ ifconfig lo 127.0.0.1 netmask 255.0.0.0 || cr=1
1231 route add -net 127.0.0.0 netmask 255.0.0.0 \
1232 gw 127.0.0.1 reject 2>/dev/null
1233 else
1234@@ -287,7 +287,7 @@ start()
1235 [ $r != 0 ]
1236 veend $?
1237 fi
1238-
1239+
1240 if [ -n "$defaultroute" ]; then
1241 ebegin "Setting default route $defaultroute"
1242 route add default $defaultroute
1243diff --git a/init.d/pf.in b/init.d/pf.in
1244index 15c9fc5..a36df26 100644
1245--- a/init.d/pf.in
1246+++ b/init.d/pf.in
1247@@ -44,7 +44,7 @@ reload()
1248 {
1249 ebegin "Reloading $name rules."
1250 pfctl -q -n -f "$pf_conf" && \
1251- {
1252+ {
1253 # Flush everything but existing state entries that way when
1254 # rules are read in, it doesn't break established connections.
1255 pfctl -q -Fnat -Fqueue -Frules -FSources -Finfo -FTables -Fosfp
1256diff --git a/init.d/swap-blk.in b/init.d/swap-blk.in
1257index 3c1c52c..f7d4367 100644
1258--- a/init.d/swap-blk.in
1259+++ b/init.d/swap-blk.in
1260@@ -13,11 +13,11 @@ start()
1261 ebegin "Activating block swap devices"
1262 swapctl -A -t blk >/dev/null
1263 eend 0 # If swapon has nothing todo it errors, so always return 0
1264-}
1265+}
1266
1267 stop()
1268 {
1269 ebegin "Deactivating block swap devices"
1270 swapctl -U -t blk >/dev/null
1271- eend 0
1272+ eend 0
1273 }
1274diff --git a/init.d/swap.in b/init.d/swap.in
1275index d99b9b8..a1a931f 100644
1276--- a/init.d/swap.in
1277+++ b/init.d/swap.in
1278@@ -16,7 +16,7 @@ start()
1279 *) swapon -a >/dev/null;;
1280 esac
1281 eend 0 # If swapon has nothing todo it errors, so always return 0
1282-}
1283+}
1284
1285 stop()
1286 {
1287@@ -31,5 +31,5 @@ stop()
1288 NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;;
1289 *) swapoff -a >/dev/null;;
1290 esac
1291- eend 0
1292+ eend 0
1293 }
1294diff --git a/init.d/syscons.in b/init.d/syscons.in
1295index cb584b3..ba22bf5 100644
1296--- a/init.d/syscons.in
1297+++ b/init.d/syscons.in
1298@@ -15,13 +15,13 @@ start() {
1299 done
1300 eend $?
1301 fi
1302-
1303+
1304 if [ -n "$keymap" ]; then
1305 ebegin "Setting keymap to $keymap"
1306 kbdcontrol -l $keymap </dev/console
1307 eend $?
1308 fi
1309-
1310+
1311 if [ -n "$keyrate" ]; then
1312 ebegin "Setting keyrate to $keyrate"
1313 kbdcontrol -r $keyrate </dev/console
1314@@ -40,7 +40,7 @@ start() {
1315 done
1316 eoutdent
1317 fi
1318-
1319+
1320 if [ -n "$cursor" ]; then
1321 ebegin "Setting cursor"
1322 vidcontrol -c $cursor
1323diff --git a/init.d/termencoding.in b/init.d/termencoding.in
1324index 734d220..fea27ee 100644
1325--- a/init.d/termencoding.in
1326+++ b/init.d/termencoding.in
1327@@ -31,5 +31,16 @@ start()
1328 printf "\033%s" "$termencoding" >$ttydev$n
1329 n=$(($n + 1))
1330 done
1331+
1332+ # Save the encoding for use immediately at boot
1333+ if [ -w "$RC_LIBEXECDIR" ]; then
1334+ mkdir -p "$RC_LIBEXECDIR"/console
1335+ if yesno ${unicode:-${UNICODE}}; then
1336+ echo "" > "$RC_LIBEXECDIR"/console/unicode
1337+ else
1338+ rm -f "$RC_LIBEXECDIR"/console/unicode
1339+ fi
1340+ fi
1341+
1342 eend 0
1343 }
1344diff --git a/init.d/ttys.in b/init.d/ttys.in
1345index 178f182..b8a051d 100644
1346--- a/init.d/ttys.in
1347+++ b/init.d/ttys.in
1348@@ -2,7 +2,7 @@
1349 # Copyright (c) 2008 Roy Marples <roy@marples.name>
1350 # All rights reserved. Released under the 2-clause BSD license.
1351
1352-depend()
1353+depend()
1354 {
1355 after fsck
1356 keyword -prefix
1357@@ -13,7 +13,7 @@ start()
1358 ebegin "Setting tty flags"
1359 ttyflags -a
1360 eend $? || return $?
1361-
1362+
1363 if [ -c /dev/ttyp0 ]; then
1364 chmod 666 /dev/tty[p-uw-zP-T][0-9a-zA-Z]
1365 fi
1366diff --git a/init.d/wscons.in b/init.d/wscons.in
1367index 3b18a24..916e27b 100644
1368--- a/init.d/wscons.in
1369+++ b/init.d/wscons.in
1370@@ -27,10 +27,10 @@ start()
1371 font)
1372 cmd=$wsfld
1373 [ "$arg2" != "-" ] && cmd="$cmd -w $arg2"
1374- [ "$arg3" != "-" ] && cmd="$cmd -h $arg3"
1375+ [ "$arg3" != "-" ] && cmd="$cmd -h $arg3"
1376 [ "$arg4" != "-" ] && cmd="$cmd -e $arg4"
1377 cmd="$cmd -N $arg1 $arg5"
1378- eval "$cmd"
1379+ eval "$cmd"
1380 ;;
1381
1382 screen)
1383diff --git a/local.d/Makefile b/local.d/Makefile
1384new file mode 100644
1385index 0000000..7a7d31d
1386--- /dev/null
1387+++ b/local.d/Makefile
1388@@ -0,0 +1,6 @@
1389+DIR= ${LOCALDIR}
1390+CONF= README
1391+
1392+MK= ../mk
1393+include ${MK}/os.mk
1394+include ${MK}/scripts.mk
1395diff --git a/local.d/README b/local.d/README
1396new file mode 100644
1397index 0000000..d3c1156
1398--- /dev/null
1399+++ b/local.d/README
1400@@ -0,0 +1,9 @@
1401+This directory should contain programs or scripts which are to be run
1402+when the local service is started or stopped.
1403+
1404+If a file in this directory is executable and it has a .start extension,
1405+it will be run when the local service is started. If a file is
1406+executable and it has a .stop extension, it will be run when the local
1407+service is stopped.
1408+
1409+All files are processed in lexical order.
1410diff --git a/mk/.mk b/mk/.mk
1411deleted file mode 100644
1412index e69de29..0000000
1413diff --git a/mk/cc.mk b/mk/cc.mk
1414index 2c912d5..06556f0 100644
1415--- a/mk/cc.mk
1416+++ b/mk/cc.mk
1417@@ -5,9 +5,9 @@ CFLAGS?= -O2
1418
1419 # Default to using the C99 standard
1420 CSTD?= c99
1421-_CSTD_SH= if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi
1422-_CSTD!= ${_CSTD_SH}
1423-CFLAGS+= ${_CSTD}$(shell ${_CSTD_SH})
1424+ifneq (${CSTD},)
1425+CFLAGS+= -std=${CSTD}
1426+endif
1427
1428 # Try and use some good cc flags if we're building from git
1429 # We don't use -pedantic as it will warn about our perfectly valid
1430@@ -29,5 +29,5 @@ _CC_FLAGS_SH= for f in ${_CCFLAGS}; do \
1431 ${CC} $$f -S -xc -o /dev/null - ; \
1432 then printf "%s" "$$f "; fi \
1433 done;
1434-_CC_FLAGS!= ${_CC_FLAGS_SH}
1435-CFLAGS+= ${_CC_FLAGS}$(shell ${_CC_FLAGS_SH})
1436+_CC_FLAGS:= $(shell ${_CC_FLAGS_SH})
1437+CFLAGS+= ${_CC_FLAGS}
1438diff --git a/mk/debug.mk b/mk/debug.mk
1439index 67e9ad1..bc98b58 100644
1440--- a/mk/debug.mk
1441+++ b/mk/debug.mk
1442@@ -3,14 +3,14 @@
1443 # All rights reserved. Released under the 2-clause BSD license.
1444
1445 _RC_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-DRC_DEBUG";; esac
1446-_RC_DEBUG!= ${_RC_DEBUG_SH}
1447-CPPFLAGS+= ${_RC_DEBUG}$(shell ${_RC_DEBUG_SH})
1448+_RC_DEBUG:= $(shell ${_RC_DEBUG_SH})
1449+CPPFLAGS+= ${_RC_DEBUG}
1450
1451 # Should we enable this with a different flag?
1452 _LD_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-Wl,--rpath=../librc -Wl,--rpath=../libeinfo";; esac
1453-_LD_DEBUG!= ${_LD_DEBUG_SH}
1454-LDFLAGS+= ${_LD_DEBUG}$(shell ${_LD_DEBUG_SH})
1455+_LD_DEBUG:= $(shell ${_LD_DEBUG_SH})
1456+LDFLAGS+= ${_LD_DEBUG}
1457
1458 _GGDB_SH= case "${DEBUG}" in "") echo "";; *) echo "-ggdb";; esac
1459-_GGDB!= ${_GGDB_SH}
1460-CFLAGS+= ${_GGDB}$(shell ${_GGDB_SH})
1461+_GGDB:= $(shell ${_GGDB_SH})
1462+CFLAGS+= ${_GGDB}
1463diff --git a/mk/depend-.mk b/mk/depend-.mk
1464deleted file mode 100644
1465index 9d13b52..0000000
1466--- a/mk/depend-.mk
1467+++ /dev/null
1468@@ -1,2 +0,0 @@
1469-# This space left intentionally blank because gmake does not load .depend
1470-# by default
1471diff --git a/mk/depend-gmake.mk b/mk/depend-gmake.mk
1472deleted file mode 100644
1473index 947843e..0000000
1474--- a/mk/depend-gmake.mk
1475+++ /dev/null
1476@@ -1,3 +0,0 @@
1477-# Tell gmake to include the optional dependency file.
1478-# This sucks, but I don't know any other way of portably making this work.
1479--include .depend
1480diff --git a/mk/depend.mk b/mk/depend.mk
1481index 067c1ef..44af378 100644
1482--- a/mk/depend.mk
1483+++ b/mk/depend.mk
1484@@ -10,9 +10,4 @@ IGNOREFILES+= .depend
1485
1486 depend: .depend extra_depend
1487
1488-# Nasty hack. depend-.mk is a blank file, depend-gmake.mk has a gmake specific
1489-# command to optionally include .depend.
1490-# Someone should patch gmake to optionally include .depend if it exists.
1491-_INC_DEP= $(shell if ${MAKE} --version | grep -q "^GNU "; then \
1492- echo "gmake"; else echo ""; fi)
1493-include ${MK}/depend-${_INC_DEP}.mk
1494+-include .depend
1495diff --git a/mk/dist.mk b/mk/dist.mk
1496index 24ce130..fb58edc 100644
1497--- a/mk/dist.mk
1498+++ b/mk/dist.mk
1499@@ -9,14 +9,21 @@ DISTFILE?= ${DISTPREFIX}.tar.bz2
1500 CLEANFILES+= ${NAME}-*.tar.bz2
1501
1502 _SNAP_SH= date -u +%Y%m%d%H%M
1503-_SNAP!= ${_SNAP_SH}
1504-SNAP= ${_SNAP}$(shell ${_SNAP_SH})
1505+_SNAP:= $(shell ${_SNAP_SH})
1506+SNAP= ${_SNAP}
1507 SNAPDIR= ${DISTPREFIX}-${SNAP}
1508 SNAPFILE= ${SNAPDIR}.tar.bz2
1509
1510 dist:
1511 git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE}
1512
1513+distcheck: dist
1514+ rm -rf ${DISTPREFIX}
1515+ tar xf ${DISTFILE}
1516+ MAKEFLAGS= $(MAKE) -C ${DISTPREFIX}
1517+ MAKEFLAGS= $(MAKE) -C ${DISTPREFIX} check
1518+ rm -rf ${DISTPREFIX}
1519+
1520 snapshot:
1521 rm -rf /tmp/${SNAPDIR}
1522 mkdir /tmp/${SNAPDIR}
1523diff --git a/mk/git.mk b/mk/git.mk
1524index 54a98ef..62cae5a 100644
1525--- a/mk/git.mk
1526+++ b/mk/git.mk
1527@@ -4,5 +4,5 @@ _GITVER_SH= if git rev-parse --short HEAD >/dev/null 2>&1; then \
1528 else \
1529 echo ""; \
1530 fi
1531-_GITVER!= ${_GITVER_SH}
1532-GITVER= ${_GITVER}$(shell ${_GITVER_SH})
1533+_GITVER:= $(shell ${_GITVER_SH})
1534+GITVER= ${_GITVER}
1535diff --git a/mk/lib.mk b/mk/lib.mk
1536index 16c16a5..a5682dd 100644
1537--- a/mk/lib.mk
1538+++ b/mk/lib.mk
1539@@ -38,7 +38,7 @@ ${SHLIB_NAME}: ${SOBJS}
1540 @${ECHO} building shared library $@
1541 @rm -f $@ ${SHLIB_LINK}
1542 @ln -fs $@ ${SHLIB_LINK}
1543- ${CC} ${LDFLAGS} -shared -Wl,-x \
1544+ ${CC} ${CFLAGS} ${LDFLAGS} -shared -Wl,-x \
1545 -o $@ -Wl,-soname,${SONAME} \
1546 ${SOBJS} ${LDADD}
1547
1548diff --git a/mk/ncurses.mk b/mk/ncurses.mk
1549deleted file mode 100644
1550index d93e8fb..0000000
1551--- a/mk/ncurses.mk
1552+++ /dev/null
1553@@ -1,3 +0,0 @@
1554-LIBTERMCAP?= -lncurses
1555-CPPFLAGS+= -DHAVE_TERMCAP
1556-LDADD+= ${LIBTERMCAP}
1557diff --git a/mk/os.mk b/mk/os.mk
1558index 09f2aef..0cde8ae 100644
1559--- a/mk/os.mk
1560+++ b/mk/os.mk
1561@@ -4,8 +4,8 @@
1562 # Generic definitions
1563
1564 _OS_SH= uname -s
1565-_OS!= ${_OS_SH}
1566-OS?= ${_OS}$(shell ${_OS_SH})
1567+_OS:= $(shell ${_OS_SH})
1568+OS?= ${_OS}
1569 include ${MK}/os-${OS}.mk
1570
1571 RC_LIB= /$(LIBNAME)/rc
1572diff --git a/mk/pam.mk b/mk/pam.mk
1573index 65115d5..15ffb54 100644
1574--- a/mk/pam.mk
1575+++ b/mk/pam.mk
1576@@ -1,6 +1,10 @@
1577+ifeq (${MKPAM},pam)
1578 LIBPAM?= -lpam
1579 CPPFLAGS+= -DHAVE_PAM
1580 LDADD+= ${LIBPAM}
1581
1582 PAMDIR?= /etc/pam.d
1583 PAMMODE?= 0644
1584+else ifneq (${MKPAM},)
1585+$(error if MKPAM is defined, it must be "pam")
1586+endif
1587diff --git a/mk/prog.mk b/mk/prog.mk
1588index 33929fb..5bddf18 100644
1589--- a/mk/prog.mk
1590+++ b/mk/prog.mk
1591@@ -15,8 +15,8 @@ _DYNLINK_SH= if test "${PREFIX}" = "" && test -e /libexec/ld.elf_so; then \
1592 else \
1593 echo ""; \
1594 fi
1595-_DYNLINK!= ${_DYNLINK_SH}
1596-LDFLAGS+= ${_DYNLINK}$(shell ${_DYNLINK_SH})
1597+_DYNLINK:= $(shell ${_DYNLINK_SH})
1598+LDFLAGS+= ${_DYNLINK}
1599 LDFLAGS+= -Wl,-rpath=${PREFIX}/${LIBNAME}
1600 LDFLAGS+= ${PROGLDFLAGS}
1601
1602@@ -28,7 +28,7 @@ all: depend ${PROG}
1603 ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
1604
1605 ${PROG}: ${SCRIPTS} ${OBJS}
1606- ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
1607+ ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
1608
1609 clean:
1610 rm -f ${CLEANFILES}
1611diff --git a/mk/scripts.mk b/mk/scripts.mk
1612index bd7ec6b..3517aab 100644
1613--- a/mk/scripts.mk
1614+++ b/mk/scripts.mk
1615@@ -8,11 +8,11 @@ include ${MK}/os.mk
1616 OBJS+= ${SRCS:.in=}
1617
1618 _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
1619-_PKG_SED!= ${_PKG_SED_SH}
1620+_PKG_SED:= $(shell ${_PKG_SED_SH})
1621 _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
1622-_LCL_SED!= ${_LCL_SED_SH}
1623+_LCL_SED:= $(shell ${_LCL_SED_SH})
1624
1625-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})
1626+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}
1627
1628 # Tweak our shell scripts
1629 .SUFFIXES: .sh.in .in
1630diff --git a/mk/sys.mk b/mk/sys.mk
1631index e22731b..b68afdb 100644
1632--- a/mk/sys.mk
1633+++ b/mk/sys.mk
1634@@ -12,8 +12,8 @@ SH= /bin/sh
1635
1636 PREFIX?=
1637 _UPREFIX_SH= case "${PREFIX}" in "") echo /usr;; *) echo "${PREFIX}";; esac
1638-_UPREFIX!= ${_UPREFIX_SH}
1639-UPREFIX= ${_UPREFIX}$(shell ${_UPREFIX_SH})
1640+_UPREFIX:= $(shell ${_UPREFIX_SH})
1641+UPREFIX= ${_UPREFIX}
1642 LOCAL_PREFIX= /usr/local
1643
1644 PICFLAG?= -fPIC
1645@@ -21,6 +21,7 @@ PICFLAG?= -fPIC
1646 SYSCONFDIR?= ${PREFIX}/etc
1647 INITDIR?= ${SYSCONFDIR}/init.d
1648 CONFDIR?= ${SYSCONFDIR}/conf.d
1649+LOCALDIR?= ${SYSCONFDIR}/local.d
1650
1651 BINDIR?= ${PREFIX}/sbin
1652 BINMODE?= 0755
1653@@ -29,8 +30,8 @@ INCDIR?= ${UPREFIX}/include
1654 INCMODE?= 0444
1655
1656 _LIBNAME_SH= case `readlink /lib` in /lib64|lib64) echo "lib64";; *) echo "lib";; esac
1657-_LIBNAME!= ${_LIBNAME_SH}
1658-LIBNAME?= ${_LIBNAME}$(shell ${_LIBNAME_SH})
1659+_LIBNAME:= $(shell ${_LIBNAME_SH})
1660+LIBNAME?= ${_LIBNAME}
1661 LIBDIR?= ${UPREFIX}/${LIBNAME}
1662 LIBMODE?= 0444
1663 SHLIBDIR?= ${PREFIX}/${LIBNAME}
1664diff --git a/mk/termcap.mk b/mk/termcap.mk
1665index 7a603e3..b716276 100644
1666--- a/mk/termcap.mk
1667+++ b/mk/termcap.mk
1668@@ -1,3 +1,11 @@
1669+ifeq (${MKTERMCAP},ncurses)
1670+LIBTERMCAP?= -lncurses
1671+CPPFLAGS+= -DHAVE_TERMCAP
1672+LDADD+= ${LIBTERMCAP}
1673+else ifeq (${MKTERMCAP},termcap)
1674 LIBTERMCAP?= -ltermcap
1675 CPPFLAGS+= -DHAVE_TERMCAP
1676 LDADD+= ${LIBTERMCAP}
1677+else ifneq (${MKTERMCAP},)
1678+$(error If MKTERMCAP is defined, it must be ncurses or termcap)
1679+endif
1680diff --git a/net/Makefile.Linux b/net/Makefile.Linux
1681index 7006d74..f7fb087 100644
1682--- a/net/Makefile.Linux
1683+++ b/net/Makefile.Linux
1684@@ -1,7 +1,7 @@
1685 SRCS+= iwconfig.sh.in
1686 INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
1687- ccwgroup.sh clip.sh iproute2.sh ifplugd.sh ip6to4.sh ipppd.sh \
1688- iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
1689+ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
1690+ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
1691 vlan.sh
1692
1693 .SUFFIXES: .sh.Linux.in
1694diff --git a/net/apipa.sh b/net/apipa.sh
1695index f4e5f73..0ca3bda 100644
1696--- a/net/apipa.sh
1697+++ b/net/apipa.sh
1698@@ -21,7 +21,7 @@ apipa_start()
1699 local iface="$1" i1= i2= addr= i=0
1700
1701 _exists true || return 1
1702-
1703+
1704 einfo "Searching for free addresses in 169.254.0.0/16"
1705 eindent
1706
1707diff --git a/net/arping.sh b/net/arping.sh
1708index 307e8ef..b04f05d 100644
1709--- a/net/arping.sh
1710+++ b/net/arping.sh
1711@@ -19,7 +19,7 @@ arping_address()
1712 esac
1713
1714 # We need to bring the interface up to test
1715- _exists "${iface}" || return 1
1716+ _exists "${iface}" || return 1
1717 _up "${iface}"
1718
1719 eval w=\$arping_wait_${IFVAR}
1720@@ -43,7 +43,7 @@ arping_address()
1721 sed -n -e 'y/abcdef/ABCDEF/' -e 's/.*\[\([^]]*\)\].*/\1/p')"
1722 fi
1723 [ -z "${foundmac}" ] && return 1
1724-
1725+
1726 if [ -n "${mac}" ]; then
1727 if [ "${mac}" != "${foundmac}" ]; then
1728 vewarn "Found ${ip} but MAC ${foundmac} does not match"
1729@@ -74,7 +74,7 @@ arping_start()
1730 fi
1731
1732 eindent
1733-
1734+
1735 for x in ${gateways}; do
1736 local IFS=,
1737 set -- ${x}
1738@@ -119,7 +119,7 @@ arping_start()
1739 fi
1740 done
1741 unset IFS
1742-
1743+
1744 _load_config
1745 return 0
1746 fi
1747diff --git a/net/bonding.sh b/net/bonding.sh
1748index 415306c..209d4f0 100644
1749--- a/net/bonding.sh
1750+++ b/net/bonding.sh
1751@@ -115,7 +115,7 @@ bonding_pre_start()
1752
1753 bonding_stop()
1754 {
1755- _is_bond || return 0
1756+ _is_bond || return 0
1757
1758 local slaves= s=
1759 slaves=$( \
1760diff --git a/net/br2684ctl.sh b/net/br2684ctl.sh
1761index 3eea0d9..77dafc9 100644
1762--- a/net/br2684ctl.sh
1763+++ b/net/br2684ctl.sh
1764@@ -17,7 +17,7 @@ br2684ctl_depend()
1765 }
1766
1767 _config_vars="$_config_vars bridge bridge_add brctl"
1768-
1769+
1770 br2684ctl_pre_start()
1771 {
1772 local opts=
1773@@ -40,7 +40,7 @@ br2684ctl_pre_start()
1774 return 1
1775 ;;
1776 esac
1777-
1778+
1779 einfo "Starting RFC 2684 Bridge control on ${IFACE}"
1780 start-stop-daemon --start --exec $(_br2684ctl) --background \
1781 --make-pidfile --pidfile "/var/run/br2684ctl-${IFACE}.pid" \
1782@@ -52,7 +52,7 @@ br2684ctl_post_stop()
1783 {
1784 local pidfile="/var/run/br2684ctl-${IFACE}.pid"
1785 [ -e "${pidfile}" ] || return 0
1786-
1787+
1788 einfo "Stopping RFC 2684 Bridge control on ${IFACE}"
1789 start-stop-daemon --stop --quiet --pidfile "${pidfile}"
1790 eend $?
1791diff --git a/net/bridge.sh b/net/bridge.sh
1792index c0172ed..91e68d6 100644
1793--- a/net/bridge.sh
1794+++ b/net/bridge.sh
1795@@ -38,15 +38,15 @@ bridge_pre_start()
1796 local opts="$(_get_array "brctl_${IFVAR}")"
1797 # brif is used for dynamic add
1798 eval brif=\$bridge_add_${IFVAR}
1799-
1800+
1801 # we need a way to if the bridge exists in a variable name, not just the
1802 # contents of a variable. Eg if somebody has only bridge_add_eth0='br0',
1803 # with no other lines mentioning br0.
1804 eval bridge_unset=\${bridge_${IFVAR}-y\}
1805 eval brctl_unset=\${brctl_${IFVAR}-y\}
1806-
1807- if [ -z "${brif}" -a "${brctl_unset}" == 'y' ]; then
1808- if [ -z "${ports}" -a "${bridge_unset}" == "y" ]; then
1809+
1810+ if [ -z "${brif}" -a "${brctl_unset}" = 'y' ]; then
1811+ if [ -z "${ports}" -a "${bridge_unset}" = "y" ]; then
1812 #eerror "Misconfigured static bridge detected (see net.example)"
1813 return 0
1814 fi
1815@@ -186,6 +186,6 @@ bridge_post_stop()
1816 brctl delbr "${iface}"
1817 eend $?
1818 fi
1819-
1820+
1821 return 0
1822 }
1823diff --git a/net/ccwgroup.sh b/net/ccwgroup.sh
1824index cf08943..6fcba1d 100644
1825--- a/net/ccwgroup.sh
1826+++ b/net/ccwgroup.sh
1827@@ -5,7 +5,7 @@ _config_vars="$_config_vars ccwgroup"
1828
1829 ccwgroup_depend()
1830 {
1831- before interface
1832+ before interface
1833 }
1834
1835 ccwgroup_pre_start()
1836@@ -42,7 +42,7 @@ ccwgroup_pre_stop()
1837 {
1838 # Erase any existing ccwgroup to be safe
1839 service_set_value ccwgroup_device ""
1840-
1841+
1842 [ ! -L /sys/class/net/"${FACE}"/driver ] && return 0
1843 local driver="$(readlink /sys/class/net/"${IFACE}"/driver)"
1844 case "${diver}" in
1845@@ -59,7 +59,7 @@ ccwgroup_post_stop()
1846 {
1847 local device="$(service_get_value ccwgroup_device)"
1848 [ -z "${device}" ] && return 0
1849-
1850+
1851 einfo "Disabling ccwgroup on ${iface}"
1852 echo "0" >/sys/devices/qeth/"${device}"/online
1853 echo "1" >/sys/devices/qeth/"${device}"/ungroup
1854diff --git a/net/clip.sh b/net/clip.sh
1855index 3cb84e7..35efa3f 100644
1856--- a/net/clip.sh
1857+++ b/net/clip.sh
1858@@ -97,7 +97,7 @@ clip_pre_start()
1859 return 1
1860 fi
1861 fi
1862-
1863+
1864 local started_here=
1865 if ! are_atmclip_svcs_running; then
1866 atmclip_svcs_start || return 1
1867diff --git a/net/ethtool.sh b/net/ethtool.sh
1868new file mode 100644
1869index 0000000..64b44a6
1870--- /dev/null
1871+++ b/net/ethtool.sh
1872@@ -0,0 +1,54 @@
1873+# Copyright (c) 2011 by Gentoo Foundation
1874+# All rights reserved. Released under the 2-clause BSD license.
1875+
1876+_ethtool() {
1877+ echo /usr/sbin/ethtool
1878+}
1879+
1880+ethtool_depend()
1881+{
1882+ program $(_ethtool)
1883+ before interface
1884+}
1885+
1886+# This is just to trim whitespace, do not add any quoting!
1887+_trim() {
1888+ echo $*
1889+}
1890+
1891+ethtool_pre_start() {
1892+ local order opt OFS="${OIFS}"
1893+ eval order=\$ethtool_order_${IFVAR}
1894+ [ -z "${order}" ] && eval order=\$ethtool_order
1895+ [ -z "${order}" ] && order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple"
1896+ # ethtool options not used: --driver, --register-dump, --eeprom-dump, --negotiate, --test, --statistics
1897+ eindent
1898+ for opt in ${order} ; do
1899+ local args
1900+ eval args=\$ethtool_${opt//-/_}_${IFVAR}
1901+
1902+ # Skip everything if no arguments
1903+ [ -z "${args}" ] && continue
1904+
1905+ # Split on \n
1906+ local IFS="$__IFS"
1907+
1908+ for p in ${args} ; do
1909+ IFS="${OIFS}"
1910+ local args_pretty="$(_trim "${p}")"
1911+ # Do nothing if empty
1912+ [ -z "${args_prety}" ] && continue
1913+ args_pretty="--${opt} $IFACE ${args_pretty}"
1914+ args="--${opt} $IFACE ${args}"
1915+ ebegin "ethtool ${args_pretty}"
1916+ $(_ethtool) ${args}
1917+ rc=$?
1918+ eend $rc "ethtool exit code $rc"
1919+ # TODO: ethtool has MANY different exit codes, with no
1920+ # documentation as to which ones are fatal or not. For now we
1921+ # simply print the exit code and don't stop the start sequence.
1922+ done
1923+ IFS="${OIFS}"
1924+ done
1925+ eoutdent
1926+}
1927diff --git a/net/ifconfig.sh.Linux.in b/net/ifconfig.sh.Linux.in
1928index 74fcc9f..f5c2064 100644
1929--- a/net/ifconfig.sh.Linux.in
1930+++ b/net/ifconfig.sh.Linux.in
1931@@ -139,7 +139,7 @@ _add_address()
1932 return 0
1933 fi
1934
1935- case "$1" in
1936+ case "$1" in
1937 *:*) ifconfig "${IFACE}" inet6 add "$@"; return $?;;
1938 esac
1939
1940@@ -225,7 +225,7 @@ _delete_addresses()
1941 while true; do
1942 local addr=$(_get_inet_address)
1943 [ -z "${addr}" ] && break
1944-
1945+
1946 if [ "${addr}" = "127.0.0.1/8" ]; then
1947 # Don't delete the loopback address
1948 [ "${IFACE}" = "lo" -o "${IFACE}" = "lo0" ] && break
1949@@ -246,7 +246,7 @@ _delete_addresses()
1950 einfo "${addr}"
1951 ifconfig "${IFACE}" inet6 del "${addr}"
1952 done
1953-
1954+
1955 return 0
1956 }
1957
1958diff --git a/net/ifplugd.sh b/net/ifplugd.sh
1959index 5831720..9f6c884 100644
1960--- a/net/ifplugd.sh
1961+++ b/net/ifplugd.sh
1962@@ -57,7 +57,7 @@ ifplugd_pre_start()
1963 ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
1964 elif [ ${timeout} -lt 0 ]; then
1965 einfo "Backgrounding ..."
1966- exit 1
1967+ exit 1
1968 fi
1969
1970 veinfo "Waiting for ${IFACE} to be marked as started"
1971@@ -84,7 +84,7 @@ ifplugd_stop()
1972
1973 local pidfile="/var/run/ifplugd.${IFACE}.pid"
1974 [ ! -e "${pidfile}" ] && return 0
1975-
1976+
1977 ebegin "Stopping ifplugd on ${IFACE}"
1978 start-stop-daemon --stop --quiet --exec /usr/sbin/ifplugd \
1979 --pidfile "${pidfile}" --signal QUIT
1980diff --git a/net/ifwatchd.sh b/net/ifwatchd.sh
1981index d9da15e..4e6b1c6 100644
1982--- a/net/ifwatchd.sh
1983+++ b/net/ifwatchd.sh
1984@@ -50,7 +50,7 @@ ifwatchd_stop()
1985 -- -c "${RC_LIBEXECDIR}/sh/ifwatchd-carrier.sh" \
1986 -n "${RC_LIBEXECDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \
1987 || return 0
1988-
1989+
1990 ebegin "Stopping ifwatchd on" "${IFACE}"
1991 start-stop-daemon --stop --exec /usr/sbin/ifwatchd \
1992 -- -c "${RC_LIBEXECDIR}/sh/ifwatchd-carrier.sh" \
1993diff --git a/net/ip6to4.sh b/net/ip6to4.sh
1994index 6bddb7e..2349429 100644
1995--- a/net/ip6to4.sh
1996+++ b/net/ip6to4.sh
1997@@ -56,7 +56,7 @@ ip6to4_start()
1998 [ ${i} -lt 32 ] && continue
1999 ;;
2000 esac
2001-
2002+
2003 veinfo "IPv4 address on ${host}: ${ip}/${subnet}"
2004 local ipa= ip6= IFS="${IFS}."
2005 for i in ${ip}; do
2006@@ -87,7 +87,7 @@ ip6to4_start()
2007 eend $? || return 1
2008 _up
2009 fi
2010-
2011+
2012 # Now apply our config
2013 eval config_${config_index}=\'"${new}"\'
2014 config_index=$((${config_index} - 1))
2015diff --git a/net/iproute2.sh b/net/iproute2.sh
2016index 1cd4f42..a2e9db7 100644
2017--- a/net/iproute2.sh
2018+++ b/net/iproute2.sh
2019@@ -117,14 +117,14 @@ _add_address()
2020 shift; shift; shift
2021 set -- "${one}/$(_netmask2cidr "${three}")" "$@"
2022 fi
2023-
2024+
2025 # tunnel keyword is 'peer' in iproute2, but 'pointopoint' in ifconfig.
2026 if [ "$2" = "pointopoint" ]; then
2027 local one="$1"
2028 shift; shift
2029 set -- "${one}" "peer" "$@"
2030 fi
2031-
2032+
2033 # Always scope lo addresses as host unless specified otherwise
2034 if [ "${IFACE}" = "lo" ]; then
2035 set -- "$@" "scope" "host"
2036@@ -162,7 +162,7 @@ _add_route()
2037 set -- "${one}" "${two}" via "$@"
2038 fi
2039
2040- local cmd= have_metric=false
2041+ local cmd= have_metric=false
2042 while [ -n "$1" ]; do
2043 case "$1" in
2044 metric) cmd="${cmd} $1"; have_metric=true;;
2045@@ -221,7 +221,7 @@ _ip_rule_runner() {
2046 local IFS="$__IFS"
2047 for ru in $rules ; do
2048 unset IFS
2049- ruN="$(trim "${ru}")"
2050+ ruN="$(_trim "${ru}")"
2051 [ -z "${ruN}" ] && continue
2052 vebegin "${cmd} ${ruN}"
2053 ip rule ${cmd} ${ru}
2054@@ -239,9 +239,14 @@ iproute2_pre_start()
2055 if [ -n "${tunnel}" ]; then
2056 # Set our base metric to 1000
2057 metric=1000
2058+ # Bug#347657: If the mode is 'ipip6' or 'ip6ip6', the -6 must be passed
2059+ # to iproute2 during tunnel creation.
2060+ local ipproto=''
2061+ [ "${tunnel##mode ipip6}" != "${tunnel}" ] && ipproto='-6'
2062+ [ "${tunnel##mode ip6ip6}" != "${tunnel}" ] && ipproto='-6'
2063
2064 ebegin "Creating tunnel ${IFVAR}"
2065- ip tunnel add ${tunnel} name "${IFACE}"
2066+ ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
2067 eend $? || return 1
2068 _up
2069 fi
2070diff --git a/net/iwconfig.sh.BSD.in b/net/iwconfig.sh.BSD.in
2071index ec88e66..f94246b 100644
2072--- a/net/iwconfig.sh.BSD.in
2073+++ b/net/iwconfig.sh.BSD.in
2074@@ -477,7 +477,7 @@ iwconfig_defaults()
2075 #ifconfig "${iface}" txpower 100 2>/dev/null
2076 ifconfig "${IFACE}" bssid -
2077 ifconfig "${IFACE}" ssid -
2078- ifconfig "${IFACE}" wepkey 1:- wepkey 2:- wepkey 3:- wepkey 4:-
2079+ ifconfig "${IFACE}" wepkey 1:- wepkey 2:- wepkey 3:- wepkey 4:-
2080 ifconfig "${IFACE}" authmode open
2081 ifconfig "${IFACE}" -mediaopt adhoc
2082 ifconfig "${IFACE}" -mediaopt hostap
2083@@ -563,8 +563,8 @@ iwconfig_pre_start()
2084 return 0
2085 fi
2086
2087- iwconfig_defaults
2088- iwconfig_user_config
2089+ iwconfig_defaults
2090+ iwconfig_user_config
2091
2092 # Set the base metric to be 2000
2093 metric=2000
2094diff --git a/net/iwconfig.sh.Linux.in b/net/iwconfig.sh.Linux.in
2095index 28cdd23..600ffe7 100644
2096--- a/net/iwconfig.sh.Linux.in
2097+++ b/net/iwconfig.sh.Linux.in
2098@@ -47,7 +47,7 @@ _get_ssid()
2099
2100 _get_ap_mac_address()
2101 {
2102- local mac="$(iwgetid --raw --ap "${IFACE}")"
2103+ local mac="$(iwgetid --raw --ap "${IFACE}")"
2104 case "${mac}" in
2105 "00:00:00:00:00:00") return 1;;
2106 "44:44:44:44:44:44") return 1;;
2107@@ -163,7 +163,7 @@ iwconfig_setup_specific()
2108 local key=$(iwconfig_get_wep_key)
2109
2110 iwconfig_set_mode "${mode}"
2111-
2112+
2113 # Now set the key
2114 if ! eval iwconfig "${IFACE}" key "${key}"; then
2115 if [ "${key}" != "off" ]; then
2116@@ -185,10 +185,10 @@ iwconfig_setup_specific()
2117 ewarn "${IFACE} does not support setting the channel to \"${channel:-3}\""
2118 return 1
2119 fi
2120-
2121+
2122 # Finally apply the user Config
2123 iwconfig_user_config
2124-
2125+
2126 iwconfig_report
2127 return 0
2128 }
2129@@ -226,7 +226,7 @@ iwconfig_wait_for_association()
2130 /proc/net/wireless)" != "0" ] && return 0
2131 fi
2132 fi
2133-
2134+
2135 sleep 1
2136 [ ${timeout} -eq 0 ] && continue
2137 i=$((${i} + 1))
2138@@ -281,7 +281,7 @@ iwconfig_associate()
2139 iwconfig "${IFACE}" freq "${freq}"
2140 fi
2141 [ -n "${mac}" ] && iwconfig "${IFACE}" ap "${mac}"
2142-
2143+
2144 # Finally apply the user Config
2145 iwconfig_user_config
2146
2147@@ -377,10 +377,10 @@ iwconfig_scan()
2148 for line; do
2149 case "${line}" in
2150 *Address:*)
2151- APS=$((${APS} + 1))
2152+ APS=$((${APS} + 1))
2153 eval MAC_${APS}="\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\""
2154 eval QUALITY_${APS}=0
2155- ;;
2156+ ;;
2157 *ESSID:*)
2158 x=${line#*\"}
2159 x=${x%*\"}
2160@@ -455,7 +455,7 @@ iwconfig_scan()
2161 eval a=\$QUALITY_${i}
2162 eval b=\$QUALITY_${k}
2163 local u=${k}
2164- # We need to split this into two tests, otherwise bash errors
2165+ # We need to split this into two tests, otherwise bash errors
2166 [ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i}
2167 unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u}
2168 fi
2169@@ -581,7 +581,7 @@ iwconfig_connect_not_preferred()
2170 break
2171 fi
2172 done
2173-
2174+
2175 if ! ${pref}; then
2176 SSID=${e}
2177 eval mode=\$MODE_${i}
2178@@ -711,10 +711,10 @@ iwconfig_pre_start()
2179 # wait if our scan returns nothing
2180 LC_ALL=C iwconfig "${IFACE}" | sed -e '1d' | grep -q "Tx-Power=off"
2181 local txpowerwasoff=$?
2182-
2183+
2184 iwconfig_defaults
2185 iwconfig_user_config
2186-
2187+
2188 # Set the base metric to be 2000
2189 metric=2000
2190
2191diff --git a/net/macchanger.sh b/net/macchanger.sh
2192index 32bbdc9..9126d30 100644
2193--- a/net/macchanger.sh
2194+++ b/net/macchanger.sh
2195@@ -24,7 +24,7 @@ macchanger_pre_start()
2196
2197 # The interface needs to be up for macchanger to work most of the time
2198 _down
2199-
2200+
2201 mac=$(echo "${mac}" | tr '[:upper:]' '[:lower:]')
2202 local hex="[0-9a-f][0-9a-f]"
2203 case "${mac}" in
2204diff --git a/net/netplugd.sh b/net/netplugd.sh
2205index 0f46643..8f36ef2 100644
2206--- a/net/netplugd.sh
2207+++ b/net/netplugd.sh
2208@@ -59,7 +59,7 @@ netplugd_pre_start()
2209 ewarn "WARNING: infinite timeout set for ${IFACE} to come up"
2210 elif [ ${timeout} -lt 0 ]; then
2211 einfo "Backgrounding ..."
2212- exit 1
2213+ exit 1
2214 fi
2215
2216 veinfo "Waiting for ${IFACE} to be marked as started"
2217@@ -86,7 +86,7 @@ netplugd_stop()
2218
2219 local pidfile="/var/run/netplugd-${IFACE}.pid"
2220 [ ! -e "${pidfile}" ] && return 0
2221-
2222+
2223 ebegin "Stopping netplug on" "${IFACE}"
2224 start-stop-daemon --stop --quiet --exec /sbin/netplugd \
2225 --pidfile "${pidfile}"
2226diff --git a/net/pppd.sh b/net/pppd.sh
2227index a8c8882..c7cfa44 100644
2228--- a/net/pppd.sh
2229+++ b/net/pppd.sh
2230@@ -31,7 +31,7 @@ pppd_pre_start()
2231 if yesno ${IN_BACKGROUND}; then
2232 local config=
2233 eval config=\$config_${IFVAR}
2234- # If no config for ppp then don't default to DHCP
2235+ # If no config for ppp then don't default to DHCP
2236 if [ -z "${config}" ]; then
2237 eval config_${IFVAR}=null
2238 fi
2239@@ -39,7 +39,7 @@ pppd_pre_start()
2240 fi
2241
2242 local link= i= unit="${IFACE#ppp}" opts=
2243-
2244+
2245 # PPP requires a link to communicate over - normally a serial port
2246 # PPPoE communicates over Ethernet
2247 # PPPoA communicates over ATM
2248@@ -92,7 +92,7 @@ pppd_pre_start()
2249 && [ -n "${password}" -o -z "${passwordset}" ]; then
2250 opts="plugin passwordfd.so ${opts} passwordfd 0"
2251 fi
2252-
2253+
2254 if ! ${hasdefaultmetric}; then
2255 local m=
2256 eval m=\$metric_${IFVAR}
2257@@ -122,7 +122,7 @@ pppd_pre_start()
2258
2259 # Set unit
2260 opts="unit ${unit} ${opts}"
2261-
2262+
2263 # Setup connect script
2264 local chatprog="/usr/sbin/chat -e -E -v" phone=
2265 eval phone=\$phone_number_${IFVAR}
2266diff --git a/net/pump.sh b/net/pump.sh
2267index d03e2c8..ecceff0 100644
2268--- a/net/pump.sh
2269+++ b/net/pump.sh
2270@@ -35,7 +35,7 @@ pump_start()
2271
2272 ebegin "Running pump"
2273 eval pump "${args}"
2274- eend $? || return 1
2275+ eend $? || return 1
2276
2277 _show_address
2278 return 0
2279@@ -48,7 +48,7 @@ pump_stop()
2280 start-stop-daemon --quiet --test --stop --exec /sbin/pump || return 0
2281
2282 # Check that pump is running on the interface
2283- if ! pump --status --interface "${IFACE}" >/dev/null 2>&1; then
2284+ if ! pump --status --interface "${IFACE}" >/dev/null 2>&1; then
2285 return 0
2286 fi
2287
2288diff --git a/net/system.sh b/net/system.sh
2289index b22eee6..6680a7d 100644
2290--- a/net/system.sh
2291+++ b/net/system.sh
2292@@ -80,10 +80,10 @@ _system_nis()
2293
2294 eval servers=\$nis_servers_${IFVAR}
2295 [ -z "${servers}" ] && servers=${nis_servers}
2296-
2297+
2298 eval domain=\$nis_domain_${IFVAR}
2299 [ -z "${domain}" ] && domain=${nis_domain}
2300-
2301+
2302 [ -z "${servers}" -a -z "${domain}" ] && return 0
2303
2304 buffer="# Generated by net-scripts for interface ${iface}\n"
2305@@ -110,8 +110,8 @@ _system_nis()
2306 system_pre_start()
2307 {
2308 _system_dns
2309- _system_ntp
2310- _system_nis
2311+ _system_ntp
2312+ _system_nis
2313
2314 return 0
2315 }
2316diff --git a/net/vlan.sh b/net/vlan.sh
2317index c245051..1d50d4f 100644
2318--- a/net/vlan.sh
2319+++ b/net/vlan.sh
2320@@ -1,9 +1,18 @@
2321 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
2322 # All rights reserved. Released under the 2-clause BSD license.
2323
2324+_ip()
2325+{
2326+ if [ -x /bin/ip ]; then
2327+ echo /bin/ip
2328+ else
2329+ echo /sbin/ip
2330+ fi
2331+}
2332+
2333 vlan_depend()
2334 {
2335- program /sbin/vconfig
2336+ program $(_ip)
2337 after interface
2338 before dhcp
2339 }
2340@@ -36,31 +45,12 @@ _check_vlan()
2341
2342 vlan_pre_start()
2343 {
2344- local vc="$(_get_array "vconfig_${IFVAR}")"
2345- [ -z "${vc}" ] && return 0
2346-
2347- _check_vlan || return 1
2348- _exists || return 1
2349-
2350- local v= x= e=
2351- local IFS="$__IFS"
2352- for v in ${vc}; do
2353- unset IFS
2354- case "${v}" in
2355- set_name_type" "*) x=${v};;
2356- *)
2357- set -- ${v}
2358- x="$1 ${IFACE}"
2359- shift
2360- x="${x} $@"
2361- ;;
2362- esac
2363-
2364- e="$(vconfig ${x} 2>&1 1>/dev/null)"
2365- [ -z "${e}" ] && continue
2366- eerror "${e}"
2367+ local vconfig
2368+ eval vconfig=\$vconfig_${IFVAR}
2369+ if [ -n "${vconfig}" ]; then
2370+ eerror "You must convert your vconfig_ VLAN entries to vlan${N} entries."
2371 return 1
2372- done
2373+ fi
2374 }
2375
2376 vlan_post_start()
2377@@ -68,14 +58,26 @@ vlan_post_start()
2378 local vlans=
2379 eval vlans=\$vlans_${IFVAR}
2380 [ -z "${vlans}" ] && return 0
2381-
2382+
2383 _check_vlan || return 1
2384 _exists || return 1
2385
2386- local vlan= e= s=
2387+ local vlan= e= s= vname= vflags= vingress= vegress=
2388 for vlan in ${vlans}; do
2389 einfo "Adding VLAN ${vlan} to ${IFACE}"
2390- e="$(vconfig add "${IFACE}" "${vlan}" 2>&1 1>/dev/null)"
2391+ # We need to gather all interface configuration options
2392+ # 1) naming. Default to the standard "${IFACE}.${vlan}" but it can be anything
2393+ eval vname=\$vlan${vlan}_name
2394+ [ -z "${vname}" ] && vname="${IFACE}.${vlan}"
2395+ # 2) flags
2396+ eval vflags=\$vlan${vlan}_flags
2397+ # 3) ingress/egress map
2398+ eval vingress=\$vlan${vlan}_ingress
2399+ [ -z "${vingress}" ] || vingress="ingress-qos-map ${vingress}"
2400+ eval vegress=\$vlan${vlan}_egress
2401+ [ -z "${vegress}" ] || vegress="egress-qos-map ${vegress}"
2402+
2403+ e="$(ip link add link "${IFACE}" name "${vname}" type vlan id "${vlan}" ${vflags} ${vingress} ${vegress} 2>&1 1>/dev/null)"
2404 if [ -n "${e}" ]; then
2405 eend 1 "${e}"
2406 continue
2407@@ -95,7 +97,7 @@ vlan_post_start()
2408 start
2409 ) || mark_service_stopped "net.${ifname}"
2410 done
2411-
2412+
2413 return 0
2414 }
2415
2416@@ -110,7 +112,7 @@ vlan_post_stop()
2417 stop
2418 ) && {
2419 mark_service_stopped "net.${vlan}"
2420- vconfig rem "${vlan}" >/dev/null
2421+ ip link delete "${vlan}" type vlan >/dev/null
2422 }
2423 done
2424
2425diff --git a/net/wpa_supplicant.sh b/net/wpa_supplicant.sh
2426index 379e615..c619f99 100644
2427--- a/net/wpa_supplicant.sh
2428+++ b/net/wpa_supplicant.sh
2429@@ -149,7 +149,7 @@ wpa_supplicant_pre_start()
2430 if [ -z "${wpac}" ]; then
2431 if service_started devd; then
2432 ebegin "Backgrounding ..."
2433- exit 1
2434+ exit 1
2435 fi
2436 return 0
2437 fi
2438@@ -167,7 +167,7 @@ wpa_supplicant_pre_start()
2439 -P "/var/run/wpa_cli-${IFACE}.pid" -B
2440 if eend $?; then
2441 ebegin "Backgrounding ..."
2442- exit 1
2443+ exit 1
2444 fi
2445
2446 # wpa_cli failed to start? OK, error here
2447diff --git a/sh/init.sh.Linux.in b/sh/init.sh.Linux.in
2448index 0e581c1..9b04557 100644
2449--- a/sh/init.sh.Linux.in
2450+++ b/sh/init.sh.Linux.in
2451@@ -34,7 +34,7 @@ mount_svcdir()
2452 [ $? -eq 0 ] && return 0
2453 fi
2454 fi
2455-
2456+
2457 if grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
2458 fs="ramfs"
2459 # ramfs has no special options
2460@@ -65,19 +65,27 @@ mount_svcdir()
2461 # By default VServer already has /proc mounted, but OpenVZ does not!
2462 # However, some of our users have an old proc image in /proc
2463 # NFC how they managed that, but the end result means we have to test if
2464-# /proc actually works or not. We to this by comparing uptime to one a second
2465-# ago
2466+# /proc actually works or not. We to this by comparing two reads of
2467+# /proc/self/stat. They will not match, because at least the minor fault count
2468+# field (field 10) should have changed.
2469+#
2470+# We can use any file here that fills the following requirements:
2471+# - changes between sequential reads
2472+# - is world-readable (not blocked in hardened kernel)
2473+# - Is only a single line (ergo entire check is doable with no forks)
2474 mountproc=true
2475-if [ -e /proc/uptime ]; then
2476- up="$(cat /proc/uptime)"
2477- sleep 1
2478- if [ "$up" = "$(cat /proc/uptime)" ]; then
2479+f=/proc/self/stat
2480+if [ -e $f ]; then
2481+ exec 9<$f ; read a <&9 ; exec 9<&-
2482+ exec 9<$f ; read b <&9 ; exec 9<&-
2483+ if [ "$a" = "$b" ]; then
2484 eerror "You have cruft in /proc that should be deleted"
2485 else
2486 einfo "/proc is already mounted, skipping"
2487 mountproc=false
2488 fi
2489 fi
2490+unset a b f
2491
2492 if $mountproc; then
2493 procfs="proc"
2494diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
2495index 947c2f7..229d1ee 100644
2496--- a/sh/runscript.sh.in
2497+++ b/sh/runscript.sh.in
2498@@ -111,7 +111,7 @@ start()
2499 [ -n "$command" ] || return 0
2500 local _background=
2501 ebegin "Starting ${name:-$RC_SVCNAME}"
2502- if yesno "${command_background}"; then
2503+ if yesno "${command_background}"; then
2504 _background="--background --pidfile"
2505 fi
2506 if yesno "$start_inactive"; then
2507@@ -252,7 +252,7 @@ while [ -n "$1" ]; do
2508 eerror "$RC_SVCNAME: function \`$1' defined but does not exist"
2509 exit 1
2510 fi
2511- fi
2512+ fi
2513 fi
2514 done
2515 eerror "$RC_SVCNAME: unknown function \`$1'"
2516diff --git a/src/libeinfo/Makefile b/src/libeinfo/Makefile
2517index 1569f8f..b93b5e5 100644
2518--- a/src/libeinfo/Makefile
2519+++ b/src/libeinfo/Makefile
2520@@ -10,4 +10,4 @@ MK= ../../mk
2521 include ${MK}/lib.mk
2522 include ${MK}/cc.mk
2523 include ${MK}/debug.mk
2524-include ${MK}/${MKTERMCAP}.mk
2525+include ${MK}/termcap.mk
2526diff --git a/src/librc/Makefile b/src/librc/Makefile
2527index d3f9cc4..574aa2a 100644
2528--- a/src/librc/Makefile
2529+++ b/src/librc/Makefile
2530@@ -19,21 +19,26 @@ SED_CMD= -e 's:@PREFIX@:${PREFIX}:g'
2531 SED_CMD+= -e 's:@LIB@:${LIBNAME}:g'
2532 SED_CMD+= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
2533 SED_CMD+= -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g'
2534-_PKG_PREFIX_SH= if test -n "${PKG_PREFIX}" && test "${PKG_PREFIX}" != "/" && test "${PKG_PREFIX}" != "${PREFIX}"; then \
2535- echo "-e 's:@PKG_PREFIX@:${PKG_PREFIX}:g'"; \
2536- else \
2537- echo "-e 's:.*@PKG_PREFIX@.*:\#undef RC_PKG_PREFIX:g'"; \
2538- fi
2539-_PKG_PREFIX!= ${_PKG_PREFIX_SH}
2540-SED_CMD+= ${_PKG_PREFIX}$(shell ${_PKG_PREFIX_SH})
2541-
2542-_LCL_PREFIX_SH= if test -n "${LOCAL_PREFIX}" && test "${LOCAL_PREFIX}" != "/" && test "${LOCAL_PREFIX}" != "${PREFIX}"; then \
2543- echo "-e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g'"; \
2544- else \
2545- echo "-e 's:@LOCAL_PREFIX@::g'"; \
2546- fi
2547-_LCL_PREFIX!= ${_LCL_PREFIX_SH}
2548-SED_CMD+= ${_LCL_PREFIX}$(shell ${_LCL_PREFIX_SH})
2549+
2550+_PKG_PREFIX= -e 's:.*@PKG_PREFIX@.*:\#undef RC_PKG_PREFIX:g'
2551+ifneq (${PKG_PREFIX},)
2552+ifneq (${PKG_PREFIX},/)
2553+ifneq (${PKG_PREFIX},${PREFIX})
2554+_PKG_PREFIX= -e 's:@PKG_PREFIX@:${PKG_PREFIX}:g'
2555+endif
2556+endif
2557+endif
2558+SED_CMD+= ${_PKG_PREFIX}
2559+
2560+_LCL_PREFIX= -e 's:@LOCAL_PREFIX@::g'
2561+ifneq (${LOCAL_PREFIX},)
2562+ifneq (${LOCAL_PREFIX},/)
2563+ifneq (${LOCAL_PREFIX},${PREFIX})
2564+_LCL_PREFIX= -e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g'
2565+endif
2566+endif
2567+endif
2568+SED_CMD+= ${_LCL_PREFIX}
2569
2570 .SUFFIXES: .h.in .h
2571 .h.in.h:
2572diff --git a/src/librc/librc-daemon.c b/src/librc/librc-daemon.c
2573index 1bedf29..dde62f9 100644
2574--- a/src/librc/librc-daemon.c
2575+++ b/src/librc/librc-daemon.c
2576@@ -40,7 +40,7 @@ pid_is_exec(pid_t pid, const char *exec)
2577 int c;
2578 bool retval = false;
2579
2580- exec = basename_c(exec);
2581+ exec = basename_c(exec);
2582 snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid);
2583 if ((fp = fopen(buffer, "r"))) {
2584 while ((c = getc(fp)) != EOF && c != '(')
2585@@ -283,7 +283,7 @@ _match_daemon(const char *path, const char *file, RC_STRINGLIST *match)
2586 }
2587
2588 static RC_STRINGLIST *
2589-_match_list(const char *exec, const char* const* argv, const char *pidfile)
2590+_match_list(const char *exec, const char *const *argv, const char *pidfile)
2591 {
2592 RC_STRINGLIST *match = rc_stringlist_new();
2593 int i = 0;
2594@@ -297,7 +297,7 @@ _match_list(const char *exec, const char* const* argv, const char *pidfile)
2595 rc_stringlist_add(match, m);
2596 free(m);
2597 }
2598-
2599+
2600 while (argv && argv[i]) {
2601 l = strlen(*argv) + strlen("argv_=") + 16;
2602 m = xmalloc(sizeof(char) * l);
2603@@ -323,7 +323,7 @@ rc_service_daemon_set(const char *service, const char *exec,
2604 const char *pidfile, bool started)
2605 {
2606 char dirpath[PATH_MAX];
2607- char file[PATH_MAX];
2608+ char file[PATH_MAX];
2609 int nfiles = 0;
2610 char oldfile[PATH_MAX] = { '\0' };
2611 bool retval = false;
2612diff --git a/src/librc/librc-depend.c b/src/librc/librc-depend.c
2613index 765f595..54cd72a 100644
2614--- a/src/librc/librc-depend.c
2615+++ b/src/librc/librc-depend.c
2616@@ -114,7 +114,13 @@ get_deptype(const RC_DEPINFO *depinfo, const char *type)
2617 }
2618
2619 RC_DEPTREE *
2620-rc_deptree_load(void)
2621+rc_deptree_load(void) {
2622+ return rc_deptree_load_file(RC_DEPTREE_CACHE);
2623+}
2624+librc_hidden_def(rc_deptree_load)
2625+
2626+RC_DEPTREE *
2627+rc_deptree_load_file(const char *deptree_file)
2628 {
2629 FILE *fp;
2630 RC_DEPTREE *deptree;
2631@@ -127,7 +133,7 @@ rc_deptree_load(void)
2632 char *e;
2633 int i;
2634
2635- if (!(fp = fopen(RC_DEPTREE_CACHE, "r")))
2636+ if (!(fp = fopen(deptree_file, "r")))
2637 return NULL;
2638
2639 deptree = xmalloc(sizeof(*deptree));
2640@@ -172,16 +178,16 @@ rc_deptree_load(void)
2641 }
2642 fclose(fp);
2643 free(line);
2644-
2645+
2646 return deptree;
2647 }
2648-librc_hidden_def(rc_deptree_load)
2649+librc_hidden_def(rc_deptree_load_file)
2650
2651 static bool
2652 valid_service(const char *runlevel, const char *service, const char *type)
2653 {
2654 RC_SERVICE state;
2655-
2656+
2657 if (!runlevel ||
2658 strcmp(type, "ineed") == 0 ||
2659 strcmp(type, "needsme") == 0)
2660@@ -393,7 +399,7 @@ visit_service(const RC_DEPTREE *deptree,
2661 if (!(di = get_depinfo(deptree, service->value)))
2662 continue;
2663 provided = get_provided(di, runlevel, options);
2664-
2665+
2666 if (TAILQ_FIRST(provided)) {
2667 TAILQ_FOREACH(p, provided, entries) {
2668 di = get_depinfo(deptree, p->value);
2669@@ -767,14 +773,14 @@ rc_deptree_update(void)
2670 if (!depinfo || strcmp(depinfo->service, service) != 0) {
2671 deptype = NULL;
2672 depinfo = get_depinfo(deptree, service);
2673- if (!depinfo) {
2674+ if (!depinfo) {
2675 depinfo = xmalloc(sizeof(*depinfo));
2676 TAILQ_INIT(&depinfo->depends);
2677 depinfo->service = xstrdup(service);
2678 TAILQ_INSERT_TAIL(deptree, depinfo, entries);
2679 }
2680 }
2681-
2682+
2683 /* We may not have any depends */
2684 if (!type || !depends)
2685 continue;
2686@@ -815,7 +821,7 @@ rc_deptree_update(void)
2687 depend[l - 2] == 's' &&
2688 depend[l - 1] == 'h')
2689 continue;
2690-
2691+
2692 /* Remove our dependency if instructed */
2693 if (depend[0] == '!') {
2694 rc_stringlist_delete(deptype->services, depend + 1);
2695diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c
2696index 97cec38..aa038a3 100644
2697--- a/src/librc/librc-misc.c
2698+++ b/src/librc/librc-misc.c
2699@@ -61,7 +61,7 @@ rc_getline(char **line, size_t *len, FILE *fp)
2700 char *p;
2701 size_t last = 0;
2702
2703- while(!feof(fp)) {
2704+ while (!feof(fp)) {
2705 if (*line == NULL || last != 0) {
2706 *len += BUFSIZ;
2707 *line = xrealloc(*line, *len);
2708@@ -218,3 +218,52 @@ rc_config_value(RC_STRINGLIST *list, const char *entry)
2709 return NULL;
2710 }
2711 librc_hidden_def(rc_config_value)
2712+
2713+/* Global for caching the strings loaded from rc.conf to avoid reparsing for
2714+ * each rc_conf_value call */
2715+static RC_STRINGLIST *rc_conf = NULL;
2716+
2717+char *
2718+rc_conf_value(const char *setting)
2719+{
2720+ RC_STRINGLIST *old;
2721+ RC_STRING *s;
2722+ char *p;
2723+
2724+ if (! rc_conf) {
2725+ rc_conf = rc_config_load(RC_CONF);
2726+#ifdef DEBUG_MEMORY
2727+ atexit(_free_rc_conf);
2728+#endif
2729+
2730+ /* Support old configs */
2731+ if (exists(RC_CONF_OLD)) {
2732+ old = rc_config_load(RC_CONF_OLD);
2733+ TAILQ_CONCAT(rc_conf, old, entries);
2734+#ifdef DEBUG_MEMORY
2735+ free(old);
2736+#endif
2737+ }
2738+
2739+ /* Convert old uppercase to lowercase */
2740+ TAILQ_FOREACH(s, rc_conf, entries) {
2741+ p = s->value;
2742+ while (p && *p && *p != '=') {
2743+ if (isupper((unsigned char)*p))
2744+ *p = tolower((unsigned char)*p);
2745+ p++;
2746+ }
2747+ }
2748+ }
2749+
2750+ return rc_config_value(rc_conf, setting);
2751+}
2752+librc_hidden_def(rc_conf_value)
2753+
2754+#ifdef DEBUG_MEMORY
2755+static void
2756+_free_rc_conf(void)
2757+{
2758+ rc_stringlist_free(rc_conf);
2759+}
2760+#endif
2761diff --git a/src/librc/librc-stringlist.c b/src/librc/librc-stringlist.c
2762index c3825cb..818a31c 100644
2763--- a/src/librc/librc-stringlist.c
2764+++ b/src/librc/librc-stringlist.c
2765@@ -146,7 +146,7 @@ librc_hidden_def(rc_stringlist_sort)
2766 void
2767 rc_stringlist_free(RC_STRINGLIST *list)
2768 {
2769- RC_STRING *s1;
2770+ RC_STRING *s1;
2771 RC_STRING *s2;
2772
2773 if (!list)
2774diff --git a/src/librc/librc.c b/src/librc/librc.c
2775index 8a9fd79..e134547 100644
2776--- a/src/librc/librc.c
2777+++ b/src/librc/librc.c
2778@@ -72,7 +72,7 @@ ls_dir(const char *dir, int options)
2779 {
2780 DIR *dp;
2781 struct dirent *d;
2782- RC_STRINGLIST *list = NULL;
2783+ RC_STRINGLIST *list = NULL;
2784 struct stat buf;
2785 size_t l;
2786 char file[PATH_MAX];
2787@@ -198,23 +198,24 @@ file_regex(const char *file, const char *regex)
2788 }
2789 #endif
2790
2791+/* New sys identification code
2792+ * Not to be used for any binaries outside of openrc. */
2793 const char *
2794 rc_sys_v2(void)
2795 {
2796-#define __STRING_SWITCH(x) { char* __string_switch = x; if(false) {}
2797-#define __STRING_CASE(y) else if(strcmp(__string_switch,y) == 0)
2798+#define __STRING_SWITCH(x) { char *__string_switch = x; if (false) {}
2799+#define __STRING_CASE(y) else if (strcmp(__string_switch,y) == 0)
2800 #define __STRING_SWITCH_END() }
2801- char* systype = rc_conf_value("rc_sys");
2802- /* New sys identification code */
2803- if(systype) {
2804- char* s = systype;
2805- // Convert to uppercase
2806- while(s && *s) {
2807- if(islower((unsigned char)*s))
2808- *s = toupper((unsigned char)*s);
2809+ char *systype = rc_conf_value("rc_sys");
2810+ if (systype) {
2811+ char *s = systype;
2812+ /* Convert to uppercase */
2813+ while (s && *s) {
2814+ if (islower((unsigned char) *s))
2815+ *s = toupper((unsigned char) *s);
2816 s++;
2817 }
2818- // Now do detection
2819+ /* Now do detection */
2820 __STRING_SWITCH(systype)
2821 __STRING_CASE(RC_SYS_PREFIX) { return RC_SYS_PREFIX; }
2822 #ifdef __FreeBSD__
2823@@ -241,13 +242,14 @@ rc_sys_v2(void)
2824 }
2825 librc_hidden_def(rc_sys_v2)
2826
2827-/* Old sys identification code */
2828+/* Old sys identification code.
2829+ * Not to be used for any binaries outside of openrc. */
2830 const char *
2831 rc_sys_v1(void)
2832 {
2833 #ifdef PREFIX
2834 return RC_SYS_PREFIX;
2835-#else
2836+#else
2837
2838 #ifdef __FreeBSD__
2839 int jailed = 0;
2840@@ -290,7 +292,7 @@ librc_hidden_def(rc_sys_v1)
2841 const char *
2842 rc_sys(void)
2843 {
2844- if(rc_conf_value("rc_sys")) {
2845+ if (rc_conf_value("rc_sys")) {
2846 return rc_sys_v2();
2847 } else {
2848 return rc_sys_v1();
2849@@ -389,7 +391,7 @@ bool
2850 rc_runlevel_stack(const char *dst, const char *src)
2851 {
2852 char d[PATH_MAX], s[PATH_MAX];
2853-
2854+
2855 if (!rc_runlevel_exists(dst) || !rc_runlevel_exists(src))
2856 return false;
2857 snprintf(s, sizeof(s), "../%s", src);
2858@@ -402,7 +404,7 @@ bool
2859 rc_runlevel_unstack(const char *dst, const char *src)
2860 {
2861 char path[PATH_MAX];
2862-
2863+
2864 snprintf(path, sizeof(path), "%s/%s/%s", RC_RUNLEVELDIR, dst, src);
2865 return (unlink(path) == 0 ? true : false);
2866 }
2867@@ -638,7 +640,7 @@ rc_service_mark(const char *service, const RC_SERVICE state)
2868 }
2869 skip_state = state;
2870 }
2871-
2872+
2873 if (state == RC_SERVICE_HOTPLUGGED || state == RC_SERVICE_FAILED) {
2874 free(init);
2875 return true;
2876@@ -786,7 +788,7 @@ rc_service_value_set(const char *service, const char *option,
2877 {
2878 FILE *fp;
2879 char file[PATH_MAX];
2880- char *p = file;
2881+ char *p = file;
2882
2883 p += snprintf(file, sizeof(file), RC_SVCDIR "/options/%s", service);
2884 if (mkdir(file, 0755) != 0 && errno != EEXIST)
2885diff --git a/src/librc/librc.h b/src/librc/librc.h
2886index dc97f1d..f04750d 100644
2887--- a/src/librc/librc.h
2888+++ b/src/librc/librc.h
2889@@ -72,6 +72,7 @@
2890 #define librc_hidden_proto(x) hidden_proto(x)
2891 #define librc_hidden_def(x) hidden_def(x)
2892
2893+librc_hidden_proto(rc_conf_value)
2894 librc_hidden_proto(rc_config_list)
2895 librc_hidden_proto(rc_config_load)
2896 librc_hidden_proto(rc_config_value)
2897@@ -79,6 +80,7 @@ librc_hidden_proto(rc_deptree_depend)
2898 librc_hidden_proto(rc_deptree_depends)
2899 librc_hidden_proto(rc_deptree_free)
2900 librc_hidden_proto(rc_deptree_load)
2901+librc_hidden_proto(rc_deptree_load_file)
2902 librc_hidden_proto(rc_deptree_order)
2903 librc_hidden_proto(rc_deptree_update)
2904 librc_hidden_proto(rc_deptree_update_needed)
2905diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in
2906index 3d0ffb4..5b06de2 100644
2907--- a/src/librc/rc.h.in
2908+++ b/src/librc/rc.h.in
2909@@ -43,6 +43,14 @@ __BEGIN_DECLS
2910 #define RC_CONFDIR RC_SYSCONFDIR "/conf.d"
2911 #define RC_PLUGINDIR RC_LIBDIR "/plugins"
2912
2913+#define RC_PROFILE_ENV RC_SYSCONFDIR "/profile.env"
2914+#define RC_SYS_WHITELIST RC_LIBEXECDIR "/conf.d/env_whitelist"
2915+#define RC_USR_WHITELIST RC_SYSCONFDIR "/conf.d/env_whitelist"
2916+#define RC_CONF RC_SYSCONFDIR "/rc.conf"
2917+#define RC_CONF_OLD RC_SYSCONFDIR "/conf.d/rc"
2918+
2919+#define RC_PATH_PREFIX RC_LIBEXECDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin"
2920+
2921 /* PKG_PREFIX is where packages are installed if different from the base OS
2922 * On Gentoo this is normally unset, on FreeBSD /usr/local and on NetBSD
2923 * /usr/pkg. */
2924@@ -342,7 +350,7 @@ typedef void *RC_DEPTREE;
2925 * @param target
2926 * @param mtime of newest target
2927 * @param filename of the newest target (needs mtime param)
2928- * @return true if source is newer than target, otherwise false */
2929+ * @return true if source is newer than target, otherwise false */
2930 bool rc_newer_than(const char *, const char *, time_t *, char *);
2931
2932 /*! Check to see if source is older than target.
2933@@ -351,7 +359,7 @@ bool rc_newer_than(const char *, const char *, time_t *, char *);
2934 * @param target
2935 * @param mtime of oldest target
2936 * @param filename of the oldest target (needs mtime param)
2937- * @return true if source is older than target, otherwise false */
2938+ * @return true if source is older than target, otherwise false */
2939 bool rc_older_than(const char *, const char *, time_t *, char *);
2940
2941 /*! Update the cached dependency tree if it's older than any init script,
2942@@ -375,6 +383,11 @@ bool rc_deptree_update_needed(time_t *, char *);
2943 * @return pointer to the dependency tree */
2944 RC_DEPTREE *rc_deptree_load(void);
2945
2946+/*! Load a cached dependency tree from the specified file and return a pointer
2947+ * to it. This pointer should be freed with rc_deptree_free when done.
2948+ * @return pointer to the dependency tree */
2949+RC_DEPTREE *rc_deptree_load_file(const char *);
2950+
2951 /*! List the depend for the type of service
2952 * @param deptree to search
2953 * @param type to use (keywords, etc)
2954@@ -457,6 +470,9 @@ RC_STRINGLIST *rc_config_load(const char *);
2955 /*! Return the value of the entry from a key=value list. */
2956 char *rc_config_value(RC_STRINGLIST *, const char *);
2957
2958+/*! Return the value of the entry from rc.conf. */
2959+char *rc_conf_value(const char *);
2960+
2961 /*! Check if a variable is a boolean and return its value.
2962 * If variable is not a boolean then we set errno to be ENOENT when it does
2963 * not exist or EINVAL if it's not a boolean.
2964@@ -503,7 +519,7 @@ RC_STRING *rc_stringlist_find(RC_STRINGLIST *, const char *);
2965 RC_STRINGLIST *rc_stringlist_split(const char *, const char *);
2966
2967
2968-/*! Sort the list according to C locale
2969+/*! Sort the list according to C locale
2970 * @param list to sort */
2971 void rc_stringlist_sort(RC_STRINGLIST **);
2972
2973diff --git a/src/librc/rc.map b/src/librc/rc.map
2974index 113f2d7..c5f10ad 100644
2975--- a/src/librc/rc.map
2976+++ b/src/librc/rc.map
2977@@ -1,5 +1,6 @@
2978 RC_1.0 {
2979 global:
2980+ rc_conf_value;
2981 rc_config_list;
2982 rc_config_load;
2983 rc_config_value;
2984@@ -7,6 +8,7 @@ global:
2985 rc_deptree_depends;
2986 rc_deptree_free;
2987 rc_deptree_load;
2988+ rc_deptree_load_file;
2989 rc_deptree_order;
2990 rc_deptree_update;
2991 rc_deptree_update_needed;
2992diff --git a/src/rc/Makefile b/src/rc/Makefile
2993index 9d33192..5397415 100644
2994--- a/src/rc/Makefile
2995+++ b/src/rc/Makefile
2996@@ -41,9 +41,25 @@ include ${MK}/prog.mk
2997 include ${MK}/git.mk
2998 include ${MK}/cc.mk
2999
3000-include ${MK}/${MKTERMCAP}.mk
3001+include ${MK}/termcap.mk
3002 LDADD+= ${LIBDL} ${LIBKVM}
3003-include ${MK}/${MKPAM}.mk
3004+include ${MK}/pam.mk
3005+
3006+# create symlinks to rc if not an SELINUX system, otherwise create a wrapper
3007+# script to call rc with the proper name of the applet to execute.
3008+# $1 is a list of the links
3009+# $2 is the path+name of the target to link to (usually 'rc' or '/sbin/rc')
3010+# $3 is the path where the links are created
3011+define make-links
3012+ for x in $(1); do \
3013+ if test -n "${MKSELINUX}"; then \
3014+ printf '#!/bin/sh\nexec ${2} --applet %s "$$@"\n' $$x >${3}/$$x; \
3015+ chmod ${BINMODE} ${3}/$$x; \
3016+ else \
3017+ ln -sf ${2} ${3}/$$x; \
3018+ fi; \
3019+ done;
3020+endef
3021
3022 ${SRCS}: version.h
3023
3024@@ -61,13 +77,13 @@ install: all
3025 ${INSTALL} -d ${DESTDIR}${SBINDIR}
3026 ${INSTALL} -m ${BINMODE} ${PROG} ${DESTDIR}${SBINDIR}
3027 ${INSTALL} -d ${DESTDIR}${BINDIR}
3028- for x in ${BINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${BINDIR}/$$x; done
3029+ $(call make-links,${BINLINKS},${SBINDIR}/${PROG},${DESTDIR}${BINDIR})
3030 ${INSTALL} -d ${DESTDIR}${SBINDIR}
3031- for x in ${SBINLINKS}; do ln -fs ${PROG} ${DESTDIR}${SBINDIR}/$$x; done
3032+ $(call make-links,${SBINLINKS},${SBINDIR}/${PROG},${DESTDIR}${SBINDIR})
3033 ${INSTALL} -d ${DESTDIR}${LINKDIR}/bin
3034- for x in $(RC_BINLINKS); do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/bin/$$x; done
3035+ $(call make-links,${RC_BINLINKS},${SBINDIR}/${PROG},${DESTDIR}${LINKDIR}/bin)
3036 ${INSTALL} -d ${DESTDIR}${LINKDIR}/sbin
3037- for x in ${RC_SBINLINKS}; do ln -fs ${SBINDIR}/${PROG} ${DESTDIR}${LINKDIR}/sbin/$$x; done
3038+ $(call make-links, ${RC_SBINLINKS},${SBINDIR}/${PROG},${DESTDIR}${LINKDIR}/sbin)
3039 if test "${MKPAM}" = pam; then \
3040 ${INSTALL} -d ${DESTDIR}${PAMDIR}; \
3041 ${INSTALL} -m ${PAMMODE} start-stop-daemon.pam ${DESTDIR}${PAMDIR}/start-stop-daemon; \
3042@@ -76,4 +92,4 @@ install: all
3043 check test::
3044
3045 links: rc
3046- for l in ${ALL_LINKS}; do ln -sf rc $$l || exit $$? ; done
3047+ $(call make-links,${ALL_LINKS},rc,.)
3048diff --git a/src/rc/_usage.c b/src/rc/_usage.c
3049index ec1ce1d..175634a 100644
3050--- a/src/rc/_usage.c
3051+++ b/src/rc/_usage.c
3052@@ -1,7 +1,7 @@
3053 /*
3054 * Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
3055 * All rights reserved
3056-
3057+ *
3058 * Redistribution and use in source and binary forms, with or without
3059 * modification, are permitted provided that the following conditions
3060 * are met:
3061@@ -24,6 +24,8 @@
3062 * SUCH DAMAGE.
3063 */
3064
3065+#include "version.h"
3066+
3067 #if lint
3068 # define _noreturn
3069 #endif
3070@@ -34,6 +36,22 @@
3071 #endif
3072
3073 _noreturn static void
3074+show_version(void)
3075+{
3076+ const char *bootlevel = NULL;
3077+
3078+ printf("%s (OpenRC", applet);
3079+ if ((bootlevel = rc_sys()))
3080+ printf(" [%s]", bootlevel);
3081+ printf(") %s", VERSION);
3082+#ifdef BRANDING
3083+ printf(" (%s)", BRANDING);
3084+#endif
3085+ printf("\n");
3086+ exit(EXIT_SUCCESS);
3087+}
3088+
3089+_noreturn static void
3090 usage(int exit_status)
3091 {
3092 const char * const has_arg[] = { "", "<arg>", "[arg]" };
3093diff --git a/src/rc/_usage.h b/src/rc/_usage.h
3094index d65e05e..5e116c9 100644
3095--- a/src/rc/_usage.h
3096+++ b/src/rc/_usage.h
3097@@ -1,7 +1,7 @@
3098 /*
3099 * Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
3100 * All rights reserved
3101-
3102+ *
3103 * Redistribution and use in source and binary forms, with or without
3104 * modification, are permitted provided that the following conditions
3105 * are met:
3106@@ -24,11 +24,12 @@
3107 * SUCH DAMAGE.
3108 */
3109
3110-#define getoptstring_COMMON "Chqv"
3111+#define getoptstring_COMMON "ChqVv"
3112
3113 #define longopts_COMMON \
3114 { "help", 0, NULL, 'h'}, \
3115 { "nocolor", 0, NULL, 'C'}, \
3116+ { "version", 0, NULL, 'V'}, \
3117 { "verbose", 0, NULL, 'v'}, \
3118 { "quiet", 0, NULL, 'q'}, \
3119 { NULL, 0, NULL, 0 }
3120@@ -36,11 +37,13 @@
3121 #define longopts_help_COMMON \
3122 "Display this help output", \
3123 "Disable color output", \
3124+ "Display software version", \
3125 "Run verbosely", \
3126 "Run quietly"
3127
3128 #define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1);
3129 #define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS);
3130+#define case_RC_COMMON_getopt_case_V if (argc == 2) show_version();
3131 #define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1);
3132 #define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1);
3133 #define case_RC_COMMON_getopt_default usage (EXIT_FAILURE);
3134@@ -48,6 +51,7 @@
3135 #define case_RC_COMMON_GETOPT \
3136 case 'C': case_RC_COMMON_getopt_case_C; break; \
3137 case 'h': case_RC_COMMON_getopt_case_h; break; \
3138+ case 'V': case_RC_COMMON_getopt_case_V; break; \
3139 case 'v': case_RC_COMMON_getopt_case_v; break; \
3140 case 'q': case_RC_COMMON_getopt_case_q; break; \
3141 default: case_RC_COMMON_getopt_default; break;
3142diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
3143index a05bfae..69b5bbd 100644
3144--- a/src/rc/fstabinfo.c
3145+++ b/src/rc/fstabinfo.c
3146@@ -109,7 +109,7 @@ do_mount(struct ENT *ent)
3147 argv[6] = ENT_FILE(*ent);
3148 argv[7] = NULL;
3149 switch (pid = vfork()) {
3150- case -1:
3151+ case -1:
3152 eerrorx("%s: vfork: %s", applet, strerror(errno));
3153 /* NOTREACHED */
3154 case 0:
3155diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c
3156index 11bc2d5..6068cb6 100644
3157--- a/src/rc/rc-applets.c
3158+++ b/src/rc/rc-applets.c
3159@@ -152,7 +152,7 @@ do_e(int argc, char **argv)
3160 ts.tv_nsec = WAIT_INTERVAL;
3161 for (i = 0; i < argc; i++) {
3162 ebeginv("Waiting for %s", argv[i]);
3163- for (;;){
3164+ for (;;) {
3165 if (exists(argv[i]))
3166 break;
3167 if (nanosleep(&ts, NULL) == -1)
3168@@ -298,7 +298,7 @@ do_service(int argc, char **argv)
3169 }
3170 }
3171 ok = rc_service_started_daemon(service, exec, NULL, idx);
3172-
3173+
3174 } else if (strcmp(applet, "service_crashed") == 0) {
3175 ok = (_rc_can_find_pids() &&
3176 rc_service_daemons_crashed(service) &&
3177@@ -429,6 +429,17 @@ run_applets(int argc, char **argv)
3178 char *p;
3179 pid_t pid = 0;
3180
3181+ /* Bug 351712: We need an extra way to explicitly select an applet OTHER
3182+ * than trusting argv[0], as argv[0] is not going to be the applet value if
3183+ * we are doing SELinux context switching. For this, we allow calls such as
3184+ * 'rc --applet APPLET', and shift ALL of argv down by two array items. */
3185+ if (strcmp(applet, "rc") == 0 && argc >= 3 &&
3186+ (strcmp(argv[1],"--applet") == 0 || strcmp(argv[1], "-a") == 0)) {
3187+ applet = argv[2];
3188+ argv += 2;
3189+ argc -= 2;
3190+ }
3191+
3192 /* These are designed to be applications in their own right */
3193 if (strcmp(applet, "fstabinfo") == 0)
3194 exit(fstabinfo(argc, argv));
3195@@ -476,7 +487,7 @@ run_applets(int argc, char **argv)
3196 exit(EXIT_FAILURE);
3197 }
3198 exit(EXIT_SUCCESS);
3199- };
3200+ };
3201
3202 if (applet[0] == 'e' || (applet[0] == 'v' && applet[1] == 'e'))
3203 exit(do_e(argc, argv));
3204diff --git a/src/rc/rc-depend.c b/src/rc/rc-depend.c
3205index 29f23d2..3d00d1a 100644
3206--- a/src/rc/rc-depend.c
3207+++ b/src/rc/rc-depend.c
3208@@ -106,7 +106,7 @@ _rc_deptree_load(int force, int *regen) {
3209 }
3210
3211 #include "_usage.h"
3212-#define getoptstring "aot:suT" getoptstring_COMMON
3213+#define getoptstring "aot:suTF:" getoptstring_COMMON
3214 static const struct option longopts[] = {
3215 { "starting", 0, NULL, 'a'},
3216 { "stopping", 0, NULL, 'o'},
3217@@ -114,6 +114,7 @@ static const struct option longopts[] = {
3218 { "notrace", 0, NULL, 'T'},
3219 { "strict", 0, NULL, 's'},
3220 { "update", 0, NULL, 'u'},
3221+ { "deptree-file", 1, NULL, 'F'},
3222 longopts_COMMON
3223 };
3224 static const char * const longopts_help[] = {
3225@@ -123,6 +124,7 @@ static const char * const longopts_help[] = {
3226 "Don't trace service dependencies",
3227 "Only use what is in the runlevels",
3228 "Force an update of the dependency tree",
3229+ "File to load cached deptree from",
3230 longopts_help_COMMON
3231 };
3232 #include "_usage.c"
3233@@ -141,6 +143,7 @@ rc_depend(int argc, char **argv)
3234 char *runlevel = xstrdup(getenv("RC_RUNLEVEL"));
3235 int opt;
3236 char *token;
3237+ char *deptree_file = NULL;
3238
3239 types = rc_stringlist_new();
3240 while ((opt = getopt_long(argc, argv, getoptstring,
3241@@ -166,13 +169,21 @@ rc_depend(int argc, char **argv)
3242 case 'T':
3243 options &= RC_DEP_TRACE;
3244 break;
3245+ case 'F':
3246+ deptree_file = xstrdup(optarg);
3247+ break;
3248
3249- case_RC_COMMON_GETOPT
3250+ case_RC_COMMON_GETOPT
3251 }
3252 }
3253
3254- if (!(deptree = _rc_deptree_load(update, NULL)))
3255- eerrorx("failed to load deptree");
3256+ if (deptree_file) {
3257+ if (!(deptree = rc_deptree_load_file(deptree_file)))
3258+ eerrorx("failed to load deptree");
3259+ } else {
3260+ if (!(deptree = _rc_deptree_load(update, NULL)))
3261+ eerrorx("failed to load deptree");
3262+ }
3263
3264 if (!runlevel)
3265 runlevel = rc_runlevel_get();
3266diff --git a/src/rc/rc-logger.c b/src/rc/rc-logger.c
3267index 4734989..e45c327 100644
3268--- a/src/rc/rc-logger.c
3269+++ b/src/rc/rc-logger.c
3270@@ -172,7 +172,7 @@ rc_logger_open(const char *level)
3271 ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
3272 if (openpty(&rc_logger_tty, &slave_tty, NULL, &tt, &ws))
3273 return;
3274- } else
3275+ } else
3276 if (openpty(&rc_logger_tty, &slave_tty, NULL, NULL, NULL))
3277 return;
3278
3279diff --git a/src/rc/rc-misc.c b/src/rc/rc-misc.c
3280index 0239f9d..64edf68 100644
3281--- a/src/rc/rc-misc.c
3282+++ b/src/rc/rc-misc.c
3283@@ -52,61 +52,7 @@
3284 #include "rc-misc.h"
3285 #include "version.h"
3286
3287-#define PROFILE_ENV RC_SYSCONFDIR "/profile.env"
3288-#define SYS_WHITELIST RC_LIBEXECDIR "/conf.d/env_whitelist"
3289-#define USR_WHITELIST RC_SYSCONFDIR "/conf.d/env_whitelist"
3290-#define RC_CONF RC_SYSCONFDIR "/rc.conf"
3291-#define RC_CONF_OLD RC_SYSCONFDIR "/conf.d/rc"
3292-
3293-#define PATH_PREFIX RC_LIBEXECDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin"
3294-
3295-static RC_STRINGLIST *rc_conf = NULL;
3296-
3297-extern char** environ;
3298-
3299-#ifdef DEBUG_MEMORY
3300-static void
3301-_free_rc_conf(void)
3302-{
3303- rc_stringlist_free(rc_conf);
3304-}
3305-#endif
3306-
3307-char *
3308-rc_conf_value(const char *setting)
3309-{
3310- RC_STRINGLIST *old;
3311- RC_STRING *s;
3312- char *p;
3313-
3314- if (! rc_conf) {
3315- rc_conf = rc_config_load(RC_CONF);
3316-#ifdef DEBUG_MEMORY
3317- atexit(_free_rc_conf);
3318-#endif
3319-
3320- /* Support old configs */
3321- if (exists(RC_CONF_OLD)) {
3322- old = rc_config_load(RC_CONF_OLD);
3323- TAILQ_CONCAT(rc_conf, old, entries);
3324-#ifdef DEBUG_MEMORY
3325- free(old);
3326-#endif
3327- }
3328-
3329- /* Convert old uppercase to lowercase */
3330- TAILQ_FOREACH(s, rc_conf, entries) {
3331- p = s->value;
3332- while (p && *p && *p != '=') {
3333- if (isupper((unsigned char)*p))
3334- *p = tolower((unsigned char)*p);
3335- p++;
3336- }
3337- }
3338- }
3339-
3340- return rc_config_value(rc_conf, setting);
3341-}
3342+extern char **environ;
3343
3344 bool
3345 rc_conf_yesno(const char *setting)
3346@@ -135,7 +81,7 @@ env_filter(void)
3347
3348 /* Add the user defined list of vars */
3349 env_allow = rc_stringlist_split(rc_conf_value("rc_env_allow"), " ");
3350- profile = rc_config_load(PROFILE_ENV);
3351+ profile = rc_config_load(RC_PROFILE_ENV);
3352
3353 /* Copy the env and work from this so we can manipulate it safely */
3354 env_list = rc_stringlist_new();
3355@@ -181,7 +127,7 @@ env_filter(void)
3356 void
3357 env_config(void)
3358 {
3359- size_t pplen = strlen(PATH_PREFIX);
3360+ size_t pplen = strlen(RC_PATH_PREFIX);
3361 char *path;
3362 char *p;
3363 char *e;
3364@@ -199,16 +145,16 @@ env_config(void)
3365 for a little extra security */
3366 path = getenv("PATH");
3367 if (! path)
3368- setenv("PATH", PATH_PREFIX, 1);
3369- else if (strncmp (PATH_PREFIX, path, pplen) != 0) {
3370+ setenv("PATH", RC_PATH_PREFIX, 1);
3371+ else if (strncmp (RC_PATH_PREFIX, path, pplen) != 0) {
3372 l = strlen(path) + pplen + 3;
3373 e = p = xmalloc(sizeof(char) * l);
3374- p += snprintf(p, l, "%s", PATH_PREFIX);
3375+ p += snprintf(p, l, "%s", RC_PATH_PREFIX);
3376
3377 /* Now go through the env var and only add bits not in our
3378 * PREFIX */
3379 while ((token = strsep(&path, ":"))) {
3380- np = npp = xstrdup(PATH_PREFIX);
3381+ np = npp = xstrdup(RC_PATH_PREFIX);
3382 while ((tok = strsep(&npp, ":")))
3383 if (strcmp(tok, token) == 0)
3384 break;
3385@@ -316,7 +262,7 @@ exec_service(const char *service, const char *arg)
3386 fd = svc_lock(basename_c(service));
3387 if (fd == -1)
3388 return -1;
3389-
3390+
3391 file = rc_service_resolve(service);
3392 if (!exists(file)) {
3393 rc_service_mark(service, RC_SERVICE_STOPPED);
3394diff --git a/src/rc/rc-plugin.c b/src/rc/rc-plugin.c
3395index 592eb09..d82e9a9 100644
3396--- a/src/rc/rc-plugin.c
3397+++ b/src/rc/rc-plugin.c
3398@@ -105,7 +105,7 @@ rc_plugin_load(void)
3399 continue;
3400 }
3401
3402- fptr = (int (*)(RC_HOOK, const char*))
3403+ fptr = (int (*)(RC_HOOK, const char *))
3404 dlfunc(h, RC_PLUGIN_HOOK);
3405 if (fptr == NULL) {
3406 eerror("%s: cannot find symbol `%s'",
3407@@ -200,7 +200,7 @@ rc_plugin_run(RC_HOOK hook, const char *value)
3408 sigaction(SIGUSR1, &sa, NULL);
3409 sigaction(SIGWINCH, &sa, NULL);
3410 sigprocmask(SIG_SETMASK, &old, NULL);
3411-
3412+
3413 rc_in_plugin = true;
3414 close(pfd[0]);
3415 rc_environ_fd = fdopen(pfd[1], "w");
3416diff --git a/src/rc/rc.c b/src/rc/rc.c
3417index b062349..140667a 100644
3418--- a/src/rc/rc.c
3419+++ b/src/rc/rc.c
3420@@ -153,7 +153,7 @@ cleanup(void)
3421
3422 #ifdef DEBUG_MEMORY
3423 while (p1) {
3424- p2 = LIST_NEXT(p1, entries);
3425+ p2 = LIST_NEXT(p1, entries);
3426 free(p1);
3427 p1 = p2;
3428 }
3429@@ -315,7 +315,7 @@ open_shell(void)
3430 {
3431 const char *shell;
3432 struct passwd *pw;
3433-
3434+
3435 #ifdef __linux__
3436 const char *sys = rc_sys();
3437
3438@@ -586,7 +586,7 @@ do_stop_services(const char *newlevel, bool parallel, bool going_down)
3439 }
3440
3441 crashed = rc_conf_yesno("rc_crashed_stop");
3442-
3443+
3444 nostop = rc_stringlist_split(rc_conf_value("rc_nostop"), " ");
3445 TAILQ_FOREACH_REVERSE(service, stop_services, rc_stringlist, entries)
3446 {
3447@@ -773,14 +773,16 @@ handle_bad_signal(int sig)
3448 #endif
3449
3450 #include "_usage.h"
3451-#define getoptstring "o:s:S" getoptstring_COMMON
3452+#define getoptstring "a:o:s:S" getoptstring_COMMON
3453 static const struct option longopts[] = {
3454+ { "applet", 1, NULL, 'a' },
3455 { "override", 1, NULL, 'o' },
3456 { "service", 1, NULL, 's' },
3457 { "sys", 0, NULL, 'S' },
3458 longopts_COMMON
3459 };
3460 static const char * const longopts_help[] = {
3461+ "runs the applet specified by the next argument",
3462 "override the next runlevel to change into\n"
3463 "when leaving single user or boot runlevels",
3464 "runs the service specified with the rest\nof the arguments",
3465@@ -804,6 +806,7 @@ main(int argc, char **argv)
3466 int opt;
3467 bool parallel;
3468 int regen = 0;
3469+ int i;
3470 #ifdef __linux__
3471 char *proc;
3472 char *p;
3473@@ -822,18 +825,6 @@ main(int argc, char **argv)
3474 if (!applet)
3475 eerrorx("arguments required");
3476
3477- if (argc > 1 && (strcmp(argv[1], "--version") == 0)) {
3478- printf("%s (OpenRC", applet);
3479- if ((bootlevel = rc_sys()))
3480- printf(" [%s]", bootlevel);
3481- printf(") " VERSION
3482-#ifdef BRANDING
3483- " (" BRANDING ")"
3484-#endif
3485- "\n");
3486- exit(EXIT_SUCCESS);
3487- }
3488-
3489 /* Run our built in applets. If we ran one, we don't return. */
3490 run_applets(argc, argv);
3491
3492@@ -855,6 +846,10 @@ main(int argc, char **argv)
3493 longopts, (int *) 0)) != -1)
3494 {
3495 switch (opt) {
3496+ case 'a':
3497+ /* Do nothing, actual logic in run_applets, this
3498+ * is a placeholder */
3499+ break;
3500 case 'o':
3501 if (*optarg == '\0')
3502 optarg = NULL;
3503@@ -880,18 +875,18 @@ main(int argc, char **argv)
3504 case 'S':
3505 if (rc_conf_value("rc_sys")) {
3506 bootlevel = rc_sys_v2();
3507- if(bootlevel)
3508+ if (bootlevel)
3509 printf("%s\n", bootlevel);
3510 } else {
3511 ewarn("WARNING: rc_sys not defined in rc.conf. Falling back to automatic detection");
3512 bootlevel = rc_sys_v1();
3513- if(bootlevel)
3514+ if (bootlevel)
3515 printf("%s\n", bootlevel);
3516 }
3517 exit(EXIT_SUCCESS);
3518 /* NOTREACHED */
3519- case_RC_COMMON_GETOPT
3520- }
3521+ case_RC_COMMON_GETOPT
3522+ }
3523 }
3524
3525 newlevel = argv[optind++];
3526diff --git a/src/rc/runscript.c b/src/rc/runscript.c
3527index 1c60c24..0eca487 100644
3528--- a/src/rc/runscript.c
3529+++ b/src/rc/runscript.c
3530@@ -451,7 +451,7 @@ svc_exec(const char *arg1, const char *arg2)
3531 signal_pipe[0] = signal_pipe[1] = -1;
3532
3533 sigprocmask (SIG_SETMASK, &oldmask, NULL);
3534-
3535+
3536 if (master_tty >= 0) {
3537 /* Why did we do this? */
3538 /* signal (SIGWINCH, SIG_IGN); */
3539@@ -572,7 +572,7 @@ svc_start_check(void)
3540 RC_SERVICE state;
3541
3542 state = rc_service_state(service);
3543-
3544+
3545 if (in_background) {
3546 if (!(state & (RC_SERVICE_INACTIVE | RC_SERVICE_STOPPED)))
3547 exit(EXIT_FAILURE);
3548@@ -583,7 +583,7 @@ svc_start_check(void)
3549 " next runlevel", applet);
3550 }
3551
3552- if (exclusive_fd == -1)
3553+ if (exclusive_fd == -1)
3554 exclusive_fd = svc_lock(applet);
3555 if (exclusive_fd == -1) {
3556 if (errno == EACCES)
3557@@ -603,7 +603,7 @@ svc_start_check(void)
3558 else if (state & RC_SERVICE_INACTIVE && !in_background)
3559 ewarnx("WARNING: %s has already started, but is inactive",
3560 applet);
3561-
3562+
3563 rc_service_mark(service, RC_SERVICE_STARTING);
3564 hook_out = RC_HOOK_SERVICE_START_OUT;
3565 rc_plugin_run(RC_HOOK_SERVICE_START_IN, applet);
3566@@ -619,7 +619,7 @@ svc_start_deps(void)
3567 size_t len;
3568 char *p, *tmp;
3569 pid_t pid;
3570-
3571+
3572 errno = 0;
3573 if (rc_conf_yesno("rc_depend_strict") || errno == ENOENT)
3574 depoptions |= RC_DEP_STRICT;
3575@@ -725,7 +725,7 @@ svc_start_deps(void)
3576 n = 0;
3577 TAILQ_FOREACH(svc, tmplist, entries) {
3578 rc_service_schedule_start(svc->value, service);
3579- use_services = rc_deptree_depend(deptree,
3580+ use_services = rc_deptree_depend(deptree,
3581 "iprovide", svc->value);
3582 TAILQ_FOREACH(svc2, use_services, entries)
3583 rc_service_schedule_start(svc2->value, service);
3584@@ -760,7 +760,7 @@ static void svc_start_real()
3585 {
3586 bool started;
3587 RC_STRING *svc, *svc2;
3588-
3589+
3590 if (ibsave)
3591 setenv("IN_BACKGROUND", ibsave, 1);
3592 hook_out = RC_HOOK_SERVICE_START_DONE;
3593@@ -873,7 +873,7 @@ svc_stop_deps(RC_SERVICE state)
3594
3595 if (state & RC_SERVICE_WASINACTIVE)
3596 return;
3597-
3598+
3599 errno = 0;
3600 if (rc_conf_yesno("rc_depend_strict") || errno == ENOENT)
3601 depoptions |= RC_DEP_STRICT;
3602@@ -941,7 +941,7 @@ svc_stop_deps(RC_SERVICE state)
3603 }
3604 rc_stringlist_free(tmplist);
3605 tmplist = NULL;
3606-
3607+
3608 /* We now wait for other services that may use us and are
3609 * stopping. This is important when a runlevel stops */
3610 services = rc_deptree_depends(deptree, types_mua, applet_list,
3611@@ -959,7 +959,7 @@ static void
3612 svc_stop_real(void)
3613 {
3614 bool stopped;
3615-
3616+
3617 /* If we're stopping localmount, set LC_ALL=C so that
3618 * bash doesn't load anything blocking the unmounting of /usr */
3619 if (strcmp(applet, "localmount") == 0)
3620@@ -1138,7 +1138,7 @@ runscript(int argc, char **argv)
3621 file = basename_c(argv[1]);
3622 else
3623 file = basename_c(lnk);
3624- dir = save;
3625+ dir = save;
3626 } else
3627 file = basename_c(argv[1]);
3628 ll = strlen(dir) + strlen(file) + 2;
3629@@ -1206,7 +1206,7 @@ runscript(int argc, char **argv)
3630 #endif
3631
3632 deps = true;
3633-
3634+
3635 /* Punt the first arg as its our service name */
3636 argc--;
3637 argv++;
3638@@ -1363,7 +1363,7 @@ runscript(int argc, char **argv)
3639 RC_SERVICE_INACTIVE)
3640 {
3641 TAILQ_FOREACH(svc,
3642- restart_services,
3643+ restart_services,
3644 entries)
3645 if (rc_service_state(svc->value) &
3646 RC_SERVICE_STOPPED)
3647diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
3648index bd6c7bf..72b8aff 100644
3649--- a/src/rc/start-stop-daemon.c
3650+++ b/src/rc/start-stop-daemon.c
3651@@ -43,7 +43,7 @@
3652 #include <sys/ioctl.h>
3653 #include <sys/resource.h>
3654 #include <sys/stat.h>
3655-#include <sys/termios.h>
3656+#include <termios.h>
3657 #include <sys/time.h>
3658 #include <sys/wait.h>
3659
3660@@ -322,7 +322,7 @@ get_pid(const char *pidfile, bool quiet)
3661 fclose(fp);
3662 return -1;
3663 }
3664-
3665+
3666 fclose(fp);
3667
3668 return pid;
3669@@ -631,7 +631,7 @@ static const struct option longopts[] = {
3670 longopts_COMMON
3671 };
3672 static const char * const longopts_help[] = {
3673- "Set an ionice class:data when starting",
3674+ "Set an ionice class:data when starting",
3675 "Stop daemon",
3676 "Set a nicelevel when starting",
3677 "Retry schedule to use when stopping",
3678@@ -1210,7 +1210,7 @@ start_stop_daemon(int argc, char **argv)
3679 /* Clean the environment of any RC_ variables */
3680 env_list = rc_stringlist_new();
3681 i = 0;
3682- while(environ[i])
3683+ while (environ[i])
3684 rc_stringlist_add(env_list, environ[i++]);
3685
3686 #ifdef HAVE_PAM
3687@@ -1343,7 +1343,7 @@ start_stop_daemon(int argc, char **argv)
3688 if (start_wait > 0) {
3689 struct timespec ts;
3690 bool alive = false;
3691-
3692+
3693 ts.tv_sec = start_wait / 1000;
3694 ts.tv_nsec = (start_wait % 1000) * ONE_MS;
3695 if (nanosleep(&ts, NULL) == -1) {
3696diff --git a/src/test/.gitignore b/src/test/.gitignore
3697index c4816ef..1b79b9f 100644
3698--- a/src/test/.gitignore
3699+++ b/src/test/.gitignore
3700@@ -1,5 +1,6 @@
3701 einfo.data.out
3702 einfo.funcs.out
3703 librc.funcs.hidden.out
3704+librc.funcs.hidden.list
3705 rc.data.out
3706-rc.funcs.out
3707\ No newline at end of file
3708+rc.funcs.out
3709diff --git a/src/test/librc.funcs.hidden.list b/src/test/librc.funcs.hidden.list
3710deleted file mode 100644
3711index b661850..0000000
3712--- a/src/test/librc.funcs.hidden.list
3713+++ /dev/null
3714@@ -1,56 +0,0 @@
3715-rc_config_list
3716-rc_config_load
3717-rc_config_value
3718-rc_deptree_depend
3719-rc_deptree_depends
3720-rc_deptree_free
3721-rc_deptree_load
3722-rc_deptree_order
3723-rc_deptree_update
3724-rc_deptree_update_needed
3725-rc_find_pids
3726-rc_getline
3727-rc_newer_than
3728-rc_older_than
3729-rc_runlevel_exists
3730-rc_runlevel_get
3731-rc_runlevel_list
3732-rc_runlevel_set
3733-rc_runlevel_stack
3734-rc_runlevel_stacks
3735-rc_runlevel_starting
3736-rc_runlevel_stopping
3737-rc_runlevel_unstack
3738-rc_service_add
3739-rc_service_daemon_set
3740-rc_service_daemons_crashed
3741-rc_service_delete
3742-rc_service_description
3743-rc_service_exists
3744-rc_service_extra_commands
3745-rc_service_in_runlevel
3746-rc_service_mark
3747-rc_service_resolve
3748-rc_service_schedule_clear
3749-rc_service_schedule_start
3750-rc_service_started_daemon
3751-rc_service_state
3752-rc_service_value_get
3753-rc_service_value_set
3754-rc_services_in_runlevel
3755-rc_services_in_runlevel_stacked
3756-rc_services_in_state
3757-rc_services_scheduled
3758-rc_services_scheduled_by
3759-rc_stringlist_add
3760-rc_stringlist_addu
3761-rc_stringlist_delete
3762-rc_stringlist_find
3763-rc_stringlist_free
3764-rc_stringlist_new
3765-rc_stringlist_sort
3766-rc_stringlist_split
3767-rc_sys
3768-rc_sys_v1
3769-rc_sys_v2
3770-rc_yesno
3771diff --git a/src/test/rc.funcs.list b/src/test/rc.funcs.list
3772index 0aac8f9..a8b011f 100644
3773--- a/src/test/rc.funcs.list
3774+++ b/src/test/rc.funcs.list
3775@@ -1,3 +1,5 @@
3776+rc_conf_value
3777+rc_conf_value@@RC_1.0
3778 rc_config_list
3779 rc_config_list@@RC_1.0
3780 rc_config_load
3781@@ -12,6 +14,8 @@ rc_deptree_free
3782 rc_deptree_free@@RC_1.0
3783 rc_deptree_load
3784 rc_deptree_load@@RC_1.0
3785+rc_deptree_load_file
3786+rc_deptree_load_file@@RC_1.0
3787 rc_deptree_order
3788 rc_deptree_order@@RC_1.0
3789 rc_deptree_update
3790diff --git a/src/test/runtests.sh b/src/test/runtests.sh
3791index 076bd75..4731bd7 100755
3792--- a/src/test/runtests.sh
3793+++ b/src/test/runtests.sh
3794@@ -57,6 +57,7 @@ sed -n '/^librc_hidden_proto/s:.*(\(.*\))$:\1:p' ${librc_srcdir}/librc.h \
3795 | LC_ALL=C sort -u \
3796 > librc.funcs.hidden.list
3797 readelf -Wr $(grep -l '#include[[:space:]]"librc\.h"' ${librc_srcdir}/*.c | sed 's:\.c$:.o:') \
3798+ | egrep -v -e 'R_PARISC_(DP|SEG)REL' \
3799 | awk '$5 ~ /^rc_/ {print $5}' \
3800 | LC_ALL=C sort -u \
3801 | egrep -v '^rc_environ_fd$' \
3802@@ -66,6 +67,50 @@ syms=$(diff -u librc.funcs.hidden.list librc.funcs.hidden.out | sed -n '/^+[^+]/
3803 eend $? "Missing hidden defs:"$'\n'"${syms}"
3804 ret=$(($ret + $?))
3805
3806+ebegin "Checking trailing whitespace in code"
3807+# XXX: Should we check man pages too ?
3808+out=$(cd ${top_srcdir}; find */ \
3809+ '(' -name '*.[ch]' -o -name '*.in' -o -name '*.sh' ')' \
3810+ -exec grep -n -E '[[:space:]]+$' {} +)
3811+[ -z "${out}" ]
3812+eend $? "Trailing whitespace needs to be deleted:"$'\n'"${out}"
3813+
3814+ebegin "Checking trailing newlines in code"
3815+out=$(cd ${top_srcdir};
3816+ for f in `find */ -name '*.[ch]'` ; do
3817+ sed -n -e :a -e '/^\n*$/{$q1;N;ba' -e '}' $f || echo $f
3818+ done)
3819+[ -z "${out}" ]
3820+eend $? "Trailing newlines need to be deleted:"$'\n'"${out}"
3821+
3822+ebegin "Checking for obsolete functions"
3823+out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
3824+ -exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +)
3825+[ -z "${out}" ]
3826+eend $? "Avoid these obsolete functions:"$'\n'"${out}"
3827+
3828+ebegin "Checking for x* func usage"
3829+out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
3830+ -exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \
3831+ | grep -v \
3832+ -e src/includes/rc-misc.h \
3833+ -e src/libeinfo/libeinfo.c)
3834+[ -z "${out}" ]
3835+eend $? "These need to be using the x* variant:"$'\n'"${out}"
3836+
3837+ebegin "Checking spacing style"
3838+out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
3839+ -exec grep -n -E \
3840+ -e '\<(for|if|switch|while)\(' \
3841+ -e '\<(for|if|switch|while) \( ' \
3842+ -e ' ;' \
3843+ -e '[[:space:]]$' \
3844+ -e '\){' \
3845+ -e '(^|[^:])//' \
3846+ {} +)
3847+[ -z "${out}" ]
3848+eend $? "These lines violate style rules:"$'\n'"${out}"
3849+
3850 einfo "Running unit tests"
3851 eindent
3852 for u in units/*; do
3853diff --git a/test/setup_env.sh b/test/setup_env.sh
3854index 6794913..9f3a3fd 100755
3855--- a/test/setup_env.sh
3856+++ b/test/setup_env.sh
3857@@ -9,14 +9,18 @@ srcdir=${srcdir:-.}
3858 top_builddir=${top_builddir:-${top_srcdir}}
3859 builddir=${builddir:-${srcdir}}
3860
3861-if ! . ${top_srcdir}/sh/functions.sh; then
3862+export LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBRARY_PATH}
3863+export PATH=${top_builddir}/src/rc:${PATH}
3864+
3865+
3866+if [ ! -f ${top_srcdir}/sh/functions.sh ] ; then
3867+ echo "functions.sh not yet created !?" 1>&2
3868+ exit 1
3869+elif ! . ${top_srcdir}/sh/functions.sh; then
3870 echo "Sourcing functions.sh failed !?" 1>&2
3871 exit 1
3872 fi
3873
3874-export LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBRARY_PATH}
3875-export PATH=${top_builddir}/src/rc:${PATH}
3876-
3877 cd ${top_srcdir}/src/rc
3878 ${MAKE:-make} links >/dev/null
3879 cd -