aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Troan <ewt@redhat.com>1997-09-16 14:12:05 +0000
committerErik Troan <ewt@redhat.com>1997-09-16 14:12:05 +0000
commitced9dffda28f1ec2b060f3e419cf3c6b964b03a1 (patch)
treeda3f56c24861ddc77e2910291c71adc12dca136b
downloadinitscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar
initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar.gz
initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar.bz2
initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.tar.xz
initscripts-ced9dffda28f1ec2b060f3e419cf3c6b964b03a1.zip
Initial revision
-rw-r--r--Makefile23
-rw-r--r--adjtime1
-rw-r--r--inittab56
-rw-r--r--ppp/ip-down13
-rw-r--r--ppp/ip-up14
-rwxr-xr-xrc.d/init.d/functions139
-rwxr-xr-xrc.d/init.d/halt58
-rwxr-xr-xrc.d/init.d/killall20
-rwxr-xr-xrc.d/init.d/network72
-rwxr-xr-xrc.d/init.d/nfsfs40
-rwxr-xr-xrc.d/init.d/random37
-rwxr-xr-xrc.d/init.d/single29
-rwxr-xr-xrc.d/init.d/skeleton27
-rwxr-xr-xrc.d/rc54
-rwxr-xr-xrc.d/rc.local27
-rwxr-xr-xrc.d/rc.sysinit212
-rw-r--r--src/Makefile26
-rw-r--r--src/doexec.112
-rw-r--r--src/doexec.c6
-rw-r--r--src/netreport.122
-rw-r--r--src/netreport.c45
-rw-r--r--src/testd.c7
-rwxr-xr-xsrc/testdinit44
-rw-r--r--src/usernetctl.118
-rw-r--r--src/usernetctl.c130
-rw-r--r--src/usleep.120
-rw-r--r--src/usleep.c37
-rw-r--r--sysconfig/network-scripts/ifcfg-lo6
-rw-r--r--sysconfig/network-scripts/ifdhcpc-done20
-rwxr-xr-xsysconfig/network-scripts/ifdown42
-rwxr-xr-xsysconfig/network-scripts/ifdown-post18
-rwxr-xr-xsysconfig/network-scripts/ifdown-ppp44
-rwxr-xr-xsysconfig/network-scripts/ifdown-sl35
-rwxr-xr-xsysconfig/network-scripts/ifup158
-rwxr-xr-xsysconfig/network-scripts/ifup-plip29
-rwxr-xr-xsysconfig/network-scripts/ifup-post43
-rwxr-xr-xsysconfig/network-scripts/ifup-ppp103
-rwxr-xr-xsysconfig/network-scripts/ifup-routes17
-rwxr-xr-xsysconfig/network-scripts/ifup-sl56
39 files changed, 1760 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..86a51b5a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,23 @@
+ROOT=/
+
+all:
+ (cd src; make CFLAGS="$(CFLAGS)")
+
+install:
+ mkdir -p $(ROOT)/etc
+ install -m644 -o root -g root inittab $(ROOT)/etc
+ install -m644 -o root -g root adjtime $(ROOT)/etc
+ cp -af rc.d sysconfig ppp $(ROOT)/etc
+ mkdir -p $(ROOT)/sbin
+ mv $(ROOT)/etc/sysconfig/network-scripts/ifup $(ROOT)/sbin
+ mv $(ROOT)/etc/sysconfig/network-scripts/ifdown $(ROOT)/sbin
+ (cd $(ROOT)/etc/sysconfig/network-scripts; \
+ ln -sf ../../../sbin/ifup . ; \
+ ln -sf ../../../sbin/ifdown . )
+ (cd src; make install ROOT=$(ROOT))
+ mkdir -p /var/run/netreport
+ chown root.root /var/run/netreport
+ chmod o=rwx,go=rx /var/run/netreport
+
+clean:
+ (cd src; make clean)
diff --git a/adjtime b/adjtime
new file mode 100644
index 00000000..7481b115
--- /dev/null
+++ b/adjtime
@@ -0,0 +1 @@
+0.0 0 0.0
diff --git a/inittab b/inittab
new file mode 100644
index 00000000..1065b7fe
--- /dev/null
+++ b/inittab
@@ -0,0 +1,56 @@
+#
+# inittab This file describes how the INIT process should set up
+# the system in a certain run-level.
+#
+# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+# Modified for RHS Linux by Marc Ewing and Donnie Barnes
+#
+
+# Default runlevel. The runlevels used by RHS are:
+# 0 - halt (Do NOT set initdefault to this)
+# 1 - Single user mode
+# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
+# 3 - Full multiuser mode
+# 4 - unused
+# 5 - X11
+# 6 - reboot (Do NOT set initdefault to this)
+#
+id:3:initdefault:
+
+# System initialization.
+si::sysinit:/etc/rc.d/rc.sysinit
+
+l0:0:wait:/etc/rc.d/rc 0
+l1:1:wait:/etc/rc.d/rc 1
+l2:2:wait:/etc/rc.d/rc 2
+l3:3:wait:/etc/rc.d/rc 3
+l4:4:wait:/etc/rc.d/rc 4
+l5:5:wait:/etc/rc.d/rc 5
+l6:6:wait:/etc/rc.d/rc 6
+
+# Things to run in every runlevel.
+ud::once:/sbin/update
+
+# Trap CTRL-ALT-DELETE
+ca::ctrlaltdel:/sbin/shutdown -t3 -r now
+
+# When our UPS tells us power has failed, assume we have a few minutes
+# of power left. Schedule a shutdown for 2 minutes from now.
+# This does, of course, assume you have powerd installed and your
+# UPS connected and working correctly.
+pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
+
+# If power was restored before the shutdown kicked in, cancel it.
+pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
+
+
+# Run gettys in standard runlevels
+1:12345:respawn:/sbin/mingetty tty1
+2:2345:respawn:/sbin/mingetty tty2
+3:2345:respawn:/sbin/mingetty tty3
+4:2345:respawn:/sbin/mingetty tty4
+5:2345:respawn:/sbin/mingetty tty5
+6:2345:respawn:/sbin/mingetty tty6
+
+# Run xdm in runlevel 5
+x:5:respawn:/usr/bin/X11/xdm -nodaemon
diff --git a/ppp/ip-down b/ppp/ip-down
new file mode 100644
index 00000000..13a1e267
--- /dev/null
+++ b/ppp/ip-down
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# This file should not be modified -- make local changes to
+# /etc/ppp/ip-down.local instead
+
+LOGDEVICE=$6
+REALDEVICE=$1
+
+[ -x /etc/ppp/ip-down.local ] && /etc/ppp/ip-down.local $*
+
+/etc/sysconfig/network-scripts/ifdown-post ifcfg-${LOGDEVICE}
+
+exit 0
diff --git a/ppp/ip-up b/ppp/ip-up
new file mode 100644
index 00000000..76e9e76f
--- /dev/null
+++ b/ppp/ip-up
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# This file should not be modified -- make local changes to
+# /etc/ppp/ip-up.local instead
+
+LOGDEVICE=$6
+REALDEVICE=$1
+
+echo "$REALDEVICE" > /var/run/ppp-$LOGDEVICE.dev
+[ -x /etc/ppp/ip-up.local ] && /etc/ppp/ip-up.local $*
+
+/etc/sysconfig/network-scripts/ifup-post ifcfg-${LOGDEVICE}
+
+exit 0
diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions
new file mode 100755
index 00000000..e3b1494e
--- /dev/null
+++ b/rc.d/init.d/functions
@@ -0,0 +1,139 @@
+#! /bin/sh
+#
+# functions This file contains functions to be used by most or all
+# shell scripts in the /etc/init.d directory.
+#
+# Version: @(#) /etc/init.d/functions 1.01 26-Oct-1993
+#
+# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+# Hacked by: Greg Galloway and Marc Ewing
+#
+
+# First set up a default search path.
+export PATH="/sbin:/usr/sbin:/bin:/usr/bin"
+
+# A function to start a program.
+daemon() {
+ # Test syntax.
+ if [ $# = 0 ]; then
+ echo "Usage: daemon {program}"
+ return 1
+ fi
+
+ # Save basename.
+ base=`basename $1`
+
+ # See if it's already running.
+ [ "`pidofproc $base`" != "" ] && return
+
+ # echo basename of the program.
+ echo -n "$base "
+
+ # And start it up.
+ $*
+}
+
+# A function to stop a program.
+killproc() {
+ # Test syntax.
+ if [ $# = 0 ]; then
+ echo "Usage: killproc {program} [signal]"
+ return 1
+ fi
+
+ notset=0
+ # check for second arg to be kill level
+ if [ "$2" != "" ] ; then
+ killlevel=$2
+ else
+ notset=1
+ killlevel="-9"
+ fi
+
+ # Save basename.
+ base=`basename $1`
+
+ # Find pid.
+ pid=`pidofproc $base`
+
+ # Kill it.
+ if [ "$pid" != "" ] ; then
+ echo -n "$base "
+ if [ "$notset" = 1 ] ; then
+ # TERM first, then KILL if not dead
+ kill -TERM $pid
+ usleep 10000
+ dead=`ps aux | awk "{print $2}" | grep $pid`
+ if [ "$dead" != "" ]; then
+ sleep 4
+ kill -KILL $pid
+ fi
+ # use specified level only
+ else
+ kill $killlevel $pid
+ fi
+ fi
+
+ # Remove pid file if any.
+ rm -f /var/run/$base.pid
+}
+
+# A function to find the pid of a program.
+pidofproc() {
+ # Test syntax.
+ if [ $# = 0 ] ; then
+ echo "Usage: pidofproc {program}"
+ return 1
+ fi
+
+ # First try "pidof"
+ pid=`pidof $1`
+ if [ "$pid" != "" ] ; then
+ echo $pid
+ return 0
+ fi
+
+ # Next try "/var/run/*.pid" files
+ if [ -f /var/run/$1.pid ] ; then
+ pid=`head -1 /var/run/$1.pid`
+ if [ "$pid" != "" ] ; then
+ echo $pid
+ return 0
+ fi
+ fi
+
+ # Finally try to extract it from ps
+ ps auxw | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
+ { if ((prog == $11) || (("(" prog ")") == $11) ||
+ ((prog ":") == $11)) { print $2 } }' $1
+}
+status() {
+ # Test syntax.
+ if [ $# = 0 ] ; then
+ echo "Usage: status {program}"
+ return 1
+ fi
+
+ # First try "pidof"
+ pid=`pidof $1`
+ if [ "$pid" != "" ] ; then
+ echo "$1 is running..."
+ return 0
+ fi
+
+ # Next try "/var/run/*.pid" files
+ if [ -f /var/run/$1.pid ] ; then
+ pid=`head -1 /var/run/$1.pid`
+ if [ "$pid" != "" ] ; then
+ echo "$1 dead but pid file exists"
+ return 1
+ fi
+ fi
+ # See if /var/lock/subsys/$1 exists
+ if [ -f /var/lock/subsys/$1 ]; then
+ echo "$1 dead but subsys locked"
+ return 2
+ fi
+ echo "$1 is stopped"
+ return 3
+}
diff --git a/rc.d/init.d/halt b/rc.d/init.d/halt
new file mode 100755
index 00000000..2c26854e
--- /dev/null
+++ b/rc.d/init.d/halt
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# rc.halt This file is executed by init when it goes into runlevel
+# 0 (halt) or runlevel 6 (reboot). It kills all processes,
+# unmounts file systems and then either halts or reboots.
+#
+# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+# Modified for RHS Linux by Damien Neil
+#
+
+# Set the path.
+PATH=/sbin:/bin:/usr/bin:/usr/sbin
+
+# See how we were called.
+case "$0" in
+ *halt)
+ message="The system is halted"
+ command="halt"
+ ;;
+ *reboot)
+ message="Please stand by while rebooting the system..."
+ command="reboot"
+ ;;
+ *)
+ echo "$0: call me as \"rc.halt\" or \"rc.reboot\" please!"
+ exit 1
+ ;;
+esac
+
+# Kill all processes.
+[ "${BASH+bash}" = bash ] && enable kill
+
+echo "Sending all processes the TERM signal..."
+kill -15 -1
+sleep 5
+echo "Sending all processes the KILL signal.."
+kill -9 -1
+
+# Write to wtmp file before unmounting /var
+halt -w
+
+# Turn off swap, then unmount file systems.
+echo "Turning off swap"
+swapoff -a
+echo "Unmounting file systems"
+umount -a
+mount -n -o remount,ro /
+
+echo "Remounting remaining filesystems (if any) readonly"
+mount | awk '/ext2/ { print $3 }' | while read line; do
+ mount -n -o ro,remount $line
+done
+
+# Now halt or reboot.
+echo "$message"
+[ -f /fastboot ] && echo "On the next boot fsck will be skipped."
+eval $command -d
+
diff --git a/rc.d/init.d/killall b/rc.d/init.d/killall
new file mode 100755
index 00000000..8ccfa683
--- /dev/null
+++ b/rc.d/init.d/killall
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Bring down all unneded services that are still running (there shouldn't
+# be any, so this is just a sanity check)
+
+for i in /var/lock/subsys/*; do
+ # Check if the script is there.
+ [ ! -f $i ] && continue
+
+ # Get the subsystem name.
+ subsys=${i#/var/lock/subsys/}
+
+ # Bring the subsystem down.
+ if [ -f /etc/rc.d/init.d/$subsys.init ]; then
+ /etc/rc.d/init.d/$subsys.init stop
+ else
+ /etc/rc.d/init.d/$subsys stop
+ fi
+done
+
diff --git a/rc.d/init.d/network b/rc.d/init.d/network
new file mode 100755
index 00000000..09ccc604
--- /dev/null
+++ b/rc.d/init.d/network
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# network Bring up/down networking
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+if [ ! -f /etc/sysconfig/network ]; then
+ exit 0
+fi
+
+. /etc/sysconfig/network
+
+if [ -f /etc/sysconfig/pcmcia ]; then
+ . /etc/sysconfig/pcmcia
+fi
+
+# Turn IP forwarding on or off. We do this before bringing up the interfaces
+# to make sure we don't forward when we shouldn't, and we do it even if
+# networking isn't configured (why not?).
+if [ -d /proc/sys/net/ipv4 ]; then
+ # people could have left this out of their kernel, which isn't
+ # exactly an error
+ if [ ! -f /proc/sys/net/ipv4/ip_forward ] ; then
+ echo "/proc/sys/net/ipv4/ip_forward is missing -- cannot control IP " \
+ "forwarding" >&2
+ else
+ if [ "$FORWARD_IPV4" = "no" -o "$FORWARD_IPV4" = "false" ]; then
+ value=0
+ echo "Disabling IPv4 packet forwarding."
+ else
+ echo "Enabling IPv4 packet forwarding."
+ value=1
+ fi
+
+ echo "$value" > /proc/sys/net/ipv4/ip_forward
+ fi
+fi
+
+# Check that networking is up.
+[ ${NETWORKING} = "no" ] && exit 0
+
+[ -f /sbin/ifconfig ] || exit 0
+
+cd /etc/sysconfig/network-scripts
+
+interfaces=`ls ifcfg* | grep -v ifcfg-lo | grep -v :`
+
+# See how we were called.
+case "$1" in
+ start)
+ ./ifup ifcfg-lo
+ for i in $interfaces; do
+ ./ifup $i boot
+ done
+
+ touch /var/lock/subsys/network
+ ;;
+ stop)
+ for i in $interfaces; do
+ ./ifdown $i boot
+ done
+ ./ifdown ifcfg-lo
+ rm -f /var/lock/subsys/network
+ ;;
+ *)
+ echo "Usage: network {start|stop}"
+ exit 1
+esac
+
+exit 0
diff --git a/rc.d/init.d/nfsfs b/rc.d/init.d/nfsfs
new file mode 100755
index 00000000..6da8eaa9
--- /dev/null
+++ b/rc.d/init.d/nfsfs
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# nfsfs Mount NFS filesystems.
+#
+# Version: @(#) /etc/init.d/skeleton 1.01 26-Oct-1993
+#
+# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+#
+
+# Source networking configuration.
+if [ ! -f /etc/sysconfig/network ]; then
+ exit 0
+fi
+
+. /etc/sysconfig/network
+
+# Check that networking is up.
+[ ${NETWORKING} = "no" ] && exit 0
+
+# See how we were called.
+case "$1" in
+ start)
+ echo -n "Mounting remote filesystems."
+ mount -a -t nfs
+ touch /var/lock/subsys/nfsfs
+ echo
+ ;;
+ stop)
+ echo -n "Unmounting remote filesystems."
+ umount -a -t nfs
+ rm -f /var/lock/subsys/nfsfs
+ echo
+ ;;
+ *)
+ echo "Usage: nfsfs {start|stop}"
+ exit 1
+esac
+
+exit 0
+
diff --git a/rc.d/init.d/random b/rc.d/init.d/random
new file mode 100755
index 00000000..348f0295
--- /dev/null
+++ b/rc.d/init.d/random
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# random Script to snapshot random state and reload it at boot time.
+#
+# Author: Theodore Ts'o <tytso@mit.edu>
+#
+
+random_seed=/var/run/random-seed
+
+# See how we were called.
+case "$1" in
+ start)
+ echo "Initializing random number generator..."
+ # Carry a random seed from start-up to start-up
+ # Load and then save 512 bytes, which is the size of the entropy pool
+ if [ -f $random_seed ]; then
+ cat $random_seed >/dev/urandom
+ fi
+ dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
+ touch /var/lock/subsys/random
+
+ ;;
+ stop)
+ # Carry a random seed from shut-down to start-up
+ # Save 512 bytes, which is the size of the entropy pool
+ echo "Saving random seed..."
+ dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
+
+ rm -f /var/lock/subsys/random
+ ;;
+ *)
+ echo "Usage: random {start|stop}"
+ exit 1
+esac
+
+exit 0
+
diff --git a/rc.d/init.d/single b/rc.d/init.d/single
new file mode 100755
index 00000000..98140a9c
--- /dev/null
+++ b/rc.d/init.d/single
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+#
+# rc.single This file is executed by init when it goes into runlevel
+# 1, which is the administrative state. It kills all
+# deamons and then puts the system into single user mode.
+# Note that the file systems are kept mounted.
+#
+# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+# Modified for RHS Linux by Damien Neil
+#
+
+# Set the path.
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+# Kill all processes.
+[ "${BASH+bash}" = bash ] && enable kill
+
+echo "Sending all processes the TERM signal..."
+kill -15 -1
+sleep 5
+echo "Sending all processes the KILL signal.."
+kill -9 -1
+
+rm -f /var/lock/subsys/*
+
+# Now go to the single user level.
+echo "Telling INIT to go to single user mode."
+exec init -t1 S
diff --git a/rc.d/init.d/skeleton b/rc.d/init.d/skeleton
new file mode 100755
index 00000000..a0d2758b
--- /dev/null
+++ b/rc.d/init.d/skeleton
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# skeleton Example file to build /etc/init.d scripts.
+#
+# Version: @(#) /etc/init.d/skeleton 1.01 26-Oct-1993
+#
+# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# See how we were called.
+case "$1" in
+ start)
+ touch /var/lock/subsys/skeleton
+ ;;
+ stop)
+ rm -f /var/lock/subsys/skeleton
+ ;;
+ *)
+ echo "Usage: skeleton {start|stop}"
+ exit 1
+esac
+
+exit 0
+
diff --git a/rc.d/rc b/rc.d/rc
new file mode 100755
index 00000000..a2b94559
--- /dev/null
+++ b/rc.d/rc
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# rc This file is responsible for starting/stopping
+# services when the runlevel changes. It is also
+# responsible for the very first setup of basic
+# things, such as setting the hostname.
+#
+# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
+# Modified for RHS Linux by Damien Neil
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Now find out what the current and what the previous runlevel are.
+argv1="$1"
+set `/sbin/runlevel`
+runlevel=$2
+previous=$1
+export runlevel previous
+
+# Get first argument. Set new runlevel to this argument.
+[ "$1" != "" ] && runlevel="$argv1"
+
+# Is there an rc directory for this new runlevel?
+if [ -d /etc/rc.d/rc$runlevel.d ]; then
+ # First, run the KILL scripts.
+ for i in /etc/rc.d/rc$runlevel.d/K*; do
+ # Check if the script is there.
+ [ ! -f $i ] && continue
+
+ # Check if the subsystem is already up.
+ subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
+ [ ! -f /var/lock/subsys/$subsys ] && \
+ [ ! -f /var/lock/subsys/${subsys}.init ] && continue
+
+ # Bring the subsystem down.
+ $i stop
+ done
+
+ # Now run the START scripts.
+ for i in /etc/rc.d/rc$runlevel.d/S*; do
+ # Check if the script is there.
+ [ ! -f $i ] && continue
+
+ # Check if the subsystem is already up.
+ subsys=${i#/etc/rc.d/rc$runlevel.d/S??}
+ [ -f /var/lock/subsys/$subsys ] && \
+ [ -f /var/lock/subsys/${subsys}.init ] && continue
+
+ # Bring the subsystem up.
+ $i start
+ done
+fi
diff --git a/rc.d/rc.local b/rc.d/rc.local
new file mode 100755
index 00000000..51009563
--- /dev/null
+++ b/rc.d/rc.local
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# This script will be executed *after* all the other init scripts.
+# You can put your own initialization stuff in here if you don't
+# want to do the full Sys V style init stuff.
+
+if [ -f /etc/redhat-release ]; then
+ R=$(cat /etc/redhat-release)
+else
+ R="release 3.0.3"
+fi
+
+arch=$(uname -m)
+a="a"
+case "_$arch" in
+ _a*) a="an";;
+ _i*) a="an";;
+esac
+
+# This will overwrite /etc/issue at every boot. So, make any changes you
+# want to make to /etc/issue here or you will lose them when you reboot.
+echo "" > /etc/issue
+echo "Red Hat Linux $R" >> /etc/issue
+echo "Kernel $(uname -r) on $a $(uname -m)" >> /etc/issue
+
+cp -f /etc/issue /etc/issue.net
+echo >> /etc/issue
diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit
new file mode 100755
index 00000000..af3753c9
--- /dev/null
+++ b/rc.d/rc.sysinit
@@ -0,0 +1,212 @@
+#! /bin/sh
+#
+# /etc/rc.d/rc.sysinit - run once at boot time
+#
+# Taken in part from Miquel van Smoorenburg's bcheckrc.
+#
+
+# Set the path
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+export PATH
+
+# Read in config data.
+if [ -f /etc/sysconfig/network ]; then
+ . /etc/sysconfig/network
+else
+ NETWORKING=no
+ HOSTNAME=localhost
+fi
+
+# Start up swapping.
+echo "Activating swap partitions"
+swapon -a
+
+# Set the hostname.
+hostname ${HOSTNAME}
+echo hostname: `hostname`
+
+if [ ! -f /fastboot ]; then
+ echo "Checking root filesystems."
+ fsck -V -a /
+
+ rc=$?
+
+ # A return of 2 or higher means there were serious problems.
+ if [ $rc -gt 1 ]; then
+ echo
+ echo
+ echo "*** An error occurred during the file system check."
+ echo "*** Dropping you to a shell; the system will reboot"
+ echo "*** when you leave the shell."
+
+ PS1="(Repair filesystem) #"; export PS1
+ sulogin
+
+ echo "Unmounting file systems"
+ umount -a
+ mount -n -o remount,ro /
+ echo "Automatic reboot in progress."
+ reboot
+ elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
+ echo "Checking root filesystem quotas"
+ /sbin/quotacheck -v /
+ fi
+fi
+
+if [ -x /sbin/quotaon ]; then
+ echo "Turning on user and group quotas for root filesystem"
+ /sbin/quotaon /
+fi
+
+# Remount the root filesystem read-write.
+echo "Remounting root filesystem in read-write mode."
+mount -n -o remount,rw /
+
+if [ ! -f /etc/HOSTNAME ]; then
+ echo ${HOSTNAME} > /etc/HOSTNAME
+fi
+
+# Clear mtab
+>/etc/mtab
+
+# Enter root into mtab.
+mount -f /
+
+# mount /proc
+mount -t proc /proc /proc
+if [ -f /proc/ksyms ]; then
+ USEMODULES=y
+else
+ USEMODULES=
+fi
+
+# we can't leave this mounted as it confuses "mount -a" later (dumb)
+umount /proc
+
+if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
+ # Get ready for kerneld if module support in the kernel
+ echo -n "Finding module dependencies"
+ depmod -a
+ echo ""
+fi
+
+if [ -x /sbin/kerneld -a -n "$USEMODULES" ]; then
+ /sbin/kerneld
+fi
+
+# Check filesystems
+if [ ! -f /fastboot ]; then
+ echo "Checking filesystems."
+ fsck -R -A -V -a
+
+ # A return of 2 or higher means there were serious problems.
+ if [ $? -gt 1 ]; then
+ echo
+ echo
+ echo "*** An error occurred during the file system check."
+ echo "*** Dropping you to a shell; the system will reboot"
+ echo "*** when you leave the shell."
+
+ PS1="(Repair filesystem) #"; export PS1
+ sulogin
+
+ echo "Unmounting file systems"
+ umount -a
+ mount -n -o remount,ro /
+ echo "Automatic reboot in progress."
+ reboot
+ elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
+ echo "Checking filesystem quotas"
+ /sbin/quotacheck -v -R -a
+ fi
+fi
+
+# Mount all other filesystems (except for NFS). Contrary to standard usage,
+# filesystems are NOT unmounted in single user mode.
+echo "Mounting local filesystems."
+
+mount -a -t nonfs
+
+if [ -x /sbin/quotaon ]; then
+ echo "Turning on user and group quotas for local filesystems"
+ /sbin/quotaon -a
+fi
+
+
+# Clean out /etc.
+rm -f /etc/mtab~ /fastboot /etc/nologin
+>/var/run/utmp
+
+# Delete UUCP lock files.
+rm -f /var/lock/LCK*
+
+# Delete stale subsystem files.
+rm -f /var/lock/subsys/*
+
+# Delete stale pid files
+rm -f /var/run/*.pid
+
+# Delete X locks
+rm -f /tmp/.X*-lock
+
+# Set the system clock.
+echo -n "Setting clock"
+
+ARC=0
+UTC=0
+if [ -f /etc/sysconfig/clock ]; then
+ . /etc/sysconfig/clock
+
+ # convert old style clock config to new values
+ if [ "${CLOCKMODE}" = "GMT" ]; then
+ UTC=true
+ elif [ "${CLOCKMODE}" = "ARC" ]; then
+ ARC=true
+ fi
+fi
+
+CLOCKFLAGS="-a"
+if [ $UTC = "true" ]; then
+ CLOCKFLAGS="$CLOCKFLAGS -u";
+ echo -n " (utc)"
+fi
+if [ $ARC = "true" ]; then
+ CLOCKFLAGS="$CLOCKFLAGS -A";
+ echo -n " (arc)"
+fi
+echo -n ": "
+clock $CLOCKFLAGS
+
+date
+
+# Right, now turn on swap in case we swap to files.
+echo "Enabling swap space."
+swapon -a 2>&1 | grep -v "busy"
+
+# Initialize the serial ports.
+if [ -f /etc/rc.d/rc.serial ]; then
+ . /etc/rc.d/rc.serial
+fi
+
+# Load modules (for backward compatibility with VARs)
+if [ -f /etc/rc.d/rc.modules ]; then
+ /etc/rc.d/rc.modules
+fi
+
+# If a SCSI tape has been detected, load the st module unconditionally
+# since many SCSI tapes don't deal well with st being loaded and unloaded
+if cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
+ if cat /proc/devices | grep -qv ' 9 st' ; then
+ if [ -n "$USEMODULES" ] ; then
+ # Try to load the module. If it fails, ignore it...
+ modprobe st 2>/dev/null
+ fi
+ fi
+fi
+
+# Now that we have all of our basic modules loaded and the kernel going,
+# let's dump the syslog ring somewhere so we can find it later
+dmesg > /var/log/dmesg
+
+# Feed entropy into the entropy pool
+/etc/rc.d/init.d/random start
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 00000000..b3324ef6
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,26 @@
+CFLAGS+=-Wall
+
+PROGS=usernetctl doexec netreport testd usleep
+
+all: $(PROGS)
+
+clean:
+ rm -f $(PROGS)
+
+install:
+ mkdir -p $(ROOT)/bin $(ROOT)/usr/sbin $(ROOT)/usr/man/man1
+ install -o 0 -g 0 -s -m 755 doexec $(ROOT)/bin/doexec
+ install -o 0 -g 0 -s -m 755 usleep $(ROOT)/bin/usleep
+ install -o 0 -g 0 -s -m 4755 usernetctl $(ROOT)/usr/sbin/usernetctl
+ install -o 0 -g 0 -s -m 2755 netreport $(ROOT)/sbin/netreport
+ install -m 644 doexec.1 $(ROOT)/usr/man/man1
+ install -m 644 netreport.1 $(ROOT)/usr/man/man1
+ install -m 644 usleep.1 $(ROOT)/usr/man/man1
+ install -m 644 usernetctl.1 $(ROOT)/usr/man/man1
+
+# this daemon and initscript are useful for testing the up/down/status stuff
+# not installed by default, only comes from sources.
+install-test:
+ install -o 0 -g 0 -s -m 755 testd $(ROOT)/usr/sbin/testd
+ install -o 0 -g 0 -m 755 testdinit $(ROOT)/etc/rc.d/init.d/testd
+
diff --git a/src/doexec.1 b/src/doexec.1
new file mode 100644
index 00000000..59b8b91e
--- /dev/null
+++ b/src/doexec.1
@@ -0,0 +1,12 @@
+.TH DOEXEC 1 "Red Hat Software" "RHS" \" -*- nroff -*-
+.SH NAME
+doexec \- run an executable with an arbitrary argv[0]
+.SH SYNOPSIS
+.B doexec
+\fI/path/to/executable\fP \fIargv[0]\fP [\fIargv[1-n]\fP]
+.SH DESCRIPTION
+.B doexec
+simply runs the executable with the argv list provided. It allows you
+to specify an argv[0] other than the name of the executable.
+.SH OPTIONS
+All options are passed in the argv list to the executable being run.
diff --git a/src/doexec.c b/src/doexec.c
new file mode 100644
index 00000000..a488be13
--- /dev/null
+++ b/src/doexec.c
@@ -0,0 +1,6 @@
+#include <unistd.h>
+
+int main(int argc, char ** argv) {
+ execvp(argv[1], argv + 2);
+ return 1;
+}
diff --git a/src/netreport.1 b/src/netreport.1
new file mode 100644
index 00000000..ff52e91b
--- /dev/null
+++ b/src/netreport.1
@@ -0,0 +1,22 @@
+.TH USERNETCTL 1 "Red Hat Software" "RHS" \" -*- nroff -*-
+.SH NAME
+netreport \- request notification of network interface changes
+.SH SYNOPSIS
+.B netreport
+\fI[\fP-r\fI]\fP
+.SH DESCRIPTION
+.B netreport
+tells the network management scripts to send a SIGIO signal
+to the process which called netreport when any network interface
+status changes occur.
+.SH OPTIONS
+.TP
+.B -r
+Remove the current request (if any) for the calling process.
+.PP
+.SH NOTES
+If a program does not call netreport with the
+.B -r
+option before it exits, and another process is created with the
+same PID before any changes take place in interface status, it
+is possible that the new process will receive a spurious SIGIO.
diff --git a/src/netreport.c b/src/netreport.c
new file mode 100644
index 00000000..56088ec1
--- /dev/null
+++ b/src/netreport.c
@@ -0,0 +1,45 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+/* this will be running setgid root, so be careful! */
+
+void usage(void) {
+ fprintf(stderr, "usage: netreport [-r]\n");
+ exit(1);
+}
+
+#define ADD 1
+#define DEL 0
+int main(int argc, char ** argv) {
+ int action = ADD;
+ /* more than long enough for "/var/run/netreport/<pid>\0" */
+ char netreport_name[64];
+ int netreport_file;
+
+ if (argc > 2) usage();
+
+ if ((argc > 1) && !strcmp(argv[1], "-r")) {
+ action = DEL;
+ }
+
+ sprintf(netreport_name, "/var/run/netreport/%d", getppid());
+ if (action == ADD) {
+ netreport_file = creat(netreport_name, 0);
+ if (netreport_file < 0) {
+ if (errno != EEXIST) {
+ perror("Could not create netreport file");
+ exit (1);
+ }
+ } else {
+ close(netreport_file);
+ }
+ } else {
+ /* ignore errors; not much we can do, won't hurt anything */
+ unlink(netreport_name);
+ }
+
+ exit(0);
+}
diff --git a/src/testd.c b/src/testd.c
new file mode 100644
index 00000000..f512cec9
--- /dev/null
+++ b/src/testd.c
@@ -0,0 +1,7 @@
+#include <sys/signal.h>
+#include <unistd.h>
+
+void main() {
+ signal(SIGTERM, SIG_IGN);
+ while (1) sleep(20);
+}
diff --git a/src/testdinit b/src/testdinit
new file mode 100755
index 00000000..f2f4a85b
--- /dev/null
+++ b/src/testdinit
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# lpd This shell script takes care of starting and stopping
+# lpd (printer daemon).
+#
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# See how we were called.
+case "$1" in
+ start)
+ # Start daemons.
+ echo -n "Starting testd: "
+ testd &
+ echo
+ touch /var/lock/subsys/testd
+ ;;
+ stop)
+ # Stop daemons.
+ echo -n "Shutting down testd: "
+ killproc testd
+ echo
+ rm -f /var/lock/subsys/testd
+ ;;
+ status)
+ # Am I alive?
+ status testd
+ exit $?
+ ;;
+ restart)
+ echo -n "Shutting down testd: "
+ killproc testd
+ echo
+ echo -n "Starting testd: "
+ testd &
+ echo
+ ;;
+ *)
+ echo "Usage: testd {start|stop|status|restart}"
+ exit 1
+esac
+
+exit 0
diff --git a/src/usernetctl.1 b/src/usernetctl.1
new file mode 100644
index 00000000..1602f7b5
--- /dev/null
+++ b/src/usernetctl.1
@@ -0,0 +1,18 @@
+.TH USERNETCTL 1 "Red Hat Software" "RHS" \" -*- nroff -*-
+.SH NAME
+usernetctl \- allow a user to manipulate a network interface if permitted
+.SH SYNOPSIS
+.B usernetctl
+\fIconfig-file-name\fP up\fI|\fPdown
+.SH DESCRIPTION
+.B usernetctl
+checks to see if users are allowed to manipulate the network interface
+specified by \fIconfig-file-name\fP, and then tries to bring the network
+interface up or down, as specified.
+.SH OPTIONS
+.TP
+.I "\fIconfig-file-name"
+The name of the network configuration file to read; for example, ifcfg-ppp0
+.TP
+up\fI|\fPdown
+Attempt to bring the interface up or down.
diff --git a/src/usernetctl.c b/src/usernetctl.c
new file mode 100644
index 00000000..1139a8c5
--- /dev/null
+++ b/src/usernetctl.c
@@ -0,0 +1,130 @@
+#include <alloca.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+/* this will be running setuid root, so be careful! */
+
+void usage(void) {
+ fprintf(stderr, "usage: usernetctl <interface-config> <up|down>\n");
+ exit(1);
+}
+
+static char * safeEnviron[] = {
+ "PATH=/bin:/sbin:/usr/bin:/usr/sbin",
+ "HOME=/root",
+ NULL
+};
+
+int userCtl(char * file, int size) {
+ char * contents;
+ char * chptr;
+ char * end;
+ int fd;
+
+ contents = alloca(size + 2);
+
+ if ((fd = open(file, O_RDONLY)) < 0) {
+ fprintf(stderr, "failed to open %s: %s\n", file, strerror(errno));
+ exit(1);
+ }
+
+ if (read(fd, contents, size) != size) {
+ perror("error reading device configuration");
+ exit(1);
+ }
+ close(fd);
+
+ contents[size] = '\n';
+ contents[size + 1] = '\0';
+
+ /* each pass parses a single line (until an answer is found), contents
+ itself points to the beginning of the current line */
+ while (*contents) {
+ chptr = contents;
+ while (*chptr != '\n') chptr++;
+ end = chptr + 1;
+ while (chptr > contents && isspace(*chptr)) chptr--;
+ *(++chptr) = '\0';
+
+ if (!strcmp(contents, "USERCTL=yes")) return 1;
+
+ contents = end;
+ }
+
+ return 0;
+}
+
+int main(int argc, char ** argv) {
+ char * ifaceConfig;
+ char * chptr;
+ struct stat sb;
+ char * cmd;
+
+ if (argc != 3) usage();
+
+ if (!strcmp(argv[2], "up")) {
+ cmd = "./ifup";
+ } else if (!strcmp(argv[2], "down")) {
+ cmd = "./ifdown";
+ } else {
+ usage();
+ }
+
+ if (chdir("/etc/sysconfig/network-scripts")) {
+ fprintf(stderr, "error switching to /etc/sysconfig/network-scripts: "
+ "%s\n", strerror(errno));
+ exit(1);
+ }
+
+ /* force the interface configuration to be in the current directory */
+ chptr = ifaceConfig = argv[1];
+ while (*chptr) {
+ if (*chptr == '/')
+ ifaceConfig = chptr + 1;
+ chptr++;
+ }
+
+ /* these shouldn't be symbolic links -- anal, but that's fine w/ me */
+ if (lstat(ifaceConfig, &sb)) {
+ fprintf(stderr, "failed to stat %s: %s\n", ifaceConfig,
+ strerror(errno));
+ exit(1);
+ }
+
+ /* safety checks */
+ if (!S_ISREG(sb.st_mode)) {
+ fprintf(stderr, "%s is not a normal file\n", ifaceConfig);
+ exit(1);
+ }
+
+ if (sb.st_uid) {
+ fprintf(stderr, "%s should be owned by root\n", ifaceConfig);
+ exit(1);
+ }
+
+ if (sb.st_mode & S_IWOTH) {
+ fprintf(stderr, "%s should not be world writeable\n", ifaceConfig);
+ exit(1);
+ }
+
+ if (!userCtl(ifaceConfig, sb.st_size)) {
+ fprintf(stderr, "Users are not allowed to control this interface.\n");
+ exit(1);
+ }
+
+ /* looks good to me -- let's go for it */
+
+ /* pppd wants the real uid to be the same as the effective (god only
+ knows why when it works fine setuid out of the box) */
+ setuid(geteuid());
+
+ execle(cmd, cmd, ifaceConfig, NULL, safeEnviron);
+ fprintf(stderr, "exec of %s failed: %s\n", cmd, strerror(errno));
+
+ exit(1);
+}
diff --git a/src/usleep.1 b/src/usleep.1
new file mode 100644
index 00000000..f1e19025
--- /dev/null
+++ b/src/usleep.1
@@ -0,0 +1,20 @@
+.TH USLEEP 1 "Red Hat Software" "RHS" \" -*- nroff -*-
+.SH NAME
+usleep \- sleep some number of microseconds
+.SH SYNOPSIS
+.B usleep
+[\fInumber\fP]
+.SH DESCRIPTION
+.B usleep
+sleeps some number of microseconds. The default is 1.
+.SH OPTIONS
+\fI--help\fP
+Print help information.
+.TP
+\fI-v\fP
+Print version information.
+.SH BUGS
+Probably not accurate on many machines down to the microsecond. Count
+on precision only to -4 or maybe -5.
+.SH AUTHOR
+Donald Barnes <djb@redhat.com>
diff --git a/src/usleep.c b/src/usleep.c
new file mode 100644
index 00000000..dbffc850
--- /dev/null
+++ b/src/usleep.c
@@ -0,0 +1,37 @@
+/*
+ * usleep
+ *
+ * Written by Donald Barnes <djb@redhat.com> for Red Hat Software.
+ *
+ */
+
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+void main(int argc, char **argv)
+{
+
+ double count;
+
+ if (argc == 1) count=1;
+ else if (!strcmp(argv[1], "--help"))
+ {
+ printf("usleep [number]\n sleep [number] of microseconds\n the default number to sleep is 1 microsecond\n");
+ exit(0);
+ }
+ else if (!strcmp(argv[1], "-v"))
+ {
+ printf("usleep version 1.0 by Donald Barnes <djb@redhat.com>\n usleep --help for more info\n");
+ exit(0);
+ }
+ else
+ count = strtod(argv[1], NULL);
+
+ usleep(count);
+ exit(0);
+
+
+}
diff --git a/sysconfig/network-scripts/ifcfg-lo b/sysconfig/network-scripts/ifcfg-lo
new file mode 100644
index 00000000..e21fb29f
--- /dev/null
+++ b/sysconfig/network-scripts/ifcfg-lo
@@ -0,0 +1,6 @@
+DEVICE=lo
+IPADDR=127.0.0.1
+NETMASK=255.0.0.0
+NETWORK=127.0.0.0
+BROADCAST=127.255.255.255
+ONBOOT=yes
diff --git a/sysconfig/network-scripts/ifdhcpc-done b/sysconfig/network-scripts/ifdhcpc-done
new file mode 100644
index 00000000..239725de
--- /dev/null
+++ b/sysconfig/network-scripts/ifdhcpc-done
@@ -0,0 +1,20 @@
+#!/bin/sh -x
+
+SLEEPPIDFILE=/var/run/dhcp-wait-${IFNAME}.pid
+
+if [ ! -f $SLEEPPIDFILE ]; then
+ # the parent must have timed out already -- we can't do much about
+ # it now
+ echo "DHCP configured but ifup timed out"
+ #exit 0
+fi
+
+# get the pid of the process which is waiting for this to complete
+SLEEPPID=`cat $SLEEPPIDFILE`
+rm -f $SLEEPPIDFILE
+kill $SLEEPPID
+
+if [ -f /etc/dhcpc/resolv.conf ]; then
+ echo "setting up resolv.conf" >> /tmp/dhcplog
+ cp /etc/dhcpc/resolv.conf /etc
+fi
diff --git a/sysconfig/network-scripts/ifdown b/sysconfig/network-scripts/ifdown
new file mode 100755
index 00000000..079d1ff5
--- /dev/null
+++ b/sysconfig/network-scripts/ifdown
@@ -0,0 +1,42 @@
+#!/bin/sh
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+cd /etc/sysconfig/network-scripts
+
+if [ $UID != 0 ]; then
+ if [ -x /usr/sbin/usernetctl ]; then
+ exec /usr/sbin/usernetctl $1 down
+ fi
+ echo "Users cannot control this device." >&2
+ exit 1
+fi
+
+. $1
+
+DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
+OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}"
+
+if [ -x $OTHERSCRIPT ]; then
+ $OTHERSCRIPT $1 $2
+ exit $?
+fi
+
+if echo $DEVICE | grep -q ':' ; then
+ ISALIAS=yes
+else
+ ISALIAS=no
+fi
+
+if [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then
+ if [ -f /var/run/dhcpcd-${DEVICE}.pid ]; then
+ kill `cat /var/run/dhcpcd-${DEVICE}.pid`
+ rm -f /var/run/dhcpcd-${DEVICE}.pid
+ exit 0
+ fi
+ exit 1
+fi
+
+ifconfig ${DEVICE} down
+
+exec /etc/sysconfig/network-scripts/ifdown-post $1
+
diff --git a/sysconfig/network-scripts/ifdown-post b/sysconfig/network-scripts/ifdown-post
new file mode 100755
index 00000000..cb7ce8c1
--- /dev/null
+++ b/sysconfig/network-scripts/ifdown-post
@@ -0,0 +1,18 @@
+#!/bin/sh
+# This should be called whenever an interface goes down, not just when
+# it is brought down explicitly.
+
+cd /etc/sysconfig/network-scripts
+
+. $1
+
+# Notify programs that have requested notification
+( cd /var/run/netreport || exit
+ for i in * ; do
+ [ -f $i ] && \
+ kill -SIGIO $i >/dev/null 2>&1 || \
+ rm -f $i >/dev/null 2>&1
+ done
+)
+
+exit 0
diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp
new file mode 100755
index 00000000..31845640
--- /dev/null
+++ b/sysconfig/network-scripts/ifdown-ppp
@@ -0,0 +1,44 @@
+#!/bin/bash
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+cd /etc/sysconfig/network-scripts
+
+. $1
+
+if [ ! -f /var/run/ppp-$DEVICE.dev ]; then
+ # ppp isn't running, or we didn't start it
+ exit 0
+fi
+
+file=/var/run/`cat /var/run/ppp-$DEVICE.dev`.pid
+if [ ! -f $file ]; then
+ exit 0
+fi
+
+# signals ifup-ppp not to persist
+rm -f /var/run/ppp-$DEVICE.dev
+
+PID=`cat $file`
+if [ -z "$PID" ]; then
+ exit 1
+fi
+
+kill $PID > /dev/null 2>&1
+if [ ! -d /proc/$PID ]; then
+ /etc/sysconfig/network-scripts/ifdown-post $1
+ exit 0
+fi
+sleep 2
+if [ ! -d /proc/$PID ]; then
+ /etc/sysconfig/network-scripts/ifdown-post $1
+ exit 0
+fi
+
+kill -KILL $PID > /dev/null 2>&1
+if [ -d /proc/$PID ]; then
+ logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" &
+else
+ /etc/sysconfig/network-scripts/ifdown-post $1
+fi
+
+exit 1
diff --git a/sysconfig/network-scripts/ifdown-sl b/sysconfig/network-scripts/ifdown-sl
new file mode 100755
index 00000000..cb3a8f12
--- /dev/null
+++ b/sysconfig/network-scripts/ifdown-sl
@@ -0,0 +1,35 @@
+#!/bin/bash
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+cd /etc/sysconfig/network-scripts
+
+. $1
+
+# signals ifup-sl not to persist
+rm -f /var/run/sl-$DEVICE.dev
+
+PID=`pidof dip-$DEVICE`
+if [ -z "$PID" ]; then
+ exit 1
+fi
+
+kill $PID > /dev/null 2>&1
+if [ ! -d /proc/$PID ]; then
+ /etc/sysconfig/network-scripts/ifdown-post $1
+ exit 0
+fi
+sleep 2
+if [ ! -d /proc/$PID ]; then
+ /etc/sysconfig/network-scripts/ifdown-post $1
+ exit 0
+fi
+
+kill -KILL $PID > /dev/null 2>&1
+if [ -d /proc/$PID ]; then
+ logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" &
+else
+ /etc/sysconfig/network-scripts/ifdown-post $1
+fi
+
+exit 1
+
diff --git a/sysconfig/network-scripts/ifup b/sysconfig/network-scripts/ifup
new file mode 100755
index 00000000..76cdf379
--- /dev/null
+++ b/sysconfig/network-scripts/ifup
@@ -0,0 +1,158 @@
+#!/bin/sh
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+cd /etc/sysconfig/network-scripts
+
+if [ $UID != 0 ]; then
+ if [ -x /usr/sbin/usernetctl ]; then
+ exec /usr/sbin/usernetctl $1 up
+ fi
+ echo "Users cannot control this device." >&2
+ exit 1
+fi
+
+. $1
+
+if [ "foo$2" = "fooboot" -a "${ONBOOT}" = "no" ]
+then
+ exit
+fi
+
+IPSETUP=no
+
+DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
+REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
+if echo $DEVICE | grep -q ':' ; then
+ ISALIAS=yes
+else
+ ISALIAS=no
+fi
+
+# Old BOOTP variable
+if [ "$BOOTP" = "yes" ]; then
+ BOOTPROTO=bootp
+fi
+
+if [ -e /etc/sysconfig/pcmcia ]; then
+ . /etc/sysconfig/pcmcia
+else
+ PCMCIA=no
+fi
+
+if [ $DEVICETYPE = "eth" -a "foo${ISPCMCIA}" = "foo" ]; then
+ # this is a horrible hack to work around prior brokenness
+ if [ "$PCMCIA" = "yes" -a "foo$2" = "fooboot" ]; then
+ # cardmgr will start us up properly
+ exit 0;
+ fi
+elif [ "${ISPCMCIA}" = "yes" -a "$2" = "boot" ]; then
+ # cardmgr will start us up properly
+ exit 0;
+fi
+
+### end of horrible hack
+
+OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
+
+if [ -x $OTHERSCRIPT ]; then
+ exec $OTHERSCRIPT $1 $2
+fi
+
+# is this device available? (this catches PCMCIA devices for us)
+/sbin/ifconfig ${REALDEVICE} 2>&1 | grep -s "unknown interface" > /dev/null
+if [ "$?" = "0" ]; then
+ echo "Delaying ${DEVICE} initialization."
+ exit 0
+fi
+
+if [ "$SLAVE" = yes -a "$ISALIAS" = no -a "$MASTER" != "" -a \
+ -x /sbin/ifenslave ]; then
+ RFLAG="" ; [ "$RECIEVE-ONLY" = yes ] && RFLAG="-r"
+
+ ifconfig ${DEVICE} down
+ echo "Enslaving $DEVICE to $MASTER"
+ ifenslave $RFLAG "$DEVICE" "$MASTER"
+
+ exit 0
+fi
+
+if [ "$BOOTPROTO" = bootp -a "$ISALIAS" = no ]; then
+ ifconfig ${DEVICE} down
+ ifconfig ${DEVICE} 0.0.0.0 broadcast 255.255.255.255 netmask 0.0.0.0
+ route add default ${DEVICE}
+ echo "Sending bootp request"
+ bootpc --returniffail --timeoutwait 6 --dev ${DEVICE} 2>/dev/null > /tmp/bootpc-response-${DEVICE}
+ if [ "$?" = "0" ]; then
+ . /tmp/bootpc-response-${DEVICE}
+ BOOTPHOSTNAME="$HOSTNAME"
+ echo "bootp response received -- using IP ${IPADDR}"
+ elif [ -z "$IPADDR" ]; then
+ echo "No bootp response recieved -- not configuring device ${DEVICE}."
+ rm -f /tmp/bootpc-response-${DEVICE}
+ exit 1
+ else
+ echo "No bootp response recieved -- using default configuration for device ${DEVICE}."
+ fi
+
+ rm -f /tmp/bootpc-response-${DEVICE}
+elif [ "$BOOTPROTO" = dhcp -a "$ISALIAS" = no ]; then
+ echo -n "Using DHCP for ${DEVICE}... "
+ /sbin/dhcpcd -c /etc/sysconfig/network-scripts/ifdhcpc-done ${DEVICE}
+ echo "echo \$$ > /var/run/dhcp-wait-${DEVICE}.pid; exec sleep 30" | sh
+
+ if [ -f /var/run/dhcp-wait-${DEVICE}.pid ]; then
+ echo "failed."
+ exit 1
+ else
+ rm -f /var/run/dhcp-wait-${DEVICE}.pid
+ echo "done."
+ IPSETUP=yes
+ fi
+fi
+
+if [ "$IPSETUP" != yes ]; then
+ ifconfig ${DEVICE} ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST}
+ if [ "$ISALIAS" = no ] ; then
+ route add -net ${NETWORK} netmask ${NETMASK} ${DEVICE}
+ else
+ route add -host ${IPADDR} ${DEVICE}
+ fi
+
+ # this is broken! it's only here for compatibility RH sytstems
+ if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ]; then
+ route add default gw ${GATEWAY} metric 1 ${DEVICE}
+ fi
+
+ . /etc/sysconfig/network
+
+ if [ "${GATEWAY}" != "" ]; then
+ if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
+ # set up default gateway
+ route add default gw ${GATEWAY} ${DEVICE}
+ DEFGW=${GATEWAY}
+ fi
+ fi
+
+ if [ "$BOOTPROTO" = bootp -a "$ISALIAS" = no ]; then
+ if [ -n "$GATEWAYS" ]; then
+ for gw in $GATEWAYS; do
+ if [ $gw != "${DEFGW}" ]; then
+ route add default gw $gw ${DEVICE}
+ fi
+ done
+ fi
+
+ if [ -n "$DNSSRVS" -a -n "$SEARCH" ]; then
+ echo "search $SEARCH" > /etc/resolv.conf
+ for dns in $DNSSRVS; do
+ echo "nameserver $dns" >> /etc/resolv.conf
+ done
+ fi
+
+ if [ -n "$BOOTPHOSTNAME" -a -z "`hostname`" ]; then
+ hostname $BOOTPHOSTNAME
+ fi
+ fi
+fi
+
+exec /etc/sysconfig/network-scripts/ifup-post $1
diff --git a/sysconfig/network-scripts/ifup-plip b/sysconfig/network-scripts/ifup-plip
new file mode 100755
index 00000000..ea423944
--- /dev/null
+++ b/sysconfig/network-scripts/ifup-plip
@@ -0,0 +1,29 @@
+#!/bin/sh
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+. $1
+
+if [ "foo$2" = "fooboot" -a ${ONBOOT} = "no" ]
+then
+ exit
+fi
+
+ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMIP}
+route add -net ${NETWORK} netmask ${NETMASK} ${DEVICE}
+
+# this is broken! it's only here to keep compatibility with old RH sytstems
+if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ]
+then
+ route add default gw ${GATEWAY} metric 1 ${DEVICE}
+fi
+
+. /etc/sysconfig/network
+
+if [ "${GATEWAY}" != "" ]; then
+ if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
+ # set up default gateway
+ route add default gw ${GATEWAY}
+ fi
+fi
+
+/etc/sysconfig/network-scripts/ifup-post $1
diff --git a/sysconfig/network-scripts/ifup-post b/sysconfig/network-scripts/ifup-post
new file mode 100755
index 00000000..f8c07822
--- /dev/null
+++ b/sysconfig/network-scripts/ifup-post
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+cd /etc/sysconfig/network-scripts
+
+. $1
+
+DEVICETYPE=`echo $DEVICE | sed "s/[0-9]*$//"`
+REALDEVICE=`echo $DEVICE | sed 's/:.*//g'`
+if echo $DEVICE | grep -q ':' ; then
+ ISALIAS=yes
+else
+ ISALIAS=no
+fi
+
+/etc/sysconfig/network-scripts/ifup-routes ${DEVICE}
+
+if [ "$ISALIAS" = no ] ; then
+ allow_null_glob_expansion=foo
+ for alias in /etc/sysconfig/network-scripts/ifcfg-${DEVICE}:* ; do
+ /etc/sysconfig/network-scripts/ifup $alias
+ done
+ unset allow_null_glob_expansion
+fi
+
+if [ `hostname` = '(none)' -o `hostname` = localhost -a ${DEVICE} != lo ]; then
+ IPADDR=`ifconfig ${DEVICE} | grep 'inet addr' | awk -F: '{ print $2 } ' | awk '{ print $1 }'`
+ host=`host ${IPADDR} | grep Name: | awk '{ print $2 }'`
+ if [ -n "$host" ]; then
+ echo "$host" > /etc/HOSTNAME
+ hostname $host
+ fi
+fi
+
+# Notify programs that have requested notification
+( cd /var/run/netreport || exit
+ for i in * ; do
+ [ -f $i ] && \
+ kill -SIGIO $i >/dev/null 2>&1 || \
+ rm -f $i >/dev/null 2>&1
+ done
+)
+
+exit 0
diff --git a/sysconfig/network-scripts/ifup-ppp b/sysconfig/network-scripts/ifup-ppp
new file mode 100755
index 00000000..f1b5813f
--- /dev/null
+++ b/sysconfig/network-scripts/ifup-ppp
@@ -0,0 +1,103 @@
+#!/bin/sh
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+# ifup-post for PPP is handled through /etc/ppp/ip-up
+
+if [ "$1" != daemon ] ; then
+ $0 daemon $*&
+ exit 0
+fi
+
+shift
+
+. $1
+
+if [ -z "$DISCONNECTTIMEOUT" ]; then
+ DISCONNECTTIMEOUT=2
+fi
+
+if [ -z "$RETRYTIMEOUT" ]; then
+ RETRYTIMEOUT=30
+fi
+
+if [ "$2" = "boot" -a ${ONBOOT} = "no" ]; then
+ exit
+fi
+
+[ -x /usr/sbin/pppd ] || {
+ echo "/usr/sbin/pppd does not exist or is not executable"
+ echo "ifup-ppp for $DEVICE exiting"
+ logger -p daemon.info -t ifup-ppp \
+ "/usr/sbin/pppd does not exist or is not executable for $DEVICE"
+ exit 1
+}
+
+[ -f /etc/sysconfig/network-scripts/chat-$DEVICE ] || {
+ echo "/etc/sysconfig/network-scripts/chat-$DEVICE does not exist"
+ echo "ifup-ppp for $DEVICE exiting"
+ logger -p daemon.info -t ifup-ppp \
+ "/etc/sysconfig/network-scripts/chat-$DEVICE does not exist for $DEVICE"
+ exit 1
+}
+
+opts="lock"
+if [ "${HARDFLOWCTL}" = yes ] ; then
+ opts="$opts modem crtscts"
+fi
+if [ "${ESCAPECHARS}" = yes ] ; then
+ opts="$opts asyncmap 00000000"
+fi
+if [ "${DEFROUTE}" = yes ] ; then
+ opts="$opts defaultroute"
+fi
+if [ -n "${MRU}" ] ; then
+ opts="$opts mru ${MRU}"
+fi
+if [ -n "${MTU}" ] ; then
+ opts="$opts mtu ${MTU}"
+fi
+if [ -n "${IPADDR}${REMIP}" ] ; then
+ # if either IP address is set, the following will work.
+ opts="$opts ${IPADDR}:${REMIP}"
+fi
+if [ -n "${PAPNAME}" ] ; then
+ opts="$opts name ${PAPNAME}"
+fi
+
+while : ; do
+ (logger -p daemon.info -t ifup-ppp \
+ "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
+
+ > /var/run/ppp-$DEVICE.dev
+ /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
+ remotename $DEVICE ipparam $DEVICE \
+ ${PPPOPTIONS} \
+ connect "/usr/sbin/chat -f /etc/sysconfig/network-scripts/chat-$DEVICE"
+
+ # exit if we're not supposed to persist or our lock file has disappeared
+ if [ "$PERSIST" != "yes" -o ! -f /var/run/ppp-$DEVICE.dev ]; then
+ rm -f /var/run/ppp-$DEVICE.dev
+ exit 0
+ fi
+
+ size=`wc -c < /var/run/ppp-$DEVICE.dev`
+
+ rm -f /var/run/ppp-$DEVICE.dev
+
+ if [ $size = 0 ]; then
+ # pppd never connected
+ timeout=$RETRYTIMEOUT
+ else
+ # pppd connected and then disconnected
+ timeout=$DISCONNECTTIMEOUT
+ fi
+
+ [ -z "$timeout" ] && {
+ timeout=30
+ }
+
+ sleep $timeout || {
+ # sleep was killed
+ exit 0
+ }
+done
diff --git a/sysconfig/network-scripts/ifup-routes b/sysconfig/network-scripts/ifup-routes
new file mode 100755
index 00000000..0733eea5
--- /dev/null
+++ b/sysconfig/network-scripts/ifup-routes
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# adds static routes which go through device $1
+
+if [ "$1" = "" ]; then
+ echo "usage: $0 <net-device>"
+ exit 1
+fi
+
+if [ ! -f /etc/sysconfig/static-routes ]; then
+ exit 0
+fi
+
+#note the trailing space in the grep gets rid of aliases
+grep "^$1 " /etc/sysconfig/static-routes | while read device args; do
+ route add -$args $device
+done
diff --git a/sysconfig/network-scripts/ifup-sl b/sysconfig/network-scripts/ifup-sl
new file mode 100755
index 00000000..aad0b051
--- /dev/null
+++ b/sysconfig/network-scripts/ifup-sl
@@ -0,0 +1,56 @@
+#!/bin/sh
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+# ifup-post can't be done for slip :-( Solution: use PPP
+
+if [ "$1" != daemon ] ; then
+ $0 daemon $*&
+ exit 0
+fi
+
+shift
+
+. $1
+
+if [ "foo$2" = "fooboot" -a ${ONBOOT} = "no" ]
+then
+ exit
+fi
+
+if [ -z "$RETRYTIMEOUT" ]; then
+ RETRYTIMEOUT=30
+fi
+
+[ -x /usr/sbin/dip ] || {
+ echo "/usr/sbin/dip does not exist or is not executable"
+ echo "ifup-sl for $DEVICE exiting"
+ logger -p daemon.info -t ifup-sl \
+ "/usr/sbin/dip does not exist or is not executable for $DEVICE"
+ exit 1
+}
+
+[ -f /etc/sysconfig/network-scripts/dip-$DEVICE ] || {
+ echo "/etc/sysconfig/network-scripts/dip-$DEVICE does not exist"
+ echo "ifup-sl for $DEVICE exiting"
+ logger -p daemon.info -t ifup-sl \
+ "/etc/sysconfig/network-scripts/dip-$DEVICE does not exist for $DEVICE"
+ exit 1
+}
+
+while : ; do
+ echo > /var/run/sl-$DEVICE.dev
+ (logger -p daemon.info -t ifup-sl \
+ "dip started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
+ doexec /usr/sbin/dip dip-$DEVICE /etc/sysconfig/network-scripts/dip-$DEVICE
+ if [ "$PERSIST" != "yes" -o ! -f /var/run/sl-$DEVICE.dev ] ; then
+ exit 0
+ fi
+ rm -f /var/run/sl-$DEVICE.dev
+
+
+ sleep $RETRYTIMEOUT || {
+ # sleep was killed
+ exit 0
+ }
+done
+