diff options
author | ncopa <ncopa@f176ef85-8d20-0410-844a-e957b5a1c371> | 2006-10-24 12:26:42 +0000 |
---|---|---|
committer | ncopa <ncopa@f176ef85-8d20-0410-844a-e957b5a1c371> | 2006-10-24 12:26:42 +0000 |
commit | c8b95b81b69af4a0f90340f5874dcfe6ff057a9d (patch) | |
tree | 94bc4f11d8c3466b02d5aee235ff15c4fed3c50f | |
download | alpine-baselayout-c8b95b81b69af4a0f90340f5874dcfe6ff057a9d.tar.bz2 alpine-baselayout-c8b95b81b69af4a0f90340f5874dcfe6ff057a9d.tar.xz |
initial import based on 1.0.1
-rw-r--r-- | Makefile | 92 | ||||
-rw-r--r-- | TZ | 1 | ||||
-rw-r--r-- | conf.d/bridge | 5 | ||||
-rw-r--r-- | conf.d/cron | 3 | ||||
-rw-r--r-- | conf.d/localinit | 3 | ||||
-rw-r--r-- | conf.d/tuntap | 3 | ||||
-rw-r--r-- | conf.d/watchdog | 3 | ||||
-rw-r--r-- | crontab | 8 | ||||
-rw-r--r-- | default.script | 41 | ||||
-rw-r--r-- | fstab | 9 | ||||
-rw-r--r-- | functions.sh | 96 | ||||
-rw-r--r-- | group | 49 | ||||
-rw-r--r-- | hosts | 1 | ||||
-rw-r--r-- | ide_links | 23 | ||||
-rw-r--r-- | init.d/Makefile | 40 | ||||
-rwxr-xr-x | init.d/alpinecfg.sh | 44 | ||||
-rwxr-xr-x | init.d/bootmisc.sh | 7 | ||||
-rwxr-xr-x | init.d/bridge | 38 | ||||
-rwxr-xr-x | init.d/checkroot.sh | 46 | ||||
-rwxr-xr-x | init.d/coldplug | 66 | ||||
-rwxr-xr-x | init.d/cron | 13 | ||||
-rwxr-xr-x | init.d/hostname | 9 | ||||
-rwxr-xr-x | init.d/hwclock | 9 | ||||
-rwxr-xr-x | init.d/hwdrivers | 48 | ||||
-rwxr-xr-x | init.d/inetd | 13 | ||||
-rwxr-xr-x | init.d/localinit | 31 | ||||
-rwxr-xr-x | init.d/mdev | 37 | ||||
-rwxr-xr-x | init.d/modutils | 21 | ||||
-rw-r--r-- | init.d/mountall | 8 | ||||
-rwxr-xr-x | init.d/networking | 23 | ||||
-rwxr-xr-x | init.d/procps | 10 | ||||
-rwxr-xr-x | init.d/rcK | 10 | ||||
-rwxr-xr-x | init.d/rcL | 16 | ||||
-rwxr-xr-x | init.d/rcS | 59 | ||||
-rwxr-xr-x | init.d/runtimes | 109 | ||||
-rwxr-xr-x | init.d/syslog | 13 | ||||
-rwxr-xr-x | init.d/tuntap | 46 | ||||
-rwxr-xr-x | init.d/udev | 32 | ||||
-rwxr-xr-x | init.d/udevqueue | 11 | ||||
-rw-r--r-- | init.d/udhcpc | 50 | ||||
-rwxr-xr-x | init.d/watchdog | 14 | ||||
-rw-r--r-- | inittab | 22 | ||||
-rw-r--r-- | issue | 3 | ||||
-rw-r--r-- | mdev.conf | 83 | ||||
-rw-r--r-- | nsswitch.conf | 4 | ||||
-rw-r--r-- | passwd | 42 | ||||
-rw-r--r-- | profile | 2 | ||||
-rw-r--r-- | protocols | 45 | ||||
-rw-r--r-- | rc-services.sh | 26 | ||||
-rwxr-xr-x | rc_add | 78 | ||||
-rwxr-xr-x | rc_delete | 68 | ||||
-rwxr-xr-x | rc_status | 57 | ||||
-rwxr-xr-x | runscript-alpine.sh | 85 | ||||
-rw-r--r-- | sd_links | 78 | ||||
-rw-r--r-- | services | 969 | ||||
-rw-r--r-- | shadow | 42 | ||||
-rw-r--r-- | shells | 7 | ||||
-rw-r--r-- | src/Makefile | 30 | ||||
-rw-r--r-- | src/headers.h | 26 | ||||
-rw-r--r-- | src/runscript.c | 25 | ||||
-rw-r--r-- | src/splashbard.c | 215 | ||||
-rw-r--r-- | src/start-stop-daemon.c | 1375 | ||||
-rw-r--r-- | subdir_dev | 12 | ||||
-rw-r--r-- | sysctl.conf | 6 | ||||
-rwxr-xr-x | usbdev | 17 |
65 files changed, 4477 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0040f89 --- /dev/null +++ b/Makefile @@ -0,0 +1,92 @@ +VERSION=1.0.1 +PV = alpine-baselayout-$(VERSION) +TARBALL = $(PV).tar.gz + +SUBDIRS = src init.d + +GENERATED_FILES = TZ hosts profile +ETC_FILES = $(GENERATED_FILES) group fstab inittab nsswitch.conf passwd protocols services shadow shells issue mdev.conf crontab sysctl.conf +CONFD_FILES = $(addprefix conf.d/, bridge cron localinit tuntap watchdog) +SBIN_FILES = runscript-alpine.sh functions.sh rc_add rc_delete rc_status +RC_SH_FILES = rc-services.sh +UDHCPC_FILES = default.script +LIB_MDEV_FILES = ide_links sd_links subdir_dev usbdev +CRONTABS = crontab +DISTFILES = $(ETC_FILES) $(SBIN_FILES) $(UDHCPC_FILES) $(RC_SH_FILES) $(LIB_MDEV_FILES) Makefile + +all: $(GENERATED_FILES) + for i in $(SUBDIRS) ; do \ + cd $$i && make && cd .. ; \ + done + +clean: + for i in $(SUBDIRS) ; do \ + cd $$i && make clean && cd .. ; \ + done + rm -f $(TARBALL) $(GENERATED_FILES) *~ + +TZ: + echo "UTC" > TZ + +hostname: + echo localhost > hostname + +hosts: + echo -e "127.0.0.1\tlocalhost" > hosts + +profile: + echo "export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin" > profile + echo "umask 022" >> profile + +shadow: passwd + @lastchange=$$(( `date +%s` / ( 24 * 3600 ) ));\ + awk -F: ' { \ + pw = ":!:";\ + if ($$1 == "root") { pw = "::" };\ + print $$1 pw "'"$$lastchange"':0:::::" \ + }' passwd > $@ + +# ":" $$pw ":"'"$$lastchange"'":0:::::" +install: + install -m 0755 -d $(addprefix $(DESTDIR)/, etc sbin) \ + $(DESTDIR)/etc/conf.d \ + $(DESTDIR)/etc/crontabs \ + $(DESTDIR)/lib/rcscripts/sh \ + $(DESTDIR)/usr/share/udhcpc \ + $(DESTDIR)/lib/mdev \ + $(DESTDIR)/var/spool/cron \ + $(DESTDIR)/etc/periodic/15min \ + $(DESTDIR)/etc/periodic/hourly \ + $(DESTDIR)/etc/periodic/daily \ + $(DESTDIR)/etc/periodic/weekly \ + $(DESTDIR)/etc/periodic/monthly + for i in $(SUBDIRS) ; do \ + cd $$i && make install && cd .. ;\ + done + install -m 0644 $(ETC_FILES) $(DESTDIR)/etc + chmod 600 $(DESTDIR)/etc/shadow + install -m 0644 $(CONFD_FILES) $(DESTDIR)/etc/conf.d + install -m 0755 $(SBIN_FILES) $(DESTDIR)/sbin + install -m 0755 $(UDHCPC_FILES) $(DESTDIR)/usr/share/udhcpc + install -m 0755 $(RC_SH_FILES) $(DESTDIR)/lib/rcscripts/sh + install -m 0755 $(LIB_MDEV_FILES) $(DESTDIR)/lib/mdev + mv $(DESTDIR)/etc/crontab $(DESTDIR)/etc/crontabs/root + ln -s /etc/crontabs $(DESTDIR)/var/spool/cron/crontabs + +$(TARBALL): $(DISTFILES) $(SUBDIRS) + rm -rf $(PV) + mkdir $(PV) + for i in $(SUBDIRS) ; do \ + cd $$i && make clean && cd .. ; \ + done + cp $(DISTFILES) $(PV) + mkdir $(PV)/conf.d + cp $(CONFD_FILES) $(PV)/conf.d/ + rsync -Cr $(SUBDIRS) $(PV) + tar --exclude=.svn -czf $@ $(PV) + rm -r $(PV) + +dist: $(TARBALL) + + +.PHONY: install clean all @@ -0,0 +1 @@ +UTC diff --git a/conf.d/bridge b/conf.d/bridge new file mode 100644 index 0000000..6f3c5c3 --- /dev/null +++ b/conf.d/bridge @@ -0,0 +1,5 @@ +# Specify bridges here, separated with spaces. +# a every bridge is specified as: +# bridgename=interface1+interface2[+...] + +#BRIDGES="br0=eth0+tap0 br1=eth1+eth2" diff --git a/conf.d/cron b/conf.d/cron new file mode 100644 index 0000000..2f2eb7b --- /dev/null +++ b/conf.d/cron @@ -0,0 +1,3 @@ +# enter the cron options +CRON_OPTS="-c /etc/crontabs" + diff --git a/conf.d/localinit b/conf.d/localinit new file mode 100644 index 0000000..5cf879b --- /dev/null +++ b/conf.d/localinit @@ -0,0 +1,3 @@ +# look only for localinit in those dirs. +# set to "" to disable localinit +MOUNTS="usb floppy cdrom" diff --git a/conf.d/tuntap b/conf.d/tuntap new file mode 100644 index 0000000..8491396 --- /dev/null +++ b/conf.d/tuntap @@ -0,0 +1,3 @@ +# Specify all tap devices +#DEVICES="tap0 tap1" + diff --git a/conf.d/watchdog b/conf.d/watchdog new file mode 100644 index 0000000..5cfd2c2 --- /dev/null +++ b/conf.d/watchdog @@ -0,0 +1,3 @@ +#WATCHDOG_OPTS="-t 30" +WATCHDOG_DEV="" + @@ -0,0 +1,8 @@ +# do daily/weekly/monthly maintenance +# min hour day month weekday command +*/4 * * * * run-parts /etc/periodic/15min +0 * * * * run-parts /etc/periodic/hourly +0 2 * * * run-parts /etc/periodic/daily +0 3 * * 6 run-parts /etc/periodic/weekly +0 5 1 * * run-parts /etc/periodic/monthly + diff --git a/default.script b/default.script new file mode 100644 index 0000000..166b40d --- /dev/null +++ b/default.script @@ -0,0 +1,41 @@ +#!/bin/sh + +# udhcpc script edited by Tim Riker <Tim@Rikers.org> + +[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 + +RESOLV_CONF="/etc/resolv.conf" +[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" +[ -n "$subnet" ] && NETMASK="netmask $subnet" + +case "$1" in + deconfig) + /sbin/ifconfig $interface 0.0.0.0 + ;; + + renew|bound) + /sbin/ifconfig $interface $ip $BROADCAST $NETMASK + + if [ -n "$router" ] ; then + echo "deleting routers" + while route del default gw 0.0.0.0 dev $interface ; do + : + done + + metric=0 + for i in $router ; do + route add default gw $i dev $interface metric $metric + metric=$(( $metric + 1 )) + done + fi + + echo -n > $RESOLV_CONF + [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF + for i in $dns ; do + echo adding dns $i + echo nameserver $i >> $RESOLV_CONF + done + ;; +esac + +exit 0 @@ -0,0 +1,9 @@ +none /proc proc defaults 0 0 +none /sys sysfs defaults 0 0 +mdev /dev tmpfs size=100k 0 0 +none /dev/pts devpts defaults 0 0 +tmpfs /dev/shm tmpfs defaults 0 0 +/dev/cdrom /media/cdrom iso9660 ro 0 0 +/dev/fd0 /media/floppy vfat noauto 0 0 +/dev/usba1 /media/usb vfat noauto 0 0 +none /proc/bus/usb usbfs noauto 0 0 diff --git a/functions.sh b/functions.sh new file mode 100644 index 0000000..90f7b5e --- /dev/null +++ b/functions.sh @@ -0,0 +1,96 @@ + +RC_GOT_FUNCTIONS="yes" + +# load user settings +[ -r /etc/conf.d/rc ] && . /etc/conf.d/rc + + + +svclib="/lib/rcscripts" +svcdir="${svcdir:-/var/lib/init.d}" + +# void import_addon(char *Addon) +import_addon() { + local addon="$svclib/addons/$1" + [ -r "$addon" ] && . "$addon" +} + +echon () { + if [ -z "$ECHON" ]; then + # Determine how to "echo" without newline: "echo -n" + # or "echo ...\c" + if [ "X`echo -n`" = "X-n" ]; then + ECHON=echo + NNL="\c" + # " + else + ECHON="echo -n" + NNL="" + fi + fi + $ECHON "$*$NNL" +} + + +eerror() { + echo $* >&2 +} + +einfo() { + echo $* >&2 +} + +einfon() { + echon $* >&2 +} + +ewarn() { + echo $* >&2 +} + +ebegin() { + echon " * $*: " +} + +eend() { + local msg + if [ "$1" = 0 ] || [ $# -lt 1 ] ; then + msg="ok." + else + shift + msg=" failed. $*" + fi + echo "$msg" +} + +eindent() { + true +} + +start_addon() { + (import_addon "$1-start.sh") + return 0 +} + +stop_addon() { + (import_addon "$1-stop.sh") + return 0 +} + +save_options() { + local myopts="$1" + mkdir -p -m 0755 "$svcdir/options/$SVCNAME" + shift + echo "$*" > "$svcdir/options/$SVCNAME/$myopts" +} + +get_options() { + local svc="$SVCNAME" + [ "$2" ] && svc="$2" + cat "$svcdir/options/$svc/$1" 2>/dev/null +} + +die() { + eerror "$1" + exit 1 +} @@ -0,0 +1,49 @@ +root:x:0:root +bin:x:1:root,bin,daemon +daemon:x:2:root,bin,daemon +sys:x:3:root,bin,adm +adm:x:4:root,adm,daemon +tty:x:5: +disk:x:6:root,adm +lp:x:7:lp +mem:x:8: +kmem:x:9: +wheel:x:10:root +floppy:x:11:root +mail:x:12:mail +news:x:13:news +uucp:x:14:uucp +man:x:15:man +cron:x:16:cron +console:x:17: +audio:x:18: +cdrom:x:19: +dialout:x:20:root +ftp:x:21: +sshd:x:22: +at:x:25:at +tape:x:26:root +video:x:27:root +squid:x:31:squid +gdm:x:32:gdm +xfs:x:33:xfs +games:x:35: +named:x:40:named +mysql:x:60: +postgres:x:70: +cdrw:x:80: +apache:x:81: +nut:x:84: +usb:x:85: +vpopmail:x:89: +users:x:100:games +nofiles:x:200: +qmail:x:201: +postfix:x:207: +postdrop:x:208: +smmsp:x:209:smmsp +slocate:x:245: +portage:x:250:portage +utmp:x:406: +nogroup:x:65533: +nobody:x:65534: @@ -0,0 +1 @@ +127.0.0.1 localhost diff --git a/ide_links b/ide_links new file mode 100644 index 0000000..be0c95a --- /dev/null +++ b/ide_links @@ -0,0 +1,23 @@ +#!/bin/sh + +[ -f /proc/ide/$MDEV/media ] || exit + +media=`cat /proc/ide/$MDEV/media` +for i in $media $media[0-9]* ; do + if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then + LINK=$i + break + fi +done + +# link exist, remove if necessary and exit +if [ "$LINK" ] ; then + [ "$ACTION" = remove ] && rm $LINK + exit +fi + +# create a link +num=`ls $media[0-9]* 2>/dev/null | wc -l` +ln -sf $MDEV "$media`echo $num`" +[ -e "$media" ] || ln -sf $MDEV "$media" + diff --git a/init.d/Makefile b/init.d/Makefile new file mode 100644 index 0000000..954d2b0 --- /dev/null +++ b/init.d/Makefile @@ -0,0 +1,40 @@ +SCRIPTS = alpinecfg.sh \ + bootmisc.sh \ + bridge \ + checkroot.sh \ + coldplug \ + cron \ + hostname \ + hwclock \ + hwdrivers \ + inetd \ + localinit \ + mdev \ + modutils \ + mountall \ + networking \ + procps \ + rcK \ + rcL \ + rcS \ + runtimes \ + syslog \ + tuntap \ + udev \ + udhcpc \ + watchdog + +all: + +install: $(SCRIPTS) + install -m 0755 -d $(DESTDIR)/etc + install -m 0755 -d $(DESTDIR)/etc/init.d + + for i in $(SCRIPTS) ; do \ + install -m 755 -D $$i $(DESTDIR)/etc/init.d/$$i ;\ + done + +clean: + rm -f *~ + +.PHONY: all clean diff --git a/init.d/alpinecfg.sh b/init.d/alpinecfg.sh new file mode 100755 index 0000000..180b6e8 --- /dev/null +++ b/init.d/alpinecfg.sh @@ -0,0 +1,44 @@ +#!/bin/busybox sh + +# the purpose of this script is to find and import the alpine config. +# load it or set default values. + +#depracated +echo "remeber to remove this $0 file..." +exit + +get_boot_var () { + # Look for CFG_MEDIA in cmdline + for i in `cat /proc/cmdline` ; do +# if echo $i | grep $ > /dev/null ; then +# echo $i | sed 's/'$1'=//' +# fi + case $i in + $1=*) echo $i | sed 's|'$1'=||' ;; + esac + done +} + + +import_config() { + if mount $1 ; then + echo "Using Alpine config from $1" + cp $1/$2 /etc/alpine.conf + sleep 1 + umount $1 + fi +} + +CFG="alpine.conf" +CFG_MEDIA=`get_boot_var cfg_media` +#if [ -z "$CFG_MEDIA" ] ; then + # cfg_media was not set in cmdline. We use the defaults... + echo "looking for alpine.conf on default locations" + for i in /media/* ; do + import_config $i $CFG + done +#else + # Only import for specified location +# import_config "/media/$CFG_MEDIA" $CFG +#fi + diff --git a/init.d/bootmisc.sh b/init.d/bootmisc.sh new file mode 100755 index 0000000..846f236 --- /dev/null +++ b/init.d/bootmisc.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# +# Save kernel messages in /var/log/dmesg +# +dmesg -s 65536 > /var/log/dmesg + diff --git a/init.d/bridge b/init.d/bridge new file mode 100755 index 0000000..bfbf057 --- /dev/null +++ b/init.d/bridge @@ -0,0 +1,38 @@ +#!/sbin/runscript + +BRCTL=`which brctl 2>/dev/null` + +start() { + # abort if brctl does not exist + for brspec in $BRIDGES; do + retcode=0 + br=`echo $brspec | cut -d= -f1` + ebegin "Setting up bridge $br" + if [ -z "$BRCTL" ] ; then + eerror "Need bridge-utils to be able to set up $br" + retcode=1 + else + brctl addbr $br || retcode=1 + bridge_ifs=`echo "$BRIDGES" | sed 's/.*=//; s/\+/ /g'` + for iface in $bridge_ifs ; do + # set if in promisc mode + ifconfig $iface 0.0.0.0 promisc up || retcode=1 + brctl addif $br $iface || retcode=1 + done + fi + eend $retcode + done + +} + +stop() { + which brctl > /dev/null 2>&1 || return 1 + for brspec in $BRIDGES; do + br=`echo $brspec | cut -d= -f1` + ebegin "Shutting down bridge $br" + brctl delbr $br + eend $? + done + + +} diff --git a/init.d/checkroot.sh b/init.d/checkroot.sh new file mode 100755 index 0000000..94fc7ff --- /dev/null +++ b/init.d/checkroot.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +rootmode=rw +rootopts=rw +rootcheck=yes +udevfs= + +# read the fstab +sed 's/#.*//' /etc/fstab | while read fs mnt type opts dump pass junk +do + [ "$type" = udevfs ] && udefs="$fs" + [ "$mnt" != / ] && continue + rootopts="$opts" + [ "$pass" = 0 -o "$pass" = "" ] && rootcheck=no + case "$opts" in + ro|ro,*|*,ro|*,ro,*) + rootmode=ro + ;; + esac +done + +if [ "$rootcheck" = yes ] ; then + if grep "^$fs" /proc/mounts ; then + echo "$fs is mounted. Something is wrong. Please fix and reboot." + echo "sorry newbies..." + echo + echo "CONTROL-D will exit from this shell and reboot the system." + echo + /sbin/sulogin $CONSOLE + reboot -f + elif ! fsck -C "$fs" ; then + echo "fsck failed. Please repair manually and reboot. Please note" + echo "that the root file system is currently mounted read-only. To" + echo "remount it read-write:" + echo + echo " # mount -n -o remount,rw /" + echo + echo "CONTROL-D will exit from this shell and REBOOT the system." + echo + /sbin/sulogin $CONSOLE + reboot -f + fi +fi + +mount -o remount,$rootmode / + diff --git a/init.d/coldplug b/init.d/coldplug new file mode 100755 index 0000000..a39f39f --- /dev/null +++ b/init.d/coldplug @@ -0,0 +1,66 @@ +#!/sbin/runscript + +trigger_uevents() { + local i + for i in /sys/bus/*/devices/*/uevent\ + /sys/class/*/*/uevent\ + /sys/block/*/uevent\ + /sys/block/*/*/uevent ; do + case "$i" in + */device/uevent) + continue + ;; + */class/mem/*|*/class/tty/*) + echo add > "$i" + ;; + */block/md*|*/block/dm-*) + last="$last $i" + ;; + */*) + default="$default $i" + ;; + esac + done + for i in $default $last ; do + echo add > "$i" + done +} + +# coldplug devices +start() { + unset NOCOLDPLUG + # check for boot option "nocoldplug" + for i in `cat /proc/cmdline`; do + [ "$i" = "nocoldplug" ] && NOCOLDPLUG=true + done + + if [ "$NOCOLDPLUG" ]; then + ebegin "Skipping coldplugging" + eend 0 + return + fi + +# for rc in /etc/hotplug/*.rc ; do +# name=`basename $rc .rc` +# ebegin "Coldplugging $name devices" +# $rc start 2>/tmp/coldplug.err +# eend 0 +# done + ebegin "Coldplugging devices" +# while [ -d /dev/.udev/queue ] ; do +# sleep 1 +# echo -n "." +# done +# trigger_uevents +# sleep 1 +# while [ -d /dev/.udev/queue ] ; do +# sleep 1 +# echo -n "." +# done + find /sys -name modalias | while read a ; do + modprobe `cat $a` 2>/dev/null || echo $a >> /tmp/failed + done + eend 0 +} + + diff --git a/init.d/cron b/init.d/cron new file mode 100755 index 0000000..280035e --- /dev/null +++ b/init.d/cron @@ -0,0 +1,13 @@ +#!/sbin/runscript + +start() { + ebegin "Starting cron" + crond $CRON_OPTS + eend $? +} + +stop () { + ebegin "Stopping cron" + killall crond + eend $? +} diff --git a/init.d/hostname b/init.d/hostname new file mode 100755 index 0000000..5ce489c --- /dev/null +++ b/init.d/hostname @@ -0,0 +1,9 @@ +#!/sbin/runscript + +start() { + if [ -f /etc/hostname ] ; then + ebegin "Setting hostname" + hostname -F /etc/hostname + eend $? + fi +} diff --git a/init.d/hwclock b/init.d/hwclock new file mode 100755 index 0000000..c488c43 --- /dev/null +++ b/init.d/hwclock @@ -0,0 +1,9 @@ +#!/sbin/runscript + +start() { + ebegin "Setting system time from hardware clock" + modprobe rtc 2>/dev/null + #set the system time from hardware clock + /sbin/hwclock -s -u + eend $? +} diff --git a/init.d/hwdrivers b/init.d/hwdrivers new file mode 100755 index 0000000..de0e34a --- /dev/null +++ b/init.d/hwdrivers @@ -0,0 +1,48 @@ +#!/sbin/runscript + +SEC=`date +%s` + +# echo a . every second +timer_dots() { + local newsec=`date +%s` + if [ "$SEC" != "$newsec" ] ; then + echo -n '.' + SEC=$newsec + fi +} + +# Load hardware drivers +start() { + # check for boot option "nocoldplug" + for i in `cat /proc/cmdline`; do + case $i in + modules=*) + MODULES="`echo ${i#modules=} | tr ',' ' '`";; + noautodetect) + AUTODETECT=no;; + esac + + done + + if [ "$MODULES" ] || [ "$AUTODETECT" != no ] ; then + ebegin "Loading hardware drivers" + else + ebegin "Skipping hardware drivers" + eend + return + fi + + [ "$MODULES" ] && modprobe $MODULES 2> /dev/null + timer_dots + + if [ "$AUTODETECT" != no ] ; then + find /sys -name modalias | while read a ; do + modprobe `cat $a` 2>/dev/null || \ + echo $a >> /tmp/hwdrivers.failed + timer_dots + done + fi + eend 0 +} + + diff --git a/init.d/inetd b/init.d/inetd new file mode 100755 index 0000000..eb2439f --- /dev/null +++ b/init.d/inetd @@ -0,0 +1,13 @@ +#!/sbin/runscript + +start() { + ebegin "Starting inetd" + inetd $INETD_OPTS + eend $? +} + +stop () { + ebegin "Stopping inetd" + killall inetd + eend $? +} diff --git a/init.d/localinit b/init.d/localinit new file mode 100755 index 0000000..030a0fc --- /dev/null +++ b/init.d/localinit @@ -0,0 +1,31 @@ +#!/sbin/runscript + +mount_once() { + if mount | grep $1 >/dev/null 2>&1 ; then + NOUMOUNT=$1 + else + mount $1 >/dev/null 2>&1 + fi +} + +umount_once() { + [ "$NOUMOUNT" != "$1" ] && umount "$1" 2>/dev/null +} + +start() { + for media in $MOUNTS ; do + m="/media/$media" + mount_once $m + if [ -e $m/localinit ] ; then + ebegin "Running localinit from $media" + $m/localinit + retcode=$? + umount_once $m + eend $retcode + exit + fi + sleep 1 + umount_once $m + done +} + diff --git a/init.d/mdev b/init.d/mdev new file mode 100755 index 0000000..c474175 --- /dev/null +++ b/init.d/mdev @@ -0,0 +1,37 @@ +#!/sbin/runscript + +start() { + # check if udev is specified on cmd line + for i in `cat /proc/cmdline`; do + [ "$i" = "udev" ] && return 0 + done + + ebegin "Starting mdev" + mkdir -p /dev + + # start mdev + mount /dev + mknod -m 666 /dev/null c 1 3 + + # use mdev for hotplug + echo "/sbin/mdev" > /proc/sys/kernel/hotplug + + # create devices + mdev -s + RC=$? + + # create pts file system + [ -d /dev/pts ] || mkdir -m 755 /dev/pts + [ -c /dev/ptmx ] || mknod -m 666 /dev/ptmx c 5 2 + mount /dev/pts + [ -d /dev/shm ] || mkdir /dev/shm + mount /dev/shm + eend $RC +} + +stop() { + ebegin "Stopping mdev" + echo "" > /proc/sys/kernel/hotplug + umount /dev/pts && umount /dev/shm && umount /dev + eend +} diff --git a/init.d/modutils b/init.d/modutils new file mode 100755 index 0000000..0a6c8c5 --- /dev/null +++ b/init.d/modutils @@ -0,0 +1,21 @@ +#!/sbin/runscript + +PATH="/sbin:/bin:/usr/bin:/usr/bin" + +start() { +#[ -e /sbin/depmod ] || exit 0 +#echo -n "Calculating module dependencies... " +#depmod -a > /dev/null +#echo "done." + + if [ -f /etc/modules ] ; then + sed 's/\#.*//g' < /etc/modules | + while read module args + do + ebegin "Loading $module" + modprobe -q $module $args + eend $? + done + fi +} + diff --git a/init.d/mountall b/init.d/mountall new file mode 100644 index 0000000..8d0f306 --- /dev/null +++ b/init.d/mountall @@ -0,0 +1,8 @@ +#!/sbin/runscript + +start() { + ebegin "Mounting local filesystems" + mount -a -t nonfs,nonfs4,nosmbfs,nocifs,noncp,noncpfs,nocoda,noocfs2,nogfs 2>&1 >/tmp/mountdebug + eend $? +} + diff --git a/init.d/networking b/init.d/networking new file mode 100755 index 0000000..b23a0bc --- /dev/null +++ b/init.d/networking @@ -0,0 +1,23 @@ +#!/sbin/runscript + +# note that the spoofprotect, syncoockies and ip_forward options are set in +# /etc/sysctl.conf + +start() { + ebegin "Configuring network interfaces" + ifup -a + eend $? +} + +stop() { + ebegin "Deconfiguring network interfaces" + ifdown -a + eend $? +} + +restart() { + ebegin "Reconfiguring network interfaces" + ifdown -a && ifup -a + eend $? +} + diff --git a/init.d/procps b/init.d/procps new file mode 100755 index 0000000..0a8bd8f --- /dev/null +++ b/init.d/procps @@ -0,0 +1,10 @@ +#!/sbin/runscript + +start() { + if [ -r /etc/sysctl.conf ] ; then + ebegin "Setting kernel variables" + /sbin/sysctl -p /etc/sysctl.conf >/dev/null + eend $? + fi +} + diff --git a/init.d/rcK b/init.d/rcK new file mode 100755 index 0000000..5a22f41 --- /dev/null +++ b/init.d/rcK @@ -0,0 +1,10 @@ +#!/bin/sh + +export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin + +echo "" +for i in `for j in /etc/rcK.d/K* ; do echo $j ; done | sort -r` ; do + [ -f $i ] && $i stop +done +exit 0 + diff --git a/init.d/rcL b/init.d/rcL new file mode 100755 index 0000000..7c6b3f7 --- /dev/null +++ b/init.d/rcL @@ -0,0 +1,16 @@ +#!/bin/busybox sh + +export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin + +for i in `seq 0 9` ; do + # first stopp all the K?? scripts in this level + for j in /etc/rcL.d/K$i[0-9]* ; do + [ -f $j ] && $j stop + done + # start all S?? scripts in this level + for j in /etc/rcL.d/S$i[0-9]* ; do + [ -f $j ] && $j start + done +done +exit 0 + diff --git a/init.d/rcS b/init.d/rcS new file mode 100755 index 0000000..017d105 --- /dev/null +++ b/init.d/rcS @@ -0,0 +1,59 @@ +#!/bin/busybox sh + +# we need the proc to be able to install busybox +/bin/busybox mkdir -p /proc /usr/sbin /sys +/bin/busybox mount -t proc proc /proc +/bin/busybox mount -t sysfs none /sys + +# install busybox links +/bin/busybox --install -s + +[ -f /etc/alpine-release ] && read RELEASE BUILD < /etc/alpine-release +echo "Starting $RELEASE" + +export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin + +# use dash if it exists +[ -x /bin/dash ] && ln -sf /bin/dash /bin/sh + +# define some default variables +export DEFAULT_CFG_MOUNTS="/media/cdrom /media/floppy /media/usb" +export DEFAULT_ALPINE_CONF="/alpine.conf" +export DEFAULT_ALPINE_PACKAGES="/packages.conf" +export DEFAULT_PKG_PATH="cdrom://apks" + +# start an rc script. Look if there are a no<service> in /proc/cmdline +start_script() { + local n + if [ -f $1 ] ; then + for n in `cat /proc/cmdline`; do + [ "$n" = "s" ] && SINGLEMODE=yes + case $1 in + S??no$n) return 1;; + esac + done + case $1 in + *.sh) . $1 start;; + *) $1 start;; + esac + fi +} + +# hide kernel messages +dmesg -n 1 + +for i in `cat /proc/cmdline` ;do + case $i in + 1|s|single) + echo "Entering single mode. Type 'exit' to continue booting." + sh + ;; + esac +done + +# Run all /etc/rcS.d scripts +for j in /etc/rcS.d/S* ; do + start_script $j +done +exit 0 + diff --git a/init.d/runtimes b/init.d/runtimes new file mode 100755 index 0000000..41d0a0e --- /dev/null +++ b/init.d/runtimes @@ -0,0 +1,109 @@ +#!/sbin/runscript + +# The purpose of this script is to load the Alpine runtime modules and the +# local config that belongs to. + +SFIC=`which sfic 2>/dev/null` +COMMITED_TDB=/var/lib/apk/commited.tdb + +# search for a kernel argument +get_karg () { + for i in `cat /proc/cmdline` ; do + case $i in + $1=*) echo $i | sed 's|'$1'=||' ;; + esac + done +} + +get_pkg_list() { + # we skip lines that start with '#' + grep -v '^#' $1 | while read pkg ; do + for i in $pkg ; do + echo -n "$pkg " + done + done +} + +# load packages from mounted media +load_pkgs_and_config() { + # params: + # $1 = path to mounted media + # $2 = + local apk_list mnt ovl allpkgs pkg + mnt=$1 + apk_list="$mnt/packages.list" + if [ -f "$apk_list" ] ; then + echo " + Loading packages from $apk_list:" + apk_fetch -u -q + for pkg in `get_pkg_list $apk_list` ; do + apk_add -q $pkg + echo " $pkg" + done + fi + cd / + # look for apk overlays. + for ovl in $mnt/*.apkovl.tar.gz ; do + if [ -f $ovl ] ; then + # remember to remove leading / + ovllist=`tar -C / -zvxf $ovl | sed 's:^/::'` + if [ "$ovllist" ] ; then + echo " Reading overlay: $ovl" + lbu update $ovllist 2>/dev/null + fi + fi + done +} + +mount_once() { + if grep $1 < /proc/mounts >/dev/null 2>&1 ; then + NOUMOUNT=$1 + else + mount $1 >/dev/null 2>&1 + fi +} + +umount_once() { + [ "$NOUMOUNT" != "$1" ] && umount "$1" 2>/dev/null +} + +start() { + ebegin "Searching for local configurations" + # just in case... + modprobe usb-storage 2>/dev/null + modprobe sd_mod 2>/dev/null + modprobe floppy 2>/dev/null + modprobe cdrom 2>/dev/null + + # if pkg_path is not specified as kernel arg, look for the packages + # on mounted cdrom + APK_PATH=`get_karg pkg_path` + + # read configs if available + [ -f /etc/apk.conf ] && . /etc/apk.conf + + [ -z "$APK_PATH" ] && APK_PATH="cdrom://apks" + export APK_PATH + + # APK_CFG_MOUNTS + # if set, will only try to mount those, other wise try everything + # in /media/* + if [ "$APK_CFG_MOUNTS" ] ; then + mounts="$APK_CFG_MOUNTS" + else + mounts="*" + fi + + cd /media + for m in $mounts ; do + mount_once /media/$m + load_pkgs_and_config /media/$m + sleep 1 + umount_once /media/$m + done + eend + + # if there are no /etc/apk.conf, create one + [ -f /etc/apk.conf ] || echo "APK_PATH=$APK_PATH" > /etc/apk.conf +} + diff --git a/init.d/syslog b/init.d/syslog new file mode 100755 index 0000000..f60a981 --- /dev/null +++ b/init.d/syslog @@ -0,0 +1,13 @@ +#!/sbin/runscript + +start() { + ebegin "Starting system logging" + syslogd && klogd + eend $? +} + +stop () { + ebegin "Stopping system logging" + killall klogd && killall syslogd + eend $? +} diff --git a/init.d/tuntap b/init.d/tuntap new file mode 100755 index 0000000..667acb9 --- /dev/null +++ b/init.d/tuntap @@ -0,0 +1,46 @@ +#!/sbin/runscript + +OPENVPN=`which openvpn 2>/dev/null` +TUNCTL=`which tunctl 2>/dev/null` + +if [ -x "$OPENVPN" ] ; then + CREATETAP="$OPENVPN --mktun --dev" +else + CREATETAP="$TUNCTL -t" +fi + + +start() { + # verify tun/tap support in kernel + if ! [ -e /dev/net/tun ] ; then + modprobe tun 2>&1 >/dev/null && sleep 1 + if ! [ -e /dev/net/tun ] ; then + eerror "Tun/Tap support is not present in kernel" + return 1 + fi + fi + + # verify if openvpn is present + if [ -x "$OPENVPN" ] ; then + MKTUNTAP="$OPENVPN --mktun --dev" + elif [ -x "$TUNCTL" ] ; then + MKTUNTAP="$TUNCTL -t" + else + eerror "Needs openvpn or tunctl to create Tun/Tap devices" + return 1 + fi + + # create devices + for iface in $DEVICES ; do + ebegin "Creating Tun/Tap interface $iface" + $MKTUNTAP $iface >/dev/null + eend $? + done +} + +stop() { + ebegin "Destroying Tun/Tap interfaces" + rmmod tun 2>/dev/null + eend $? +} + diff --git a/init.d/udev b/init.d/udev new file mode 100755 index 0000000..0aa1287 --- /dev/null +++ b/init.d/udev @@ -0,0 +1,32 @@ +#!/sbin/runscript + +start() { + ebegin "Starting udev" + #init sysfs + mkdir -p /dev + + # use udevsend for hotplug + #echo /sbin/udevsend > /proc/sys/kernel/hotplug + echo "" > /proc/sys/kernel/hotplug + + # start udev + mount /dev + start-stop-daemon --start --quiet --exec /sbin/udevd -- --daemon + udevstart 2>/dev/tty10 + RC=$? + + # create pts file system + [ -d /dev/pts ] || mkdir -m 755 /dev/pts + [ -c /dev/ptmx ] || mknod -m 666 /dev/ptmx c 5 2 + + mount /dev/pts + eend $RC +} + +stop() { + ebegin "Stopping udev" + start-stop-daemon --stop --quiet --exec /sbin/udevd + RC=$? + umount /dev/pts && umount /dev + eend $RC +} diff --git a/init.d/udevqueue b/init.d/udevqueue new file mode 100755 index 0000000..4bf6d93 --- /dev/null +++ b/init.d/udevqueue @@ -0,0 +1,11 @@ +#!/sbin/runscript + +start() { + ebegin "Waiting on udev queue" + while [ -d /dev/.udev/queue ] ; do + sleep 1 + echo -n "." + done + eend 0 +} + diff --git a/init.d/udhcpc b/init.d/udhcpc new file mode 100644 index 0000000..5b1f4e9 --- /dev/null +++ b/init.d/udhcpc @@ -0,0 +1,50 @@ +#!/bin/sh +# /etc/init.d/udhcpc: start or stop udhcpc client + +set -e + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +DAEMON=/sbin/udhcpc + +test -x $DAEMON || exit 0 + +case "$1" in + start) + echo -n "Starting DHCP client: udhcpc" + start-stop-daemon --start --quiet --exec $DAEMON \ + -- --script=/etc/udhcpc.script || echo -n " already running" + echo "." + ;; + + restart) + /etc/init.d/udhcpc stop + /etc/init.d/udhcpc start + ;; + + reload) + ;; + + force-reload) + ;; + + stop) + echo -n "Stopping DHCP client: udhcpc" + start-stop-daemon --stop --quiet --exec $DAEMON || echo -n " not running" + echo "." + ;; + + renew) + start-stop-daemon --signal USR1 --stop --quiet --exec $DAEMON || echo -n " not running" + ;; + + release) + start-stop-daemon --signal USR2 --stop --quiet --exec $DAEMON || echo -n " not running" + ;; + + *) + echo "Usage: /etc/init.d/udhcpc {start|stop|restart|reload|force-reload}" + exit 1 + ;; +esac + +exit 0 diff --git a/init.d/watchdog b/init.d/watchdog new file mode 100755 index 0000000..b4b3ae7 --- /dev/null +++ b/init.d/watchdog @@ -0,0 +1,14 @@ +#!/sbin/runscript + +start() { + [ "$WATCHDOG_DEV" ] || die "WATCHDOG_DEV is not set" + ebegin "Starting $SVCNAME" + $SVCNAME $WATCHDOG_OPTS $WATCHDOG_DEV + eend $? +} + +stop () { + ebegin "Stopping $SVCNAME" + killall $SVCNAME + eend $? +} @@ -0,0 +1,22 @@ +# /etc/inittab + +::sysinit:/etc/init.d/rcS +::wait:/etc/init.d/rcL + +# Set up a couple of getty's +tty1::respawn:/sbin/getty 38400 tty1 +tty2::respawn:/sbin/getty 38400 tty2 +tty3::respawn:/sbin/getty 38400 tty3 +tty4::respawn:/sbin/getty 38400 tty4 + +# Put a getty on the serial port +#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 + +# Stuff to do for the 3-finger salute +::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/etc/init.d/rcK +null::shutdown:/bin/umount -a -r 2>/dev/null +null::shutdown:/sbin/swapoff -a 2>/dev/null + @@ -0,0 +1,3 @@ + +This is \n. (\s \m \r) \t + diff --git a/mdev.conf b/mdev.conf new file mode 100644 index 0000000..bf2a560 --- /dev/null +++ b/mdev.conf @@ -0,0 +1,83 @@ +# +# This is a sample mdev.conf. +# + +SLEEP=10 + +# Symlinks: +# Syntax: %s -> %s +MAKEDEV -> ../sbin/MAKEDEV +/proc/core -> kcore +fd -> /proc/self/fd +mcdx -> mcdx0 +radio -> radio0 +ram -> ram1 +sbpcd -> sbpcd0 +sr0 -> scd0 +sr1 -> scd1 +sr10 -> scd10 +sr11 -> scd11 +sr12 -> scd12 +sr13 -> scd13 +sr14 -> scd14 +sr15 -> scd15 +sr16 -> scd16 +sr2 -> scd2 +sr3 -> scd3 +sr4 -> scd4 +sr5 -> scd5 +sr6 -> scd6 +sr7 -> scd7 +sr8 -> scd8 +sr9 -> scd9 +stderr -> fd/2 +stdin -> fd/0 +stdout -> fd/1 +vbi -> vbi0 +#vcs -> vcs0 +#vcsa -> vcsa0 +video -> video0 + +# Devices: +# Syntax: %s %d:%d %s +# devices user:group mode + +null root:root 777 +zero root:root 666 +grsec root:root 660 + +urandom root:root 444 + +console root:tty 0600 +fd0 root:floppy 0660 +kmem root:root 000 +mem root:root 0640 +port root:root 0640 +ptmx root:tty 0660 + +sd[a-z][0-9]* root:disk 0660 */lib/mdev/sd_links +hd[a-z][0-9]* root:disk 0660 */lib/mdev/ide_links + +md[0-9] root:disk 0660 +tty root:tty 0666 +tty[0-9] root:tty 0660 +tty[0-9][0-9] root:tty 0660 + +ttyS[0-9]* root:tty 640 +ttyLTM[0-9] root:dialout 0660 @ln -sf $MDEV modem +video.* root:video 0660 + +# alsa sound devices +pcm.* root:audio 0660 */lib/mdev/subdir_dev snd +control.* root:audio 0660 */lib/mdev/subdir_dev snd +midi.* root:audio 0660 */lib/mdev/subdir_dev snd +seq root:audio 0660 */lib/mdev/subdir_dev snd +timer root:audio 0660 */lib/mdev/subdir_dev snd + +# load drivers for usb devices +usbdev[0-9].* root:root 0660 */lib/mdev/usbdev + +# net devices +tun[0-9]* root:root 0600 */lib/mdev/subdir_dev net +tap[0-9]* root:root 0600 */lib/mdev/subdir_dev net + diff --git a/nsswitch.conf b/nsswitch.conf new file mode 100644 index 0000000..6ed388d --- /dev/null +++ b/nsswitch.conf @@ -0,0 +1,4 @@ +# Default settings for nsswitch.conf as needed for tinylogin +passwd: compat +group: compat +shadow: compat @@ -0,0 +1,42 @@ +root:x:0:0:root:/root:/bin/ash +bin:x:1:1:bin:/bin:/bin/false +daemon:x:2:2:daemon:/sbin:/bin/false +adm:x:3:4:adm:/var/adm:/bin/false +lp:x:4:7:lp:/var/spool/lpd:/bin/false +sync:x:5:0:sync:/sbin:/bin/sync +shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +halt:x:7:0:halt:/sbin:/sbin/halt +mail:x:8:12:mail:/var/spool/mail:/bin/false +news:x:9:13:news:/usr/lib/news:/bin/false +uucp:x:10:14:uucp:/var/spool/uucppublic:/bin/false +operator:x:11:0:operator:/root:/bin/bash +man:x:13:15:man:/usr/man:/bin/false +postmaster:x:14:12:postmaster:/var/spool/mail:/bin/false +cron:x:16:16:cron:/var/spool/cron:/bin/false +ftp:x:21:21::/home/ftp:/bin/false +sshd:x:22:22:sshd:/dev/null:/bin/false +at:x:25:25:at:/var/spool/cron/atjobs:/bin/false +squid:x:31:31:Squid:/var/cache/squid:/bin/false +gdm:x:32:32:GDM:/var/lib/gdm:/bin/false +xfs:x:33:33:X Font Server:/etc/X11/fs:/bin/false +games:x:35:35:games:/usr/games:/bin/false +named:x:40:40:bind:/var/bind:/bin/false +mysql:x:60:60:mysql:/var/lib/mysql:/bin/false +postgres:x:70:70::/var/lib/postgresql:/bin/bash +apache:x:81:81:apache:/home/httpd:/bin/false +nut:x:84:84:nut:/var/state/nut:/bin/false +cyrus:x:85:12::/usr/cyrus:/bin/false +vpopmail:x:89:89::/var/vpopmail:/bin/false +alias:x:200:200::/var/qmail/alias:/bin/false +qmaild:x:201:200::/var/qmail:/bin/false +qmaill:x:202:200::/var/qmail:/bin/false +qmailp:x:203:200::/var/qmail:/bin/false +qmailq:x:204:201::/var/qmail:/bin/false +qmailr:x:205:201::/var/qmail:/bin/false +qmails:x:206:201::/var/qmail:/bin/false +postfix:x:207:207:postfix:/var/spool/postfix:/bin/false +smmsp:x:209:209:smmsp:/var/spool/mqueue:/bin/false +portage:x:250:250:portage:/var/tmp/portage:/bin/false +guest:x:405:100:guest:/dev/null:/dev/null +nobody:x:65534:65534:nobody:/:/bin/false +distcc:x:240:2:distccd:/dev/null:/bin/false @@ -0,0 +1,2 @@ +export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin +umask 022 diff --git a/protocols b/protocols new file mode 100644 index 0000000..03f049d --- /dev/null +++ b/protocols @@ -0,0 +1,45 @@ +# /etc/protocols: +# $Id: protocols,v 1.1 2004/02/04 03:32:40 pebenito Exp $ +# $Header: /home/cvsroot/gentoo-projects/embedded/baselayout-lite/protocols,v 1.1 2004/02/04 03:32:40 pebenito Exp $ +# +# Internet (IP) protocols +# +# from: @(#)protocols 5.1 (Berkeley) 4/17/89 +# +# Updated for NetBSD based on RFC 1340, Assigned Numbers (July 1992). + +ip 0 IP # internet protocol, pseudo protocol number +icmp 1 ICMP # internet control message protocol +igmp 2 IGMP # Internet Group Management +ggp 3 GGP # gateway-gateway protocol +ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') +st 5 ST # ST datagram mode +tcp 6 TCP # transmission control protocol +egp 8 EGP # exterior gateway protocol +pup 12 PUP # PARC universal packet protocol +udp 17 UDP # user datagram protocol +hmp 20 HMP # host monitoring protocol +xns-idp 22 XNS-IDP # Xerox NS IDP +rdp 27 RDP # "reliable datagram" protocol +iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 +xtp 36 XTP # Xpress Tranfer Protocol +ddp 37 DDP # Datagram Delivery Protocol +idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport +ipv6 41 IPv6 # IPv6 +ipv6-route 43 IPv6-Route # Routing Header for IPv6 +ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 +idrp 45 IDRP # Inter-Domain Routing Protocol +rsvp 46 RSVP # Reservation Protocol +gre 47 GRE # General Routing Encapsulation +esp 50 ESP # Encap Security Payload for IPv6 +ah 51 AH # Authentication Header for IPv6 +skip 57 SKIP # SKIP +ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 +ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 +ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 +rspf 73 RSPF # Radio Shortest Path First. +vmtp 81 VMTP # Versatile Message Transport +ospf 89 OSPFIGP # Open Shortest Path First IGP +ipip 94 IPIP # IP-within-IP Encapsulation Protocol +encap 98 ENCAP # Yet Another IP encapsulation +pim 103 PIM # Protocol Independent Multicast diff --git a/rc-services.sh b/rc-services.sh new file mode 100644 index 0000000..4a3686d --- /dev/null +++ b/rc-services.sh @@ -0,0 +1,26 @@ + +RC_GOT_SERVICES="yes" + +[ "$RC_GOT_FUNCTIONS" ] || . /sbin/functions.sh + +# void save_options(char *option, char *optstring) +save_options() { + local myopts="$1" + + shift + if [ ! -d "${svcdir}/options/${SVCNAME}" ] ; then + mkdir -p -m 0755 "${svcdir}/options/${SVCNAME}" + fi + + echo "$*" > "${svcdir}/options/${SVCNAME}/${myopts}" +} + +# char *get_options(char *option) +get_options() { + local svc="${SVCNAME}" + [ -n $2 ] && svc="$2" + + if [ -f "${svcdir}/options/${svc}/$1" ] ; then + echo "$(< ${svcdir}/options/${svc}/$1)" + fi +} @@ -0,0 +1,78 @@ +#!/bin/sh +# +# rc_add - add an init script to a runlevel +# +# Copyright (c) 2005 Natanael Copa +# +# Distributed under GPL-2 +# + +PROGRAM=`basename $0` + +#load the libraries +. /sbin/functions.sh + +STARTNUM=50 +RCDIR="$ROOT/etc/rcL.d" + +die() { + echo "$1" >&2 + exit 1 +} + +# print usage and die +usage() { + echo "$PROGRAM $VERSION" + echo "usage: $PROGRAM [-hv] [-s number] script" + echo "" + echo " -h Show help and exit." + echo " -k Also add a corresponding kill link for shutdown/reboot." + echo " -s Set two-digit start number (00-99). Default is $STARTNUM." + echo " -S Add service as a system init service (rcS.d)." + echo " -v Turn on verbose output." + echo "" + exit 1 +} + +#parse args +unset vflag +while getopts "hks:Sv" opt ; do + case "$opt" in + h) usage;; + k) KILL="-k";; + s) STARTNUM="$OPTARG";; + S) RCDIR="ROOT/rcS.d";; + v) vflag="-v"; VERBOSE=1 ;; + \?) usage;; + esac +done +shift `expr $OPTIND - 1` + +# check if script is specified +[ $# -lt 1 ] && usage + +while [ $# -gt 0 ] ; do + SCRIPT="$1" + + # validate the start number + echo "$STARTNUM" | grep '^[0-9][0-9]$' > /dev/null || die "Start number needs to be a 2 digit number. (00-99)" + + mkdir -p "$ROOT/$RCDIR" + cd "$ROOT/$RCDIR" + + LINKTARGET="../init.d/$SCRIPT" + [ -f "$LINKTARGET" ] || die "Could not find init script $LINKTARGET" + SLINK="S$LEVEL$STARTNUM$SCRIPT" + [ "$VERBOSE" ] && echo "Creating $ROOT/$RCDIR/$SLINK." + ln -sf $LINKTARGET "$ROOT/$RCDIR/$SLINK" || exit $? + + if [ "$KILL" ] ; then + KLINK="K$LEVEL$STARTNUM$SCRIPT" + [ "$VERBOSE" ] && echo "Creating $ROOT/etc/rcK.d/$KLINK." + mkdir -p "$ROOT/etc/rcK.d" + ln -sf $LINKTARGET "$ROOT/etc/rcK.d/$KLINK" || exit $? + fi + + shift +done +exit 0 diff --git a/rc_delete b/rc_delete new file mode 100755 index 0000000..0b63aa8 --- /dev/null +++ b/rc_delete @@ -0,0 +1,68 @@ +#!/bin/sh +# +# rc_delete - delete an init script from a runlevel +# +# Copyright (c) 2005 Natanael Copa +# +# Distributed under GPL-2 +# + +PROGRAM=`basename $0` + +#load the libraries +. /sbin/functions.sh + +LEVEL=4 + +die() { + echo "$1" >&2 + exit 1 +} + +# print usage and die +usage() { + echo "$PROGRAM $VERSION" + echo "usage: $PROGRAM [-hv] [-l level] script..." + echo "" + echo " -h Show help and exit." + echo " -l Only remove from specified level. Default is all levels." + echo " -v Turn on verbose output." + echo "" + exit 1 +} + +#parse args +unset vflag +while getopts "hl:v" opt ; do + case "$opt" in + h) usage;; + l) LEVEL="$OPTARG";; + v) vflag="-v"; VERBOSE=1 ;; + \?) usage;; + esac +done +shift `expr $OPTIND - 1` + +# check if script is specified +[ $# -lt 1 ] && usage +while [ $# -gt 0 ] ; do + SCRIPT="$1" + + rclinks="" + for rcl in $ROOT/etc/rcS.d/[S][0-9][0-9]$SCRIPT \ + $ROOT/etc/rcL.d/[SK][0-9][0-9]$SCRIPT \ + $ROOT/etc/rcK.d/[SK][0-9][0-9]$SCRIPT ; do + [ -e "$rcl" ] || continue + echo "$rcl" + rclinks="$rclinks $rcl" + done + + for rclink in $rclinks ; do + [ "$VERBOSE" ] && echo "Removing $rclink." + rm -f $rclink + done + shift +done + +exit 0 + diff --git a/rc_status b/rc_status new file mode 100755 index 0000000..d547555 --- /dev/null +++ b/rc_status @@ -0,0 +1,57 @@ +#!/bin/sh +# +# rc_status - show status of boot scripts +# +# Copyright (c) 2005 Natanael Copa +# +# Distributed under GPL-2 +# + +PROGRAM=`basename $0` + +#load the libraries +. /sbin/functions.sh + +die() { + echo "$1" >&2 + exit 1 +} + +# print usage and die +usage() { + echo "$PROGRAM $VERSION" + echo "usage: $PROGRAM [-hv] [-l level] [script]" + echo "" + echo " -h Show help and exit." + echo " -l Show only specified level." + echo " -v Turn on verbose output." + echo "" + exit 1 +} + +#parse args +while getopts "hl:v" opt ; do + case "$opt" in + h) usage;; + l) case "$OPTARG" in + S|L|K) LEVELS="$LEVELS $OPTARG";; + *) die "Valid levels are: all, S, K and L";; + esac + ;; + v) VERBOSE="-v" ;; + \?) usage;; + esac +done +shift `expr $OPTIND - 1` + +cd "$ROOT/etc" + +[ -z "$LEVELS" ] && LEVELS="S L K" + +for i in $LEVELS ; do + echo "rc$i.d:" + ls -1 $VERBOSE rc$i.d 2>/dev/null + echo "" +done + +exit diff --git a/runscript-alpine.sh b/runscript-alpine.sh new file mode 100755 index 0000000..f669188 --- /dev/null +++ b/runscript-alpine.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +myscript="$1" +if [ -L $1 ] ; then + myservice=$(readlink "$1") +else + myservice=$1 +fi + +myservice=`basename ${myservice}` +export SVCNAME=${myservice} + +[ "$RC_GOT_FUNCTIONS" ] || . /sbin/functions.sh + +# wrapper for busybox killall +killall() { + local flags ka + ka=`which killall` + while [ $# -gt 0 ] ; do + case "$1" in + -*) flags="$flags $1";; + *) flags="$flags `basename $1`" + esac + shift + done + $ka $flags +} + +svc_start() { + start +} + +svc_stop() { + stop +} + +svc_status() { + status +} + +restart() { + svc_stop + sleep 1 + svc_start +} + +usage() { + local i uopts + for i in $opts; do + uopts="$uopts|$i" + done + echo "usage: $myscript start|stop|status|restart$uopts" + exit $1 +} + +[ -f "/etc/conf.d/$myservice" ] && . "/etc/conf.d/$myservice" +. "$myscript" + +shift +if [[ $# -lt 1 ]] ; then + usage 1 +fi + +for arg in $* ; do + case "${arg}" in + start) + svc_start + ;; + stop) + svc_stop + ;; + status) + svc_status + ;; + restart) + restart + ;; + *) + for opt in $opts ; do + [ "$arg" = "$opt" ] && $arg + done + ;; + esac +done + diff --git a/sd_links b/sd_links new file mode 100644 index 0000000..bde32ff --- /dev/null +++ b/sd_links @@ -0,0 +1,78 @@ +#!/bin/sh + +# NOTE: since mdev -s only provide $MDEV, don't depend on any hotplug vars. + +# function to create a link to a disk (sd[a-z]) +mklink_disk() { + local last + # find the last disk + last=`ls usb[a-z] 2>/dev/null | sort | tail -n 1 | sed 's/usb\([a-z]\).*/\1/'` + if [ "$last" ] ; then + # get next char in alphabet + next=`echo $last | tr 'abcdeghijklmnopqrstuvwxy' \ + 'bcdefghijklmnopqrtuvwxyz'` + else + # its the first + next="a" + fi + + DISKLINK=usb$next + ln -sf $DISK $DISKLINK +} + +# function to create a link to a partition (sd[a-z][0-9]) +mklink_partition() { + local num + num=`echo $MDEV | sed 's/sd[a-z]//'` + + for i in usb[a-z] ; do + if [ "`readlink $i 2>/dev/null`" = $DISK ] ; then + DISKLINK=$i + break + fi + done + + # if there are no disk link then create one. + [ "$DISKLINK" ] || mklink_disk + + # create the link to the partition + ln -sf $MDEV $DISKLINK$num +} + +# check if there already exist an usb link to this dev. +for i in usb[a-z] usb[a-z][0-9]* ; do + if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then + USBLINK=$i + break + fi +done +if [ "$USBLINK" ] ;then + # hotplug remove action + [ "$ACTION" = "remove" ] && rm $USBLINK + + # the link already exist or is not supposed to exist. We are done. + exit +fi + +# find out if its a disk or a partition +if [ -d /sys/block/$MDEV ] ; then + TYPE=disk + DISK=$MDEV + SCSIDEV=/sys/block/$MDEV/device/scsi_device:* +elif [ -d /sys/block/*/$MDEV ] ; then + TYPE=partition + PARENT=`dirname /sys/block/*/$MDEV` + DISK=`basename $PARENT` + SCSIDEV=$PARENT/device/scsi_device:* +else + exit +fi + +# check if the scsi host belongs to usb-storage. exit if it doesn't +SCSI_HOST=`basename $SCSIDEV | cut -d : -f 2` +[ -f "/proc/scsi/usb-storage/$SCSI_HOST" ] || exit + +# create link +mklink_$TYPE + + diff --git a/services b/services new file mode 100644 index 0000000..9b9e87c --- /dev/null +++ b/services @@ -0,0 +1,969 @@ +# /etc/services +# +# Network services, Internet style +# +# Note that it is presently the policy of IANA to assign a single well-known +# port number for both TCP and UDP; hence, most entries here have two entries +# even if the protocol doesn't support UDP operations. +# +# Some References: +# http://www.iana.org/assignments/port-numbers +# http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/services +# +# Each line describes one service, and is of the form: +# service-name port/protocol [aliases ...] [# comment] +# + +# +# IANA Assignments [Well Known Ports] +# The Well Known Ports are assigned by the IANA and on most systems can +# only be used by system (or root) processes or by programs executed by +# privileged users. +# The range for assigned ports managed by the IANA is 0-1023. +# +tcpmux 1/tcp # TCP port service multiplexer +tcpmux 1/udp +compressnet 2/tcp # Management Utility +compressnet 2/udp +compressnet 3/tcp # Compression Process +compressnet 3/udp +rje 5/tcp # Remote Job Entry +rje 5/udp +echo 7/tcp # Echo +echo 7/udp +discard 9/tcp sink null # Discard +discard 9/udp sink null +systat 11/tcp users # Active Users +systat 11/udp users +daytime 13/tcp # Daytime (RFC 867) +daytime 13/udp +#netstat 15/tcp # (was once asssigned, no more) +qotd 17/tcp quote # Quote of the Day +qotd 17/udp quote +msp 18/tcp # Message Send Protocol +msp 18/udp +chargen 19/tcp ttytst source # Character Generator +chargen 19/udp ttytst source +ftp-data 20/tcp # File Transfer [Default Data] +ftp-data 20/udp +ftp 21/tcp # File Transfer [Control] +ftp 21/udp fsp fspd +ssh 22/tcp # SSH Remote Login Protocol +ssh 22/udp +telnet 23/tcp # Telnet +telnet 23/udp +# private 24/tcp # any private mail system +# private 24/udp +smtp 25/tcp mail # Simple Mail Transfer +smtp 25/udp +nsw-fe 27/tcp # NSW User System FE +nsw-fe 27/udp +msg-icp 29/tcp # MSG ICP +msg-icp 29/udp +msg-auth 31/tcp # MSG Authentication +msg-auth 31/udp +dsp 33/tcp # Display Support Protocol +dsp 33/udp +# private 35/tcp # any private printer server +# private 35/udp +time 37/tcp timserver +time 37/udp timserver +rap 38/tcp # Route Access Protocol +rap 38/udp +rlp 39/tcp resource # Resource Location Protocol +rlp 39/udp resource +graphics 41/tcp # Graphics +graphics 41/udp +nameserver 42/tcp name # Host Name Server +nameserver 42/udp name +nicname 43/tcp whois # Who Is +nicname 43/udp whois +mpm-flags 44/tcp # MPM FLAGS Protocol +mpm-flags 44/udp +mpm 45/tcp # Message Processing Module [recv] +mpm 45/udp +mpm-snd 46/tcp # MPM [default send] +mpm-snd 46/udp +ni-ftp 47/tcp # NI FTP +ni-ftp 47/udp +auditd 48/tcp # Digital Audit Daemon +auditd 48/udp +tacacs 49/tcp # Login Host Protocol (TACACS) +tacacs 49/udp +re-mail-ck 50/tcp # Remote Mail Checking Protocol +re-mail-ck 50/udp +domain 53/tcp # Domain Name Server +domain 53/udp +xns-ch 54/tcp # XNS Clearinghouse +xns-ch 54/udp +isi-gl 55/tcp # ISI Graphics Language +isi-gl 55/udp +xns-auth 56/tcp # XNS Authentication +xns-auth 56/udp +# private 57/tcp # any private terminal access +# private 57/udp +xns-mail 58/tcp # XNS Mail +xns-mail 58/udp +# private 59/tcp # any private file service +# private 59/udp +ni-mail 61/tcp # NI MAIL +ni-mail 61/udp +acas 62/tcp # ACA Services +acas 62/udp +whois++ 63/tcp # whois++ +whois++ 63/udp +covia 64/tcp # Communications Integrator (CI) +covia 64/udp +tacacs-ds 65/tcp # TACACS-Database Service +tacacs-ds 65/udp +sql*net 66/tcp # Oracle SQL*NET +sql*net 66/udp +bootps 67/tcp # Bootstrap Protocol Server (BOOTP) +bootps 67/udp +bootpc 68/tcp # Bootstrap Protocol Client (BOOTP) +bootpc 68/udp +tftp 69/tcp # Trivial File Transfer +tftp 69/udp +gopher 70/tcp # Gopher +gopher 70/udp +netrjs-1 71/tcp # Remote Job Service +netrjs-1 71/udp +netrjs-2 72/tcp +netrjs-2 72/udp +netrjs-3 73/tcp +netrjs-3 73/udp +netrjs-4 74/tcp +netrjs-4 74/udp +# private 75/tcp # any private dial out service +# private 75/udp +deos 76/tcp # Distributed External Object Store +deos 76/udp +# private 77/tcp # any private RJE service +# private 77/udp +vettcp 78/tcp # vettcp +vettcp 78/udp +finger 79/tcp # Finger +finger 79/udp +http 80/tcp www www-http # World Wide Web HTTP +http 80/udp www www-http +hosts2-ns 81/tcp # HOSTS2 Name Server +hosts2-ns 81/udp +xfer 82/tcp # XFER Utility +xfer 82/udp +mit-ml-dev 83/tcp # MIT ML Device +mit-ml-dev 83/udp +ctf 84/tcp # Common Trace Facility +ctf 84/udp +mit-ml-dev 85/tcp # MIT ML Device +mit-ml-dev 85/udp +mfcobol 86/tcp # Micro Focus Cobol +mfcobol 86/udp +# private 87/tcp # any private terminal link +# private 87/udp +kerberos 88/tcp kerberos5 krb5 # Kerberos +kerberos 88/udp kerberos5 krb5 +su-mit-tg 89/tcp # SU/MIT Telnet Gateway +su-mit-tg 89/udp +dnsix 90/tcp # DNSIX Securit Attribute Token Map +dnsix 90/udp +mit-dov 91/tcp # MIT Dover Spooler +mit-dov 91/udp +npp 92/tcp # Network Printing Protocol +npp 92/udp +dcp 93/tcp # Device Control Protocol +dcp 93/udp +objcall 94/tcp # Tivoli Object Dispatcher +objcall 94/udp +supdup 95/tcp # SUPDUP +supdup 95/udp +dixie 96/tcp # DIXIE Protocol Specification +dixie 96/udp +swift-rvf 97/tcp # Swift Remote Virtural File Protocol +swift-rvf 97/udp +tacnews 98/tcp # TAC News +tacnews 98/udp +metagram 99/tcp # Metagram Relay +metagram 99/udp +#newacct 100/tcp # [unauthorized use] +hostname 101/tcp hostnames # NIC Host Name Server +hostname 101/udp hostnames +iso-tsap 102/tcp tsap # ISO-TSAP Class 0 +iso-tsap 102/udp tsap +gppitnp 103/tcp # Genesis Point-to-Point Trans Net +gppitnp 103/udp +acr-nema 104/tcp # ACR-NEMA Digital Imag. & Comm. 300 +acr-nema 104/udp +cso 105/tcp csnet-ns cso-ns # CCSO name server protocol +cso 105/udp csnet-ns cso-ns +3com-tsmux 106/tcp poppassd # 3COM-TSMUX +3com-tsmux 106/udp poppassd # Eudora: Unauthorized use by insecure poppassd protocol +rtelnet 107/tcp # Remote Telnet Service +rtelnet 107/udp +snagas 108/tcp # SNA Gateway Access Server +snagas 108/udp +pop2 109/tcp pop-2 postoffice# Post Office Protocol - Version 2 +pop2 109/udp pop-2 +pop3 110/tcp pop-3 # Post Office Protocol - Version 3 +pop3 110/udp pop-3 +sunrpc 111/tcp portmapper # SUN Remote Procedure Call +sunrpc 111/udp portmapper +mcidas 112/tcp # McIDAS Data Transmission Protocol +mcidas 112/udp +auth 113/tcp authentication tap ident # Authentication Service +auth 113/udp +sftp 115/tcp # Simple File Transfer Protocol +sftp 115/udp +ansanotify 116/tcp # ANSA REX Notify +ansanotify 116/udp +uucp-path 117/tcp # UUCP Path Service +uucp-path 117/udp +sqlserv 118/tcp # SQL Services +sqlserv 118/udp +nntp 119/tcp readnews untp # Network News Transfer Protocol +nntp 119/udp readnews untp +cfdptkt 120/tcp # CFDPTKT +cfdptkt 120/udp +erpc 121/tcp # Encore Expedited Remote Pro.Call +erpc 121/udp +smakynet 122/tcp # SMAKYNET +smakynet 122/udp +ntp 123/tcp # Network Time Protocol +ntp 123/udp +ansatrader 124/tcp # ANSA REX Trader +ansatrader 124/udp +locus-map 125/tcp # Locus PC-Interface Net Map Ser +locus-map 125/udp +nxedit 126/tcp unitary # NXEdit +nxedit 126/udp unitary # Unisys Unitary Login +locus-con 127/tcp # Locus PC-Interface Conn Server +locus-con 127/udp +gss-xlicen 128/tcp # GSS X License Verification +gss-xlicen 128/udp +pwdgen 129/tcp # Password Generator Protocol +pwdgen 129/udp +cisco-fna 130/tcp # cisco FNATIVE +cisco-fna 130/udp +cisco-tna 131/tcp # cisco TNATIVE +cisco-tna 131/udp +cisco-sys 132/tcp # cisco SYSMAINT +cisco-sys 132/udp +statsrv 133/tcp # Statistics Service +statsrv 133/udp +ingres-net 134/tcp # INGRES-NET Service +ingres-net 134/udp +epmap 135/tcp loc-srv # DCE endpoint resolution +epmap 135/udp loc-srv +profile 136/tcp # PROFILE Naming System +profile 136/udp +netbios-ns 137/tcp # NETBIOS Name Service +netbios-ns 137/udp +netbios-dgm 138/tcp # NETBIOS Datagram Service +netbios-dgm 138/udp +netbios-ssn 139/tcp # NETBIOS Session Service +netbios-ssn 139/udp +emfis-data 140/tcp # EMFIS Data Service +emfis-data 140/udp +emfis-cntl 141/tcp # EMFIS Control Service +emfis-cntl 141/udp +imap 143/tcp imap2 # Internet Message Access Protocol +imap 143/udp imap2 +uma 144/tcp # Universal Management Architecture +uma 144/udp +uaac 145/tcp # UAAC Protocol +uaac 145/udp +iso-tp0 146/tcp # ISO-TP0 +iso-tp0 146/udp +iso-ip 147/tcp # ISO-IP +iso-ip 147/udp +jargon 148/tcp # Jargon +jargon 148/udp +aed-512 149/tcp # AED 512 Emulation Service +aed-512 149/udp +sql-net 150/tcp # SQL-NET +sql-net 150/udp +hems 151/tcp # HEMS +hems 151/udp +bftp 152/tcp # Background File Transfer Program +bftp 152/udp +sgmp 153/tcp # SGMP +sgmp 153/udp +netsc-prod 154/tcp # NETSC +netsc-prod 154/udp +netsc-dev 155/tcp +netsc-dev 155/udp +sqlsrv 156/tcp # SQL Service +sqlsrv 156/udp +knet-cmp 157/tcp # KNET/VM Command/Message Protocol +knet-cmp 157/udp +pcmail-srv 158/tcp # PCMail Server +pcmail-srv 158/udp +nss-routing 159/tcp # NSS-Routing +nss-routing 159/udp +sgmp-traps 160/tcp # SGMP-TRAPS +sgmp-traps 160/udp +snmp 161/tcp # Simple Net Mgmt Proto +snmp 161/udp +snmptrap 162/tcp snmp-trap # Traps for SNMP +snmptrap 162/udp snmp-trap +cmip-man 163/tcp # CMIP/TCP Manager +cmip-man 163/udp +cmip-agent 164/tcp # CMIP/TCP Agent +cmip-agent 164/udp +xns-courier 165/tcp # Xerox +xns-courier 165/udp +s-net 166/tcp # Sirius Systems +s-net 166/udp +namp 167/tcp # NAMP +namp 167/udp +rsvd 168/tcp # RSVD +rsvd 168/udp +send 169/tcp # SEND +send 169/udp +print-srv 170/tcp # Network PostScript +print-srv 170/udp +multiplex 171/tcp # Network Innovations Multiplex +multiplex 171/udp +cl/1 172/tcp # Network Innovations CL/1 +cl/1 172/udp +xyplex-mux 173/tcp # Xyplex +xyplex-mux 173/udp +mailq 174/tcp # Mailer transport queue for Zmailer +mailq 174/udp +vmnet 175/tcp # VMNET +vmnet 175/udp +genrad-mux 176/tcp # GENRAD-MUX +genrad-mux 176/udp +xdmcp 177/tcp # X Display Manager Control Protocol +xdmcp 177/udp +nextstep 178/tcp NeXTStep NextStep# NextStep Window Server +nextstep 178/udp NeXTStep NextStep +bgp 179/tcp # Border Gateway Protocol +bgp 179/udp +ris 180/tcp # Intergraph +ris 180/udp +unify 181/tcp # Unify +unify 181/udp +audit 182/tcp # Unisys Audit SITP +audit 182/udp +ocbinder 183/tcp # OCBinder +ocbinder 183/udp +ocserver 184/tcp # OCServer +ocserver 184/udp +remote-kis 185/tcp # Remote-KIS +remote-kis 185/udp +kis 186/tcp # KIS Protocol +kis 186/udp +aci 187/tcp # Application Communication Interface +aci 187/udp +mumps 188/tcp # Plus Five's MUMPS +mumps 188/udp +qft 189/tcp # Queued File Transport +qft 189/udp +gacp 190/tcp # Gateway Access Control Protocol +gacp 190/udp +prospero 191/tcp # Prospero Directory Service +prospero 191/udp +osu-nms 192/tcp # OSU Network Monitoring System +osu-nms 192/udp +srmp 193/tcp # Spider Remote Monitoring Protocol +srmp 193/udp +irc 194/tcp # Internet Relay Chat Protocol +irc 194/udp +dn6-nlm-aud 195/tcp # DNSIX Network Level Module Audit +dn6-nlm-aud 195/udp +dn6-smm-red 196/tcp # DNSIX Session Mgt Module Audit Redir +dn6-smm-red 196/udp +dls 197/tcp # Directory Location Service +dls 197/udp +dls-mon 198/tcp # Directory Location Service Monitor +dls-mon 198/udp +smux 199/tcp # SNMP Unix Multiplexer +smux 199/udp +src 200/tcp # IBM System Resource Controller +src 200/udp +at-rtmp 201/tcp # AppleTalk Routing Maintenance +at-rtmp 201/udp +at-nbp 202/tcp # AppleTalk Name Binding +at-nbp 202/udp +at-echo 204/tcp # AppleTalk Echo +at-echo 204/udp +at-zis 206/tcp # AppleTalk Zone Information +at-zis 206/udp +qmtp 209/tcp # The Quick Mail Transfer Protocol +qmtp 209/udp +z39.50 210/tcp wais z3950 # ANSI Z39.50 +z39.50 210/udp wais z3950 +914c/g 211/tcp # Texas Instruments 914C/G Terminal +914c/g 211/udp +anet 212/tcp # ATEXSSTR +anet 212/udp +ipx 213/tcp # IPX +ipx 213/udp +imap3 220/tcp # Interactive Mail Access +imap3 220/udp +link 245/tcp # ttylink +link 245/udp +pawserv 345/tcp # Perf Analysis Workbench +pawserv 345/udp +zserv 346/tcp # Zebra server +zserv 346/udp +fatserv 347/tcp # Fatmen Server +fatserv 347/udp +scoi2odialog 360/tcp # scoi2odialog +scoi2odialog 360/udp +semantix 361/tcp # Semantix +semantix 361/udp +srssend 362/tcp # SRS Send +srssend 362/udp +rsvp_tunnel 363/tcp # RSVP Tunnel +rsvp_tunnel 363/udp +aurora-cmgr 364/tcp # Aurora CMGR +aurora-cmgr 364/udp +dtk 365/tcp # Deception Tool Kit +dtk 365/udp +odmr 366/tcp # ODMR +odmr 366/udp +rpc2portmap 369/tcp # Coda portmapper +rpc2portmap 369/udp +codaauth2 370/tcp # Coda authentication server +codaauth2 370/udp +clearcase 371/tcp # Clearcase +clearcase 371/udp +ulistproc 372/tcp ulistserv # UNIX Listserv +ulistproc 372/udp ulistserv +ldap 389/tcp # Lightweight Directory Access Protocol +ldap 389/udp +imsp 406/tcp # Interactive Mail Support Protocol +imsp 406/udp +svrloc 427/tcp # Server Location +svrloc 427/udp +mobileip-agent 434/tcp # MobileIP-Agent +mobileip-agent 434/udp +mobilip-mn 435/tcp # MobilIP-MN +mobilip-mn 435/udp +https 443/tcp # MCom +https 443/udp +snpp 444/tcp # Simple Network Paging Protocol +snpp 444/udp +microsoft-ds 445/tcp Microsoft-DS +microsoft-ds 445/udp Microsoft-DS +kpasswd 464/tcp kpwd # Kerberos "passwd" +kpasswd 464/udp kpwd +photuris 468/tcp +photuris 468/udp +saft 487/tcp # Simple Asynchronous File Transfer +saft 487/udp +gss-http 488/tcp +gss-http 488/udp +pim-rp-disc 496/tcp +pim-rp-disc 496/udp +isakmp 500/tcp # IPsec - Internet Security Association and Key Management Protocol +isakmp 500/udp +exec 512/tcp # remote process execution +comsat 512/udp biff # notify users of new mail received +login 513/tcp # remote login a la telnet +who 513/udp whod # who's logged in to machines +shell 514/tcp cmd # no passwords used +syslog 514/udp +printer 515/tcp spooler # line printer spooler +printer 515/udp spooler +videotex 516/tcp +videotex 516/udp +talk 517/tcp # like tenex link +talk 517/udp +ntalk 518/tcp +ntalk 518/udp +utime 519/tcp unixtime +utime 519/udp unixtime +efs 520/tcp # extended file name server +router 520/udp route routed # local routing process +ripng 521/tcp +ripng 521/udp +ulp 522/tcp +ulp 522/udp +ibm-db2 523/tcp +ibm-db2 523/udp +ncp 524/tcp +ncp 524/udp +timed 525/tcp timeserver +timed 525/udp timeserver +tempo 526/tcp newdate +tempo 526/udp newdate +courier 530/tcp rpc +courier 530/udp rpc +conference 531/tcp chat +conference 531/udp chat +netnews 532/tcp readnews +netnews 532/udp readnews +netwall 533/tcp # -for emergency broadcasts +netwall 533/udp +mm-admin 534/tcp # MegaMedia Admin +mm-admin 534/udp +iiop 535/tcp +iiop 535/udp +opalis-rdv 536/tcp +opalis-rdv 536/udp +nmsp 537/tcp # Networked Media Streaming Protocol +nmsp 537/udp +gdomap 538/tcp # GNUstep distributed objects +gdomap 538/udp +uucp 540/tcp uucpd # uucp daemon +uucp 540/udp uucpd +klogin 543/tcp # Kerberized `rlogin' (v5) +klogin 543/udp +kshell 544/tcp krcmd # Kerberized `rsh' (v5) +kshell 544/udp krcmd +appleqtcsrvr 545/tcp +appleqtcsrvr 545/udp +dhcpv6-client 546/tcp # DHCPv6 Client +dhcpv6-client 546/udp +dhcpv6-server 547/tcp # DHCPv6 Server +dhcpv6-server 547/udp +afpovertcp 548/tcp # AFP over TCP +afpovertcp 548/udp +rtsp 554/tcp # Real Time Stream Control Protocol +rtsp 554/udp +dsf 555/tcp +dsf 555/udp +remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem +remotefs 556/udp rfs_server rfs +nntps 563/tcp snntp # NNTP over SSL +nntps 563/udp snntp +9pfs 564/tcp # plan 9 file service +9pfs 564/udp +whoami 565/tcp +whoami 565/udp +submission 587/tcp # mail message submission +submission 587/udp +http-alt 591/tcp # FileMaker, Inc. - HTTP Alternate +http-alt 591/udp +nqs 607/tcp # Network Queuing system +nqs 607/udp +npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS +npmp-local 610/udp dqs313_qmaster +npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS +npmp-gui 611/udp dqs313_execd +hmmp-ind 612/tcp dqs313_intercell# HMMP Indication / DQS +hmmp-ind 612/udp dqs313_intercell +cryptoadmin 624/tcp # Crypto Admin +cryptoadmin 624/udp +dec_dlm 625/tcp # DEC DLM +dec_dlm 625/udp +asia 626/tcp +asia 626/udp +passgo-tivoli 627/tcp # PassGo Tivoli +passgo-tivoli 627/udp +qmqp 628/tcp # Qmail QMQP +qmqp 628/udp +3com-amp3 629/tcp +3com-amp3 629/udp +rda 630/tcp +rda 630/udp +ipp 631/tcp # Internet Printing Protocol +ipp 631/udp +ldaps 636/tcp # LDAP over SSL +ldaps 636/udp +tinc 655/tcp # TINC control port +tinc 655/udp +acap 674/tcp # Application Configuration Access Protocol +acap 674/udp +ha-cluster 694/tcp # Heartbeat HA-cluster +ha-cluster 694/udp +silc 706/tcp # SILC +silc 706/udp +kerberos-adm 749/tcp # Kerberos `kadmin' (v5) +kerberos-adm 749/udp +kerberos-iv 750/tcp kerberos4 kdc # Kerberos (server) +kerberos-iv 750/udp kerberos4 kdc +webster 765/tcp # Network dictionary +webster 765/udp +phonebook 767/tcp # Network phonebook +phonebook 767/udp +rsync 873/tcp # rsync +rsync 873/udp +ftps-data 989/tcp # ftp protocol, data, over TLS/SSL +ftps-data 989/udp +ftps 990/tcp # ftp protocol, control, over TLS/SSL +ftps 990/udp +nas 991/tcp # Netnews Administration System +nas 991/udp +telnets 992/tcp # telnet protocol over TLS/SSL +telnets 992/udp +imaps 993/tcp # imap4 protocol over TLS/SSL +imaps 993/udp +ircs 994/tcp # irc protocol over TLS/SSL +ircs 994/udp +pop3s 995/tcp # pop3 protocol over TLS/SSL +pop3s 995/udp + +# +# IANA Assignments [Registered Ports] +# +# The Registered Ports are listed by the IANA and on most systems can be +# used by ordinary user processes or programs executed by ordinary +# users. +# Ports are used in the TCP [RFC793] to name the ends of logical +# connections which carry long term conversations. For the purpose of +# providing services to unknown callers, a service contact port is +# defined. This list specifies the port used by the server process as +# its contact port. +# The IANA registers uses of these ports as a convenience to the +# community. +# To the extent possible, these same port assignments are used with the +# UDP [RFC768]. +# The Registered Ports are in the range 1024-49151. +# +socks 1080/tcp # socks proxy server +socks 1080/udp +rmiregistry 1099/tcp # Java RMI Registry +rmiregistry 1099/udp +kazaa 1214/tcp # KAZAA +kazaa 1214/udp +bvcontrol 1236/tcp rmtcfg # Gracilis Packeten remote config server +bvcontrol 1236/udp rmtcfg +nessus 1241/tcp # Nessus vulnerability assessment scanner +nessus 1241/udp +h323hostcallsc 1300/tcp # H323 Host Call Secure +h323hostcallsc 1300/udp +lotusnote 1352/tcp # Lotus Note +lotusnote 1352/udp +ms-sql-s 1433/tcp # Microsoft-SQL-Server +ms-sql-s 1433/udp +ms-sql-m 1434/tcp # Microsoft-SQL-Monitor +ms-sql-m 1434/udp +ica 1494/tcp # Citrix ICA Client +ica 1494/udp +wins 1512/tcp # Microsoft's Windows Internet Name Service +wins 1512/udp +ingreslock 1524/tcp +ingreslock 1524/udp +prospero-np 1525/tcp # Prospero non-privileged +prospero-np 1525/udp +datametrics 1645/tcp old-radius # datametrics / old radius entry +datametrics 1645/udp old-radius +sa-msg-port 1646/tcp old-radacct # sa-msg-port / old radacct entry +sa-msg-port 1646/udp old-radacct +rsap 1647/tcp +rsap 1647/udp +concurrent-lm 1648/tcp +concurrent-lm 1648/udp +kermit 1649/tcp +kermit 1649/udp +l2tp 1701/tcp +l2tp 1701/udp +h323gatedisc 1718/tcp +h323gatedisc 1718/udp +h323gatestat 1719/tcp +h323gatestat 1719/udp +h323hostcall 1720/tcp +h323hostcall 1720/udp +tftp-mcast 1758/tcp +tftp-mcast 1758/udp +hello 1789/tcp +hello 1789/udp +radius 1812/tcp # Radius +radius 1812/udp +radius-acct 1813/tcp radacct # Radius Accounting +radius-acct 1813/udp radacct +mtp 1911/tcp # Starlight Networks Multimedia Transport Protocol +mtp 1911/udp +unix-status 1957/tcp # remstats unix-status server +unix-status 1957/udp +hsrp 1985/tcp # Hot Standby Router Protocol +hsrp 1985/udp +licensedaemon 1986/tcp # cisco license management +licensedaemon 1986/udp +tr-rsrb-p1 1987/tcp # cisco RSRB Priority 1 port +tr-rsrb-p1 1987/udp +tr-rsrb-p2 1988/tcp # cisco RSRB Priority 2 port +tr-rsrb-p2 1988/udp +tr-rsrb-p3 1989/tcp # cisco RSRB Priority 3 port +tr-rsrb-p3 1989/udp +stun-p1 1990/tcp # cisco STUN Priority 1 port +stun-p1 1990/udp +stun-p2 1991/tcp # cisco STUN Priority 2 port +stun-p2 1991/udp +stun-p3 1992/tcp # cisco STUN Priority 3 port +stun-p3 1992/udp +snmp-tcp-port 1994/tcp # cisco SNMP TCP port +snmp-tcp-port 1994/udp +stun-port 1995/tcp # cisco serial tunnel port +stun-port 1995/udp +perf-port 1996/tcp # cisco Remote SRB port +perf-port 1996/udp +gdp-port 1997/tcp # cisco Gateway Discovery Protocol +gdp-port 1997/udp +x25-svc-port 1998/tcp # cisco X.25 service (XOT) +x25-svc-port 1998/udp +tcp-id-port 1999/tcp # cisco identification port +tcp-id-port 1999/udp +cisco-sccp 2000/tcp sieve # Cisco SCCP +cisco-sccp 2000/udp sieve +nfs 2049/tcp # Network File System +nfs 2049/udp +rtcm-sc104 2101/tcp # RTCM SC-104 +rtcm-sc104 2101/udp +zephyr-srv 2102/tcp # Zephyr server +zephyr-srv 2102/udp +zephyr-clt 2103/tcp # Zephyr serv-hm connection +zephyr-clt 2103/udp +zephyr-hm 2104/tcp # Zephyr hostmanager +zephyr-hm 2104/udp +cvspserver 2401/tcp # CVS client/server operations +cvspserver 2401/udp +venus 2430/tcp # codacon port +venus 2430/udp +venus-se 2431/tcp # tcp side effects +venus-se 2431/udp +codasrv 2432/tcp # not used +codasrv 2432/udp +codasrv-se 2433/tcp # tcp side effects +codasrv-se 2433/udp +mon 2583/tcp +mon 2583/udp +hpstgmgr 2600/tcp zebrasrv +hpstgmgr 2600/udp zebrasrv +discp-client 2601/tcp zebra # discp client +discp-client 2601/udp zebra +discp-server 2602/tcp ripd # discp server +discp-server 2602/udp ripd +servicemeter 2603/tcp ripngd # Service Meter +servicemeter 2603/udp ripngd +nsc-ccs 2604/tcp ospfd # NSC CCS +nsc-ccs 2604/udp ospfd +nsc-posa 2605/tcp bgpd # NSC POSA +nsc-posa 2605/udp bgpd +netmon 2606/tcp ospf6d # Dell Netmon +netmon 2606/udp ospf6d +connection 2607/tcp # Dell Connection +connection 2607/udp +wag-service 2608/tcp # Wag Service +wag-service 2608/udp +dict 2628/tcp # Dictionary server +dict 2628/udp +corbaloc 2809/tcp # CORBA LOC +corbaloc 2809/udp +ndtp 2882/tcp # Network Dictionary Transfer Protocol +ndtp 2882/udp +gds_db 3050/tcp # InterBase server +gds_db 3050/udp +icpv2 3130/tcp icp # Internet Cache Protocol (Squid) +icpv2 3130/udp icp +mysql 3306/tcp # MySQL +mysql 3306/udp +trnsprntproxy 3346/tcp # Transparent Proxy +trnsprntproxy 3346/udp +ms-wbt-server 3389/tcp rdp # MS WBT Server +ms-wbt-server 3389/udp rdp # Microsoft Remote Desktop Protocol +prsvp 3455/tcp # RSVP Port +prsvp 3455/udp +nut 3493/tcp # Network UPS Tools +nut 3493/udp +distcc 3632/tcp # Distributed Compiler +distcc 3632/udp +daap 3689/tcp # Digital Audio Access Protocol +daap 3689/udp +svn 3690/tcp # Subversion +svn 3690/udp +netboot-pxe 3928/tcp pxe # PXE NetBoot Manager +netboot-pxe 3928/udp pxe +smauth-port 3929/tcp # AMS Port +smauth-port 3929/udp +pxc-spvr-ft 4002/tcp pxc-spvr-ft rquotad +pxc-spvr-ft 4002/udp pxc-spvr-ft rquotad +pxc-splr-ft 4003/tcp pxc-splr-ft +pxc-splr-ft 4003/udp pxc-splr-ft +pxc-roid 4004/tcp pxc-roid +pxc-roid 4004/udp pxc-roid +pxc-pin 4005/tcp pxc-pin +pxc-pin 4005/udp pxc-pin +pxc-spvr 4006/tcp pxc-spvr +pxc-spvr 4006/udp pxc-spvr +pxc-splr 4007/tcp pxc-splr +pxc-splr 4007/udp pxc-splr +rwhois 4321/tcp # Remote Who Is +rwhois 4321/udp +krb524 4444/tcp +krb524 4444/udp +hylafax 4559/tcp # HylaFAX client-server protocol (new) +hylafax 4559/udp +piranha1 4600/tcp +piranha1 4600/udp +radmin-port 4899/tcp # RAdmin Port +radmin-port 4899/udp +rfe 5002/tcp # Radio Free Ethernet +rfe 5002/udp +ita-agent 5051/tcp # ITA Agent +ita-agent 5051/udp +xmpp-client 5222/tcp # XMPP Client Connection +xmpp-client 5222/udp +xmpp-server 5269/tcp # XMPP Server Connection +xmpp-server 5269/udp +cfengine 5308/tcp # CFengine +cfengine 5308/udp +postgresql 5432/tcp # POSTGRES +postgresql 5432/udp +sgi-eventmond 5553/tcp # SGI Eventmond Port +sgi-eventmond 5553/udp +sgi-esphttp 5554/tcp # SGI ESP HTTP +sgi-esphttp 5554/udp +cvsup 5999/tcp # CVSup +cvsup 5999/udp +x11 6000/tcp # X Window System +x11 6000/udp +gnutella-svc 6346/tcp +gnutella-svc 6346/udp +gnutella-rtr 6347/tcp +gnutella-rtr 6347/udp +sane-port 6566/tcp # SANE Network Scanner Control Port +sane-port 6566/udp +afs3-fileserver 7000/tcp bbs # file server itself +afs3-fileserver 7000/udp bbs +afs3-callback 7001/tcp # callbacks to cache managers +afs3-callback 7001/udp +afs3-prserver 7002/tcp # users & groups database +afs3-prserver 7002/udp +afs3-vlserver 7003/tcp # volume location database +afs3-vlserver 7003/udp +afs3-kaserver 7004/tcp # AFS/Kerberos authentication +afs3-kaserver 7004/udp +afs3-volser 7005/tcp # volume managment server +afs3-volser 7005/udp +afs3-errors 7006/tcp # error interpretation service +afs3-errors 7006/udp +afs3-bos 7007/tcp # basic overseer process +afs3-bos 7007/udp +afs3-update 7008/tcp # server-to-server updater +afs3-update 7008/udp +afs3-rmtsys 7009/tcp # remote cache manager service +afs3-rmtsys 7009/udp +font-service 7100/tcp xfs # X Font Service +font-service 7100/udp xfs +http-alt 8008/tcp # HTTP Alternate +http-alt 8008/udp +http-alt 8080/tcp # HTTP Alternate +http-alt 8080/udp +bacula-dir 9101/tcp # Bacula Director +bacula-dir 9101/udp +bacula-fd 9102/tcp # Bacula File Daemon +bacula-fd 9102/udp +bacula-sd 9103/tcp # Bacula Storage Daemon +bacula-sd 9103/udp +sd 9876/tcp # Session Director +sd 9876/udp +cyborg-systems 9888/tcp # CYBORG Systems +cyborg-systems 9888/udp +monkeycom 9898/tcp # MonkeyCom +monkeycom 9898/udp +amanda 10080/tcp # amanda backup services +amanda 10080/udp +smsqp 11201/tcp # Alamin SMS gateway +smsqp 11201/udp +hkp 11371/tcp # OpenPGP HTTP Keyserver +hkp 11371/udp +h323callsigalt 11720/tcp # h323 Call Signal Alternate +h323callsigalt 11720/udp +bprd 13720/tcp # BPRD Protocol (VERITAS NetBackup) +bprd 13720/udp +bpdbm 13721/tcp # BPDBM Protocol (VERITAS NetBackup) +bpdbm 13721/udp +bpjava-msvc 13722/tcp # BP Java MSVC Protocol +bpjava-msvc 13722/udp +vnetd 13724/tcp # Veritas Network Utility +vnetd 13724/udp +bpcd 13782/tcp # VERITAS NetBackup +bpcd 13782/udp +vopied 13783/tcp # VOPIED Protocol +vopied 13783/udp +xpilot 15345/tcp # XPilot Contact Port +xpilot 15345/udp +wnn6 22273/tcp # wnn6 +wnn6 22273/udp +binkp 24554/tcp # Bink fidonet protocol +binkp 24554/udp +quake 26000/tcp # Quake @!# +quake 26000/udp +wnn6-ds 26208/tcp +wnn6-ds 26208/udp +traceroute 33434/tcp # traceroute use +traceroute 33434/udp + +#========================================================================= +# The remaining port numbers are not as allocated by IANA. + +# Kerberos (Project Athena/MIT) services +# Note that these are for Kerberos v4, and are unofficial +kerberos_master 751/tcp # Kerberos authentication +kerberos_master 751/udp +passwd_server 752/tcp # Kerberos passwd server +passwd_server 752/udp +krb_prop 754/tcp # Kerberos slave propagation +krbupdate 760/tcp kreg # Kerberos registration +kpop 1109/tcp # Pop with Kerberos +knetd 2053/tcp # Kerberos de-multiplexor +eklogin 2105/tcp # Kerberos encrypted rlogin + +# CVSup support http://www.cvsup.org/ +supfilesrv 871/tcp # SUP server +supfiledbg 1127/tcp # SUP debugging + +# Datagram Delivery Protocol services +rtmp 1/ddp # Routing Table Maintenance Protocol +nbp 2/ddp # Name Binding Protocol +echo 4/ddp # AppleTalk Echo Protocol +zip 6/ddp # Zone Information Protocol + +# Many services now accepted as 'standard' +linuxconf 98/tcp # LinuxConf +smtps 465/tcp ssmtp # smtp protocol over TLS/SSL +smtps 465/udp ssmtp +swat 901/tcp # Samba configuration tool +rndc 953/tcp # rndc control sockets (BIND 9) +rndc 953/udp +skkserv 1178/tcp # SKK Japanese input method +xtel 1313/tcp # french minitel +support 1529/tcp # GNATS +cfinger 2003/tcp lmtp # GNU Finger +ninstall 2150/tcp # ninstall service +ninstall 2150/udp +afbackup 2988/tcp # Afbackup system +afbackup 2988/udp +fax 4557/tcp # FAX transmission service (old) +noclog 5354/tcp # noclogd with TCP (nocol) +noclog 5354/udp +hostmon 5355/tcp # hostmon uses TCP (nocol) +hostmon 5355/udp +rplay 5555/tcp # RPlay audio service +rplay 5555/udp +canna 5680/tcp # Canna (Japanese Input) +x11-ssh 6010/tcp x11-ssh-offset +x11-ssh 6010/udp x11-ssh-offset +ircd 6667/tcp # Internet Relay Chat +ircd 6667/udp +webcache 8080/tcp # WWW caching service +webcache 8080/udp +tproxy 8081/tcp # Transparent Proxy +tproxy 8081/udp +jetdirect 9100/tcp #HP JetDirect card +jetdirect 9100/udp +mandelspawn 9359/udp mandelbrot # network mandelbrot +kamanda 10081/tcp # amanda backup services (Kerberos) +kamanda 10081/udp +amandaidx 10082/tcp # amanda backup services +amidxtape 10083/tcp # amanda backup services +isdnlog 20011/tcp # isdn logging system +isdnlog 20011/udp +vboxd 20012/tcp # voice box system +vboxd 20012/udp +wnn4_Cn 22289/tcp wnn6_Cn # Wnn (Chinese input) +wnn4_Kr 22305/tcp wnn6_Kr # Wnn (Korean input) +wnn4_Tw 22321/tcp wnn6_Tw # Wnn (Taiwanse input) +asp 27374/tcp # Address Search Protocol +asp 27374/udp +tfido 60177/tcp # Ifmail +tfido 60177/udp +fido 60179/tcp # Ifmail +fido 60179/udp + +# Local services + @@ -0,0 +1,42 @@ +root::13364:0::::: +bin:!:13364:0::::: +daemon:!:13364:0::::: +adm:!:13364:0::::: +lp:!:13364:0::::: +sync:!:13364:0::::: +shutdown:!:13364:0::::: +halt:!:13364:0::::: +mail:!:13364:0::::: +news:!:13364:0::::: +uucp:!:13364:0::::: +operator:!:13364:0::::: +man:!:13364:0::::: +postmaster:!:13364:0::::: +cron:!:13364:0::::: +ftp:!:13364:0::::: +sshd:!:13364:0::::: +at:!:13364:0::::: +squid:!:13364:0::::: +gdm:!:13364:0::::: +xfs:!:13364:0::::: +games:!:13364:0::::: +named:!:13364:0::::: +mysql:!:13364:0::::: +postgres:!:13364:0::::: +apache:!:13364:0::::: +nut:!:13364:0::::: +cyrus:!:13364:0::::: +vpopmail:!:13364:0::::: +alias:!:13364:0::::: +qmaild:!:13364:0::::: +qmaill:!:13364:0::::: +qmailp:!:13364:0::::: +qmailq:!:13364:0::::: +qmailr:!:13364:0::::: +qmails:!:13364:0::::: +postfix:!:13364:0::::: +smmsp:!:13364:0::::: +portage:!:13364:0::::: +guest:!:13364:0::::: +nobody:!:13364:0::::: +distcc:!:13364:0::::: @@ -0,0 +1,7 @@ +# valid login shells +/bin/ash +/bin/dash +#/bin/bash +#/bin/lash +#/bin/msh + diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..bf012f1 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,30 @@ + +CC = gcc +LD = gcc + +#BIN_TARGETS = splashbard +#SBIN_TARGETS = runscript start-stop-daemon +SBIN_TARGETS = runscript +TARGET = $(BIN_TARGETS) $(SBIN_TARGETS) + +.PHONY: all clean +all: $(TARGET) + +tsplashd: splashbard.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + +runscript: runscript.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + +start-stop-daemon: start-stop-daemon.c + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< + +clean: + rm -f $(TARGET) *.o core *~ + +install: $(TARGET) + install -m 0755 -d $(DESTDIR)/bin + install -m 0755 -d $(DESTDIR)/sbin +# install -m 0755 $(BIN_TARGETS) $(DESTDIR)/bin + install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin + diff --git a/src/headers.h b/src/headers.h new file mode 100644 index 0000000..1ebf79d --- /dev/null +++ b/src/headers.h @@ -0,0 +1,26 @@ +/* + * header.h + * Dirty little file to include header files w/out autotools. + * + * Copyright 1999-2004 Gentoo Foundation + * Distributed under the terms of the GNU General Public License v2 + * $Header$ + */ + +/* Common includes */ +#define HAVE_TIOCNOTTY +#define HAVE_SETSID + +/* OS-specific includes */ +#if defined(__linux__) +# define HAVE_SYS_SYSMACROS_H +# define HAVE_ERROR_H +#endif + +/* Now we actually include crap ;) */ +#ifdef HAVE_ERROR_H +# include <error.h> +#endif +#ifdef HAVE_SYS_SYSMACROS_H +# include <sys/sysmacros.h> +#endif diff --git a/src/runscript.c b/src/runscript.c new file mode 100644 index 0000000..62e20c6 --- /dev/null +++ b/src/runscript.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> + +#define MAXARGS 32 + +int main(int argc, char *argv[]) { + char *av[MAXARGS]; + int i; + char *runscriptsh; + + if (!(runscriptsh = getenv("RUNSCRIPT"))) + runscriptsh = "/sbin/runscript-alpine.sh"; + for (i = 0; i < argc && i < MAXARGS ; i++) { + av[i] = argv[i]; + } + av[i] = NULL; + + if (execv(runscriptsh, av) < 0) { + perror("execv"); + return -1; + } + return 0; +} diff --git a/src/splashbard.c b/src/splashbard.c new file mode 100644 index 0000000..7fd5dce --- /dev/null +++ b/src/splashbard.c @@ -0,0 +1,215 @@ +/* + +Splash daemon + +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <sys/types.h> +#include <unistd.h> +#include <signal.h> +#include <string.h> + +char unfilled[64] = " "; +char filled[64] = "="; +char leftborder[64] = "["; +char rightborder[64] = "]"; +char animation[64] = "\\|/-"; +char message[128] = "SplashD"; + +int width = 78; +int delay = 50000; +int steps = 10; + +char sigusr1 = 0; +char sigusr2 = 0; +char sigterm = 0; + +const char options[] = "a:d:f:l:m:r:u:"; + +void usage(int exitcode) { + fprintf(stderr, "Usage: splashd [-adflru] [OPTION] STEPS\n"); + exit(exitcode); +} + +int parse_args(int argc, char *argv[]) { + int c; + while ((c = getopt(argc, argv, options)) > 0) { + switch(c) { + + case 'a': { + strncpy(animation, optarg, sizeof(animation)); + break; + } + + case 'd': { + delay = atoi(optarg); + break; + } + + case 'f': { + strncpy(filled, optarg, sizeof(filled)); + break; + } + + case 'l': { + strncpy(leftborder, optarg, sizeof(leftborder)); + break; + } + + case 'm': { + strncpy(message, optarg, sizeof(message)); + break; + } + + case 'r': { + strncpy(rightborder, optarg, sizeof(rightborder)); + break; + } + + case 'u': { + strncpy(unfilled, optarg, sizeof(unfilled)); + break; + } + + case '?': + default: { + usage(1); + break; + } + + } + + } + if (optind != argc-1) usage(1); + return atoi(argv[optind]); +} + + +void clear_screen(void) { + int i; + for (i=0; i<50; i++) { + printf("\f"); + } + printf("\n"); +} + +void center(char *s) { + int i; + printf("\n"); + for (i=0; i < (80-strlen(s)) /2; i++) putchar(' '); + printf("%s", s); +} + +void draw_bar(int steps, char *msg) { + int i=0; + char bar[256]; + char *p = bar; + int size=sizeof(bar); + + if (steps >= 78) steps=78; + + for (i=0; i < 20; i++) printf("\n"); + p += snprintf(p, (size =- strlen(leftborder)), "%s", leftborder); + + for (i=0; i < steps; i++) { + p += snprintf(p, (size =-strlen(unfilled)), "%s", unfilled); + } + p += snprintf(p, (size =- strlen(rightborder)), "%s", rightborder); + + center(msg); + printf("\n"); + center(bar); + for (i=0; i<steps+1; i++) putchar('\b'); + fflush(stdout); + +} + +void sig_handler(int signo) { + signal(signo, sig_handler); + switch(signo) { + + case SIGUSR1: { + sigusr1 = 1; + break; + } + + case SIGUSR2: { + sigusr2 = 1; + break; + } + + case SIGTERM: { + sigterm = 1; + break; + } + + default: + exit(0); + } +} + +void fill_barstr(char *buf, size_t totsize, + int current, int steps, char curs) { + int i = 0; + int lbsize = strlen(leftborder); + int rbsize = strlen(rightborder); + int barsize = totsize - lbsize - rbsize; + int fillcount = current * barsize / steps; + int fillsize = strlen(filled) * fillcount; + char *bar = buf + lbsize; + + if (totsize < lbsize + rbsize + 1) return; + + strncpy(buf, leftborder, totsize); + memset(bar, unfilled[0], barsize); + memset(bar, filled[0], fillcount); + strncpy(bar + barsize, rightborder, totsize - rbsize); + if ( current < steps) bar[fillcount] = curs; +} + + +void run_animation(int steps) { + int current = 0; + int i=0; + char buf[256]; + while (current < steps && sigterm == 0) { + fill_barstr(buf, width, current, steps, animation[i]); + i = (i + 1) % strlen(animation); + printf("\r%s", buf); + usleep(delay); + if (sigusr1) { + sigusr1 = 0; + current++; + } + + fflush(stdout); + } + fill_barstr(buf, width, steps, steps, animation[i]); + printf("\r%s", buf); + fflush(stdout); +} + + +int main(int argc, char *argv[]) { + int steps; + + steps = parse_args(argc, argv); + + /* clear screen */ +// clear_screen(); + + /* fork */ + if (fork()) { + exit(0); + } + + /* attatch to signal handler */ + signal(SIGUSR1, sig_handler); + signal(SIGTERM, sig_handler); + + run_animation(steps); + printf("\n\n"); + return 0; +} diff --git a/src/start-stop-daemon.c b/src/start-stop-daemon.c new file mode 100644 index 0000000..315164f --- /dev/null +++ b/src/start-stop-daemon.c @@ -0,0 +1,1375 @@ +/* + * A rewrite of the original Debian's start-stop-daemon Perl script + * in C (faster - it is executed many times during system startup). + * + * Written by Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, + * public domain. Based conceptually on start-stop-daemon.pl, by Ian + * Jackson <ijackson@gnu.ai.mit.edu>. May be used and distributed + * freely for any purpose. Changes by Christian Schwarz + * <schwarz@monet.m.isar.de>, to make output conform to the Debian + * Console Message Standard, also placed in public domain. Minor + * changes by Klee Dienes <klee@debian.org>, also placed in the Public + * Domain. + * + * Changes by Ben Collins <bcollins@debian.org>, added --chuid, --background + * and --make-pidfile options, placed in public domain aswell. + * + * Port to OpenBSD by Sontri Tomo Huynh <huynh.29@osu.edu> + * and Andreas Schuldei <andreas@schuldei.org> + * + * Changes by Ian Jackson: added --retry (and associated rearrangements). + * + * Modified for Gentoo rc-scripts by Donny Davies <woodchip@gentoo.org>: + * I removed the BSD/Hurd/OtherOS stuff, added #include <stddef.h> + * and stuck in a #define VERSION "1.9.18". Now it compiles without + * the whole automake/config.h dance. + * + * Updated by Aron Griffis <agriffis@gentoo.org>: + * Fetched updates from Debian's dpkg-1.10.20, including fix for + * Gentoo bug 22686 (start-stop-daemon in baselayout doesn't allow + * altered nicelevel). + * Updated by Kito <kito@gentoo.org>: + * Add support for Darwin, additional patches from opendarwin.org + * fix for Gentoo bug 72145 from eldad@gentoo.org + */ + +#define VERSION "1.10.20" +#include <stddef.h> + +#define NONRETURNPRINTFFORMAT(x, y) \ + __attribute__((noreturn, format(printf, x, y))) +#define NONRETURNING \ + __attribute__((noreturn)) + +#if defined(linux) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) +# define OSLinux +#elif defined(__GNU__) +# define OSHURD +#elif defined(__sparc__) +# define OSsunos +#elif defined(OPENBSD) || defined(__OpenBSD__) +# define OSOpenBSD +#elif defined(hpux) +# define OShpux +#elif defined(__FreeBSD__) +# define OSFreeBSD +#elif defined(__NetBSD__) +# define OSNetBSD +#elif defined(__APPLE__) +# define OSDarwin +#else +# error Unknown architecture - cannot build start-stop-daemon +#endif + +#define MIN_POLL_INTERVAL 20000 /*us*/ + +#if defined(OSHURD) +# include <hurd.h> +# include <ps.h> +#endif + +#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin) +#include <sys/param.h> +#include <sys/user.h> +#include <sys/proc.h> +#include <sys/stat.h> +#include <sys/sysctl.h> +#include <sys/types.h> + +#include <err.h> +#include <kvm.h> +#include <limits.h> +#endif + +#if defined(OShpux) +#include <sys/param.h> +#include <sys/pstat.h> +#endif + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <signal.h> +#include <sys/stat.h> +#include <dirent.h> +#include <sys/time.h> +#include <unistd.h> +#include <getopt.h> +#include <pwd.h> +#include <grp.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/termios.h> +#include <fcntl.h> +#include <limits.h> +#include <assert.h> +#include <ctype.h> + +#include "headers.h" + +#ifdef HURD_IHASH_H +# include <hurd/ihash.h> +#endif + +static int testmode = 0; +static int quietmode = 0; +static int exitnodo = 1; +static int start = 0; +static int stop = 0; +static int background = 0; +static int mpidfile = 0; +static int signal_nr = 15; +static const char *signal_str = NULL; +static int user_id = -1; +static int runas_uid = -1; +static int runas_gid = -1; +static const char *userspec = NULL; +static char *changeuser = NULL; +static const char *changegroup = NULL; +static char *changeroot = NULL; +static const char *changedir = NULL; +static const char *cmdname = NULL; +static char *execname = NULL; +static char *startas = NULL; +static const char *pidfile = NULL; +static char what_stop[1024]; +static const char *schedule_str = NULL; +static const char *progname = ""; +static int nicelevel = 0; + +static struct stat exec_stat; +#if defined(OSHURD) +static struct proc_stat_list *procset; +#endif + + +struct pid_list { + struct pid_list *next; + pid_t pid; +}; + +static struct pid_list *found = NULL; +static struct pid_list *killed = NULL; + +struct schedule_item { + enum { sched_timeout, sched_signal, sched_goto, sched_forever } type; + int value; /* seconds, signal no., or index into array */ + /* sched_forever is only seen within parse_schedule and callees */ +}; + +static int schedule_length; +static struct schedule_item *schedule = NULL; + +static void *xmalloc(int size); +static void push(struct pid_list **list, pid_t pid); +static void do_help(void); +static void parse_options(int argc, char * const *argv); +static int pid_is_user(pid_t pid, uid_t uid); +static int pid_is_cmd(pid_t pid, const char *name); +static void check(pid_t pid); +static void do_pidfile(const char *name); +static void do_stop(int signal_nr, int quietmode, + int *n_killed, int *n_notkilled, int retry_nr); +#if defined(OSLinux) || defined(OShpux) +static int pid_is_exec(pid_t pid, const struct stat *esb); +#endif + +#ifdef __GNUC__ +static void fatal(const char *format, ...) + NONRETURNPRINTFFORMAT(1, 2); +static void badusage(const char *msg) + NONRETURNING; +#else +static void fatal(const char *format, ...); +static void badusage(const char *msg); +#endif + +/* This next part serves only to construct the TVCALC macro, which + * is used for doing arithmetic on struct timeval's. It works like this: + * TVCALC(result, expression); + * where result is a struct timeval (and must be an lvalue) and + * expression is the single expression for both components. In this + * expression you can use the special values TVELEM, which when fed a + * const struct timeval* gives you the relevant component, and + * TVADJUST. TVADJUST is necessary when subtracting timevals, to make + * it easier to renormalise. Whenver you subtract timeval elements, + * you must make sure that TVADJUST is added to the result of the + * subtraction (before any resulting multiplication or what have you). + * TVELEM must be linear in TVADJUST. + */ +typedef long tvselector(const struct timeval*); +static long tvselector_sec(const struct timeval *tv) { return tv->tv_sec; } +static long tvselector_usec(const struct timeval *tv) { return tv->tv_usec; } +#define TVCALC_ELEM(result, expr, sec, adj) \ +{ \ + const long TVADJUST = adj; \ + long (*const TVELEM)(const struct timeval*) = tvselector_##sec; \ + (result).tv_##sec = (expr); \ +} +#define TVCALC(result,expr) \ +do { \ + TVCALC_ELEM(result, expr, sec, (-1)); \ + TVCALC_ELEM(result, expr, usec, (+1000000)); \ + (result).tv_sec += (result).tv_usec / 1000000; \ + (result).tv_usec %= 1000000; \ +} while(0) + + +static void +fatal(const char *format, ...) +{ + va_list arglist; + + fprintf(stderr, "%s: ", progname); + va_start(arglist, format); + vfprintf(stderr, format, arglist); + va_end(arglist); + putc('\n', stderr); + exit(2); +} + + +static void * +xmalloc(int size) +{ + void *ptr; + + ptr = malloc(size); + if (ptr) + return ptr; + fatal("malloc(%d) failed", size); +} + + +static void +xgettimeofday(struct timeval *tv) +{ + if (gettimeofday(tv,0) != 0) + fatal("gettimeofday failed: %s", strerror(errno)); +} + + +static void +push(struct pid_list **list, pid_t pid) +{ + struct pid_list *p; + + p = xmalloc(sizeof(*p)); + p->next = *list; + p->pid = pid; + *list = p; +} + +static void +clear(struct pid_list **list) +{ + struct pid_list *here, *next; + + for (here = *list; here != NULL; here = next) { + next = here->next; + free(here); + } + + *list = NULL; +} + +static void +do_help(void) +{ + printf( +"start-stop-daemon " VERSION " for Debian - small and fast C version written by\n" +"Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>, public domain.\n" +"\n" +"Usage:\n" +" start-stop-daemon -S|--start options ... -- arguments ...\n" +" start-stop-daemon -K|--stop options ...\n" +" start-stop-daemon -H|--help\n" +" start-stop-daemon -V|--version\n" +"\n" +"Options (at least one of --exec|--pidfile|--user is required):\n" +" -x|--exec <executable> program to start/check if it is running\n" +" -p|--pidfile <pid-file> pid file to check\n" +" -c|--chuid <name|uid[:group|gid]>\n" +" change to this user/group before starting process\n" +" -u|--user <username>|<uid> stop processes owned by this user\n" +" -g|--group <group|gid> run process as this group\n" +" -n|--name <process-name> stop processes with this name\n" +" -s|--signal <signal> signal to send (default TERM)\n" +" -a|--startas <pathname> program to start (default is <executable>)\n" +" -C|--chdir <directory> Change to <directory>(default is /)\n" +" -N|--nicelevel <incr> add incr to the process's nice level\n" +" -b|--background force the process to detach\n" +" -m|--make-pidfile create the pidfile before starting\n" +" -R|--retry <schedule> check whether processes die, and retry\n" +" -t|--test test mode, don't do anything\n" +" -o|--oknodo exit status 0 (not 1) if nothing done\n" +" -q|--quiet be more quiet\n" +" -v|--verbose be more verbose\n" +"Retry <schedule> is <item>|/<item>/... where <item> is one of\n" +" -<signal-num>|[-]<signal-name> send that signal\n" +" <timeout> wait that many seconds\n" +" forever repeat remainder forever\n" +"or <schedule> may be just <timeout>, meaning <signal>/<timeout>/KILL/<timeout>\n" +"\n" +"Exit status: 0 = done 1 = nothing done (=> 0 if --oknodo)\n" +" 3 = trouble 2 = with --retry, processes wouldn't die\n"); +} + + +static void +badusage(const char *msg) +{ + if (msg) + fprintf(stderr, "%s: %s\n", progname, msg); + fprintf(stderr, "Try `%s --help' for more information.\n", progname); + exit(3); +} + +struct sigpair { + const char *name; + int signal; +}; + +const struct sigpair siglist[] = { + { "ABRT", SIGABRT }, + { "ALRM", SIGALRM }, + { "FPE", SIGFPE }, + { "HUP", SIGHUP }, + { "ILL", SIGILL }, + { "INT", SIGINT }, + { "KILL", SIGKILL }, + { "PIPE", SIGPIPE }, + { "QUIT", SIGQUIT }, + { "SEGV", SIGSEGV }, + { "TERM", SIGTERM }, + { "USR1", SIGUSR1 }, + { "USR2", SIGUSR2 }, + { "CHLD", SIGCHLD }, + { "CONT", SIGCONT }, + { "STOP", SIGSTOP }, + { "TSTP", SIGTSTP }, + { "TTIN", SIGTTIN }, + { "TTOU", SIGTTOU } +}; + +static int parse_integer(const char *string, int *value_r) { + unsigned long ul; + char *ep; + + if (!string[0]) + return -1; + + ul= strtoul(string,&ep,10); + if (ul > INT_MAX || *ep != '\0') + return -1; + + *value_r= ul; + return 0; +} + +static int parse_signal(const char *signal_str, int *signal_nr) +{ + unsigned int i; + + if (parse_integer(signal_str, signal_nr) == 0) + return 0; + + for (i = 0; i < sizeof (siglist) / sizeof (siglist[0]); i++) { + if (strcmp (signal_str, siglist[i].name) == 0) { + *signal_nr = siglist[i].signal; + return 0; + } + } + return -1; +} + +static void +parse_schedule_item(const char *string, struct schedule_item *item) { + const char *after_hyph; + + if (!strcmp(string,"forever")) { + item->type = sched_forever; + } else if (isdigit(string[0])) { + item->type = sched_timeout; + if (parse_integer(string, &item->value) != 0) + badusage("invalid timeout value in schedule"); + } else if ((after_hyph = string + (string[0] == '-')) && + parse_signal(after_hyph, &item->value) == 0) { + item->type = sched_signal; + } else { + badusage("invalid schedule item (must be [-]<signal-name>, " + "-<signal-number>, <timeout> or `forever'"); + } +} + +static void +parse_schedule(const char *schedule_str) { + char item_buf[20]; + const char *slash; + int count, repeatat; + ptrdiff_t str_len; + + count = 0; + for (slash = schedule_str; *slash; slash++) + if (*slash == '/') + count++; + + schedule_length = (count == 0) ? 4 : count+1; + schedule = xmalloc(sizeof(*schedule) * schedule_length); + + if (count == 0) { + schedule[0].type = sched_signal; + schedule[0].value = signal_nr; + parse_schedule_item(schedule_str, &schedule[1]); + if (schedule[1].type != sched_timeout) { + badusage ("--retry takes timeout, or schedule list" + " of at least two items"); + } + schedule[2].type = sched_signal; + schedule[2].value = SIGKILL; + schedule[3]= schedule[1]; + } else { + count = 0; + repeatat = -1; + while (schedule_str != NULL) { + slash = strchr(schedule_str,'/'); + str_len = slash ? slash - schedule_str : strlen(schedule_str); + if (str_len >= (ptrdiff_t)sizeof(item_buf)) + badusage("invalid schedule item: far too long" + " (you must delimit items with slashes)"); + memcpy(item_buf, schedule_str, str_len); + item_buf[str_len] = 0; + schedule_str = slash ? slash+1 : NULL; + + parse_schedule_item(item_buf, &schedule[count]); + if (schedule[count].type == sched_forever) { + if (repeatat >= 0) + badusage("invalid schedule: `forever'" + " appears more than once"); + repeatat = count; + continue; + } + count++; + } + if (repeatat >= 0) { + schedule[count].type = sched_goto; + schedule[count].value = repeatat; + count++; + } + assert(count == schedule_length); + } +} + +static void +parse_options(int argc, char * const *argv) +{ + static struct option longopts[] = { + { "help", 0, NULL, 'H'}, + { "stop", 0, NULL, 'K'}, + { "start", 0, NULL, 'S'}, + { "version", 0, NULL, 'V'}, + { "startas", 1, NULL, 'a'}, + { "name", 1, NULL, 'n'}, + { "oknodo", 0, NULL, 'o'}, + { "pidfile", 1, NULL, 'p'}, + { "quiet", 0, NULL, 'q'}, + { "signal", 1, NULL, 's'}, + { "test", 0, NULL, 't'}, + { "user", 1, NULL, 'u'}, + { "group", 1, NULL, 'g'}, + { "chroot", 1, NULL, 'r'}, + { "verbose", 0, NULL, 'v'}, + { "exec", 1, NULL, 'x'}, + { "chuid", 1, NULL, 'c'}, + { "nicelevel", 1, NULL, 'N'}, + { "background", 0, NULL, 'b'}, + { "make-pidfile", 0, NULL, 'm'}, + { "retry", 1, NULL, 'R'}, + { "chdir", 1, NULL, 'd'}, + { NULL, 0, NULL, 0} + }; + int c; + + for (;;) { + c = getopt_long(argc, argv, "HKSV:a:n:op:qr:s:tu:vx:c:N:bmR:g:d:", + longopts, (int *) 0); + if (c == -1) + break; + switch (c) { + case 'H': /* --help */ + do_help(); + exit(0); + case 'K': /* --stop */ + stop = 1; + break; + case 'S': /* --start */ + start = 1; + break; + case 'V': /* --version */ + printf("start-stop-daemon " VERSION "\n"); + exit(0); + case 'a': /* --startas <pathname> */ + startas = optarg; + break; + case 'n': /* --name <process-name> */ + cmdname = optarg; + break; + case 'o': /* --oknodo */ + exitnodo = 0; + break; + case 'p': /* --pidfile <pid-file> */ + pidfile = optarg; + break; + case 'q': /* --quiet */ + quietmode = 1; + break; + case 's': /* --signal <signal> */ + signal_str = optarg; + break; + case 't': /* --test */ + testmode = 1; + break; + case 'u': /* --user <username>|<uid> */ + userspec = optarg; + break; + case 'v': /* --verbose */ + quietmode = -1; + break; + case 'x': /* --exec <executable> */ + execname = optarg; + break; + case 'c': /* --chuid <username>|<uid> */ + /* we copy the string just in case we need the + * argument later. */ + changeuser = strdup(optarg); + changeuser = strtok(changeuser, ":"); + changegroup = strtok(NULL, ":"); + break; + case 'g': /* --group <group>|<gid> */ + changegroup = optarg; + break; + case 'r': /* --chroot /new/root */ + changeroot = optarg; + break; + case 'N': /* --nice */ + nicelevel = atoi(optarg); + break; + case 'b': /* --background */ + background = 1; + break; + case 'm': /* --make-pidfile */ + mpidfile = 1; + break; + case 'R': /* --retry <schedule>|<timeout> */ + schedule_str = optarg; + break; + case 'd': /* --chdir /new/dir */ + changedir = optarg; + break; + default: + badusage(NULL); /* message printed by getopt */ + } + } + + if (signal_str != NULL) { + if (parse_signal (signal_str, &signal_nr) != 0) + badusage("signal value must be numeric or name" + " of signal (KILL, INT, ...)"); + } + + if (schedule_str != NULL) { + parse_schedule(schedule_str); + } + + if (start == stop) + badusage("need one of --start or --stop"); + + if (!execname && !pidfile && !userspec && !cmdname) + badusage("need at least one of --exec, --pidfile, --user or --name"); + + if (!startas) + startas = execname; + + if (start && !startas) + badusage("--start needs --exec or --startas"); + + if (mpidfile && pidfile == NULL) + badusage("--make-pidfile is only relevant with --pidfile"); + + if (background && !start) + badusage("--background is only relevant with --start"); + +} + +#if defined(OSLinux) +static int +pid_is_exec(pid_t pid, const struct stat *esb) +{ + struct stat sb; + char buf[32]; + + sprintf(buf, "/proc/%d/exe", pid); + if (stat(buf, &sb) != 0) + return 0; + return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino); +} + + +static int +pid_is_user(pid_t pid, uid_t uid) +{ + struct stat sb; + char buf[32]; + + sprintf(buf, "/proc/%d", pid); + if (stat(buf, &sb) != 0) + return 0; + return (sb.st_uid == uid); +} + + +static int +pid_is_cmd(pid_t pid, const char *name) +{ + char buf[32]; + FILE *f; + int c; + + sprintf(buf, "/proc/%d/stat", pid); + f = fopen(buf, "r"); + if (!f) + return 0; + while ((c = getc(f)) != EOF && c != '(') + ; + if (c != '(') { + fclose(f); + return 0; + } + /* this hopefully handles command names containing ')' */ + while ((c = getc(f)) != EOF && c == *name) + name++; + fclose(f); + return (c == ')' && *name == '\0'); +} +#endif /* OSLinux */ + + +#if defined(OSHURD) +static int +pid_is_user(pid_t pid, uid_t uid) +{ + struct stat sb; + char buf[32]; + struct proc_stat *pstat; + + sprintf(buf, "/proc/%d", pid); + if (stat(buf, &sb) != 0) + return 0; + return (sb.st_uid == uid); + pstat = proc_stat_list_pid_proc_stat (procset, pid); + if (pstat == NULL) + fatal ("Error getting process information: NULL proc_stat struct"); + proc_stat_set_flags (pstat, PSTAT_PID | PSTAT_OWNER_UID); + return (pstat->owner_uid == uid); +} + +static int +pid_is_cmd(pid_t pid, const char *name) +{ + struct proc_stat *pstat; + pstat = proc_stat_list_pid_proc_stat (procset, pid); + if (pstat == NULL) + fatal ("Error getting process information: NULL proc_stat struct"); + proc_stat_set_flags (pstat, PSTAT_PID | PSTAT_ARGS); + return (!strcmp (name, pstat->args)); +} +#endif /* OSHURD */ + + +static int +pid_is_running(pid_t pid) +{ + struct stat sb; + char buf[32]; + + sprintf(buf, "/proc/%d", pid); + if (stat(buf, &sb) != 0) { + if (errno!=ENOENT) + fatal("Error stating %s: %s", buf, strerror(errno)); + return 0; + } + + return 1; +} + +static void +check(pid_t pid) +{ +#if defined(OSLinux) || defined(OShpux) + if (execname && !pid_is_exec(pid, &exec_stat)) + return; +#elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin) + /* I will try this to see if it works */ + if (execname && !pid_is_cmd(pid, execname)) + return; +#endif + if (userspec && !pid_is_user(pid, user_id)) + return; + if (cmdname && !pid_is_cmd(pid, cmdname)) + return; + if (start && !pid_is_running(pid)) + return; + push(&found, pid); +} + +static void +do_pidfile(const char *name) +{ + FILE *f; + pid_t pid; + + f = fopen(name, "r"); + if (f) { + if (fscanf(f, "%d", &pid) == 1) + check(pid); + fclose(f); + } else if (errno != ENOENT) + fatal("open pidfile %s: %s", name, strerror(errno)); + +} + +/* WTA: this needs to be an autoconf check for /proc/pid existance. + */ + +#if defined(OSLinux) || defined (OSsunos) || defined(OSfreebsd) +static void +do_procinit(void) +{ + DIR *procdir; + struct dirent *entry; + int foundany; + pid_t pid; + + procdir = opendir("/proc"); + if (!procdir) + fatal("opendir /proc: %s", strerror(errno)); + + foundany = 0; + while ((entry = readdir(procdir)) != NULL) { + if (sscanf(entry->d_name, "%d", &pid) != 1) + continue; + foundany++; + check(pid); + } + closedir(procdir); + if (!foundany) + fatal("nothing in /proc - not mounted?"); +} +#endif /* OSLinux */ + + +#if defined(OSHURD) +error_t +check_all(void *ptr) +{ + struct proc_stat *pstat = ptr; + + check(pstat->pid); + return 0; +} + +static void +do_procinit(void) +{ + struct ps_context *context; + error_t err; + + err = ps_context_create(getproc(), &context); + if (err) + error(1, err, "ps_context_create"); + + err = proc_stat_list_create(context, &procset); + if (err) + error(1, err, "proc_stat_list_create"); + + err = proc_stat_list_add_all(procset, 0, 0); + if (err) + error(1, err, "proc_stat_list_add_all"); + + /* Check all pids */ + ihash_iterate(context->procs, check_all); +} +#endif /* OSHURD */ + + +#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) +static int +pid_is_cmd(pid_t pid, const char *name) +{ + kvm_t *kd; + int nentries, argv_len=0; + struct kinfo_proc *kp; + char errbuf[_POSIX2_LINE_MAX], buf[_POSIX2_LINE_MAX]; + char **pid_argv_p; + char *start_argv_0_p, *end_argv_0_p; + + + kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); + if (kd == 0) + errx(1, "%s", errbuf); + if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0) + errx(1, "%s", kvm_geterr(kd)); + if ((pid_argv_p = kvm_getargv(kd, kp, argv_len)) == 0) + errx(1, "%s", kvm_geterr(kd)); + + start_argv_0_p = *pid_argv_p; + /* find and compare string */ + + /* find end of argv[0] then copy and cut of str there. */ + if ((end_argv_0_p = strchr(*pid_argv_p, ' ')) == 0 ) + /* There seems to be no space, so we have the command + * allready in its desired form. */ + start_argv_0_p = *pid_argv_p; + else { + /* Tests indicate that this never happens, since + * kvm_getargv itselfe cuts of tailing stuff. This is + * not what the manpage says, however. */ + strncpy(buf, *pid_argv_p, (end_argv_0_p - start_argv_0_p)); + buf[(end_argv_0_p - start_argv_0_p) + 1] = '\0'; + start_argv_0_p = buf; + } + + if (strlen(name) != strlen(start_argv_0_p)) + return 0; + return (strcmp(name, start_argv_0_p) == 0) ? 1 : 0; +} + +static int +pid_is_user(pid_t pid, uid_t uid) +{ + kvm_t *kd; + int nentries; /* Value not used */ + uid_t proc_uid; + struct kinfo_proc *kp; + char errbuf[_POSIX2_LINE_MAX]; + + + kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); + if (kd == 0) + errx(1, "%s", errbuf); + if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0) + errx(1, "%s", kvm_geterr(kd)); + if (kp->ki_ruid ) + kvm_read(kd, (u_long)&(kp->ki_ruid), + &proc_uid, sizeof(uid_t)); + else + return 0; + return (proc_uid == (uid_t)uid); +} + +static int +pid_is_exec(pid_t pid, const char *name) +{ + kvm_t *kd; + int nentries; + struct kinfo_proc *kp; + char errbuf[_POSIX2_LINE_MAX], *pidexec; + + kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); + if (kd == 0) + errx(1, "%s", errbuf); + if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0) + errx(1, "%s", kvm_geterr(kd)); + pidexec = kp->ki_comm; + if (strlen(name) != strlen(pidexec)) + return 0; + return (strcmp(name, pidexec) == 0) ? 1 : 0; +} + + +static void +do_procinit(void) +{ + /* Nothing to do */ +} + +#endif /* OSOpenBSD */ + +#if defined(OSDarwin) +int +pid_is_user(pid_t pid, uid_t uid) +{ + int mib[4]; + size_t size; + struct kinfo_proc ki; + + size = sizeof(ki); + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = pid; + if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0) + errx(1, "%s", "Failure calling sysctl"); + return (uid == ki.kp_eproc.e_pcred.p_ruid); +} + +static int +pid_is_cmd(pid_t pid, const char *name) +{ + int mib[4]; + size_t size; + struct kinfo_proc ki; + + size = sizeof(ki); + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = pid; + if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0) + errx(1, "%s", "Failure calling sysctl"); + return (!strncmp(name, ki.kp_proc.p_comm, MAXCOMLEN)); +} + +static void +do_procinit(void) +{ + int mib[3]; + size_t size; + int nprocs, ret, i; + struct kinfo_proc *procs = NULL, *newprocs; + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_ALL; + ret = sysctl(mib, 3, NULL, &size, NULL, 0); + /* Allocate enough memory for entire process table */ + do { + size += size / 10; + newprocs = realloc(procs, size); + if (newprocs == NULL) { + if (procs) + free(procs); + errx(1, "%s", "Could not reallocate memory"); + } + procs = newprocs; + ret = sysctl(mib, 3, procs, &size, NULL, 0); + } while (ret >= 0 && errno == ENOMEM); + + if (ret < 0) + errx(1, "%s", "Failure calling sysctl"); + + /* Verify size of proc structure */ + if (size % sizeof(struct kinfo_proc) != 0) + errx(1, "%s", "proc size mismatch, userland out of sync with kernel"); + nprocs = size / sizeof(struct kinfo_proc); + for (i = 0; i < nprocs; i++) { + check(procs[i].kp_proc.p_pid); + } +} +#endif /* OSDarwin */ +#if defined(OShpux) +static int +pid_is_user(pid_t pid, uid_t uid) +{ + struct pst_status pst; + + if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0) + return 0; + return ((uid_t) pst.pst_uid == uid); +} + +static int +pid_is_cmd(pid_t pid, const char *name) +{ + struct pst_status pst; + + if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0) + return 0; + return (strcmp(pst.pst_ucomm, name) == 0); +} + +static int +pid_is_exec(pid_t pid, const struct stat *esb) +{ + struct pst_status pst; + + if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0) + return 0; + return ((dev_t) pst.pst_text.psf_fsid.psfs_id == esb->st_dev + && (ino_t) pst.pst_text.psf_fileid == esb->st_ino); +} + +static void +do_procinit(void) +{ + struct pst_status pst[10]; + int i, count; + int idx = 0; + + while ((count = pstat_getproc(pst, sizeof(pst[0]), 10, idx)) > 0) { + for (i = 0; i < count; i++) + check(pst[i].pst_pid); + idx = pst[count - 1].pst_idx + 1; + } +} +#endif /* OShpux */ + + +static void +do_findprocs(void) +{ + clear(&found); + + if (pidfile) + do_pidfile(pidfile); + else + do_procinit(); +} + +/* return 1 on failure */ +static void +do_stop(int signal_nr, int quietmode, int *n_killed, int *n_notkilled, int retry_nr) +{ + struct pid_list *p; + + do_findprocs(); + + *n_killed = 0; + *n_notkilled = 0; + + if (!found) + return; + + clear(&killed); + + for (p = found; p; p = p->next) { + if (testmode) { + printf("Would send signal %d to %d.\n", + signal_nr, p->pid); + (*n_killed)++; + } else if (kill(p->pid, signal_nr) == 0) { + push(&killed, p->pid); + (*n_killed)++; + } else { + printf("%s: warning: failed to kill %d: %s\n", + progname, p->pid, strerror(errno)); + (*n_notkilled)++; + } + } + if (quietmode < 0 && killed) { + printf("Stopped %s (pid", what_stop); + for (p = killed; p; p = p->next) + printf(" %d", p->pid); + putchar(')'); + if (retry_nr > 0) + printf(", retry #%d", retry_nr); + printf(".\n"); + } +} + + +static void +set_what_stop(const char *str) +{ + strncpy(what_stop, str, sizeof(what_stop)); + what_stop[sizeof(what_stop)-1] = '\0'; +} + +static int +run_stop_schedule(void) +{ + int r, position, n_killed, n_notkilled, value, ratio, anykilled, retry_nr; + struct timeval stopat, before, after, interval, maxinterval; + + if (testmode) { + if (schedule != NULL) { + printf("Ignoring --retry in test mode\n"); + schedule = NULL; + } + } + + if (cmdname) + set_what_stop(cmdname); + else if (execname) + set_what_stop(execname); + else if (pidfile) + sprintf(what_stop, "process in pidfile `%.200s'", pidfile); + else if (userspec) + sprintf(what_stop, "process(es) owned by `%.200s'", userspec); + else + fatal("internal error, please report"); + + anykilled = 0; + retry_nr = 0; + + if (schedule == NULL) { + do_stop(signal_nr, quietmode, &n_killed, &n_notkilled, 0); + if (n_notkilled > 0 && quietmode <= 0) + printf("%d pids were not killed\n", n_notkilled); + if (n_killed) + anykilled = 1; + goto x_finished; + } + + for (position = 0; position < schedule_length; ) { + value= schedule[position].value; + n_notkilled = 0; + + switch (schedule[position].type) { + + case sched_goto: + position = value; + continue; + + case sched_signal: + do_stop(value, quietmode, &n_killed, &n_notkilled, retry_nr++); + if (!n_killed) + goto x_finished; + else + anykilled = 1; + goto next_item; + + case sched_timeout: + /* We want to keep polling for the processes, to see if they've exited, + * or until the timeout expires. + * + * This is a somewhat complicated algorithm to try to ensure that we + * notice reasonably quickly when all the processes have exited, but + * don't spend too much CPU time polling. In particular, on a fast + * machine with quick-exiting daemons we don't want to delay system + * shutdown too much, whereas on a slow one, or where processes are + * taking some time to exit, we want to increase the polling + * interval. + * + * The algorithm is as follows: we measure the elapsed time it takes + * to do one poll(), and wait a multiple of this time for the next + * poll. However, if that would put us past the end of the timeout + * period we wait only as long as the timeout period, but in any case + * we always wait at least MIN_POLL_INTERVAL (20ms). The multiple + * (`ratio') starts out as 2, and increases by 1 for each poll to a + * maximum of 10; so we use up to between 30% and 10% of the + * machine's resources (assuming a few reasonable things about system + * performance). + */ + xgettimeofday(&stopat); + stopat.tv_sec += value; + ratio = 1; + for (;;) { + xgettimeofday(&before); + if (timercmp(&before,&stopat,>)) + goto next_item; + + do_stop(0, 1, &n_killed, &n_notkilled, 0); + if (!n_killed) + goto x_finished; + + xgettimeofday(&after); + + if (!timercmp(&after,&stopat,<)) + goto next_item; + + if (ratio < 10) + ratio++; + + TVCALC(interval, ratio * (TVELEM(&after) - TVELEM(&before) + TVADJUST)); + TVCALC(maxinterval, TVELEM(&stopat) - TVELEM(&after) + TVADJUST); + + if (timercmp(&interval,&maxinterval,>)) + interval = maxinterval; + + if (interval.tv_sec == 0 && + interval.tv_usec <= MIN_POLL_INTERVAL) + interval.tv_usec = MIN_POLL_INTERVAL; + + r = select(0,0,0,0,&interval); + if (r < 0 && errno != EINTR) + fatal("select() failed for pause: %s", + strerror(errno)); + } + + default: + assert(!"schedule[].type value must be valid"); + + } + + next_item: + position++; + } + + if (quietmode <= 0) + printf("Program %s, %d process(es), refused to die.\n", + what_stop, n_killed); + + return 2; + +x_finished: + if (!anykilled) { + if (quietmode <= 0) + printf("No %s found running; none killed.\n", what_stop); + return exitnodo; + } else { + return 0; + } +} + + +int main(int argc, char **argv) NONRETURNING; +int +main(int argc, char **argv) +{ + int devnull_fd = -1; +#ifdef HAVE_TIOCNOTTY + int tty_fd = -1; +#endif + progname = argv[0]; + + parse_options(argc, argv); + argc -= optind; + argv += optind; + + if (execname && stat(execname, &exec_stat)) + fatal("stat %s: %s", execname, strerror(errno)); + + if (userspec && sscanf(userspec, "%d", &user_id) != 1) { + struct passwd *pw; + + pw = getpwnam(userspec); + if (!pw) + fatal("user `%s' not found\n", userspec); + + user_id = pw->pw_uid; + } + + if (changegroup && sscanf(changegroup, "%d", &runas_gid) != 1) { + struct group *gr = getgrnam(changegroup); + if (!gr) + fatal("group `%s' not found\n", changegroup); + runas_gid = gr->gr_gid; + } + if (changeuser && sscanf(changeuser, "%d", &runas_uid) != 1) { + struct passwd *pw = getpwnam(changeuser); + if (!pw) + fatal("user `%s' not found\n", changeuser); + runas_uid = pw->pw_uid; + if (changegroup == NULL) { /* pass the default group of this user */ + changegroup = ""; /* just empty */ + runas_gid = pw->pw_gid; + } + } + + if (stop) { + int i = run_stop_schedule(); + exit(i); + } + + do_findprocs(); + + if (found) { + if (quietmode <= 0) + printf("%s already running.\n", execname ? execname : "process"); + exit(exitnodo); + } + if (testmode) { + printf("Would start %s ", startas); + while (argc-- > 0) + printf("%s ", *argv++); + if (changeuser != NULL) { + printf(" (as user %s[%d]", changeuser, runas_uid); + if (changegroup != NULL) + printf(", and group %s[%d])", changegroup, runas_gid); + else + printf(")"); + } + if (changeroot != NULL) + printf(" in directory %s", changeroot); + if (nicelevel) + printf(", and add %i to the priority", nicelevel); + printf(".\n"); + exit(0); + } + if (quietmode < 0) + printf("Starting %s...\n", startas); + *--argv = startas; + if (background) { /* ok, we need to detach this process */ + int i; + if (quietmode < 0) + printf("Detatching to start %s...", startas); + i = fork(); + if (i<0) { + fatal("Unable to fork.\n"); + } + if (i) { /* parent */ + if (quietmode < 0) + printf("done.\n"); + exit(0); + } + /* child continues here */ + +#ifdef HAVE_TIOCNOTTY + tty_fd=open("/dev/tty", O_RDWR); +#endif + devnull_fd=open("/dev/null", O_RDWR); + } + if (nicelevel) { + errno=0; + if ((nice(nicelevel)==-1) && (errno!=0)) + fatal("Unable to alter nice level by %i: %s", nicelevel, + strerror(errno)); + } + if (mpidfile && pidfile != NULL) { /* user wants _us_ to make the pidfile :) */ + FILE *pidf = fopen(pidfile, "w"); + pid_t pidt = getpid(); + if (pidf == NULL) + fatal("Unable to open pidfile `%s' for writing: %s", pidfile, + strerror(errno)); + fprintf(pidf, "%d\n", pidt); + fclose(pidf); + } + if (changeroot != NULL) { + if (chdir(changeroot) < 0) + fatal("Unable to chdir() to %s", changeroot); + if (chroot(changeroot) < 0) + fatal("Unable to chroot() to %s", changeroot); + } + if (changedir != NULL && chdir(changedir) < 0) + fatal("Unable to chdir() to %s", changedir); + if (changeuser != NULL) { + if (setgid(runas_gid)) + fatal("Unable to set gid to %d", runas_gid); + if (initgroups(changeuser, runas_gid)) + fatal("Unable to set initgroups() with gid %d", runas_gid); + if (setuid(runas_uid)) + fatal("Unable to set uid to %s", changeuser); + } + if (background) { /* continue background setup */ + int i; +#ifdef HAVE_TIOCNOTTY + /* change tty */ + ioctl(tty_fd, TIOCNOTTY, 0); + close(tty_fd); +#endif + umask(022); /* set a default for dumb programs */ + dup2(devnull_fd,0); /* stdin */ + dup2(devnull_fd,1); /* stdout */ + dup2(devnull_fd,2); /* stderr */ +#if defined(OShpux) + /* now close all extra fds */ + for (i=sysconf(_SC_OPEN_MAX)-1; i>=3; --i) close(i); +#else + /* now close all extra fds */ + for (i=getdtablesize()-1; i>=3; --i) close(i); +#endif + + /* create a new session */ +#ifdef HAVE_SETSID + setsid(); +#else + setpgid(0,0); +#endif + } + execv(startas, argv); + fatal("Unable to start %s: %s", startas, strerror(errno)); +} + diff --git a/subdir_dev b/subdir_dev new file mode 100644 index 0000000..01b9dcc --- /dev/null +++ b/subdir_dev @@ -0,0 +1,12 @@ +#!/bin/sh + +# scripts that moves devices to the $1/ subdir. + +if [ "$ACTION" = remove ] ; then + mv $1/$MDEV $MDEV + rmdir $1 2>/dev/null +else + mkdir -p $1 + mv $MDEV $1 +fi + diff --git a/sysctl.conf b/sysctl.conf new file mode 100644 index 0000000..881da1f --- /dev/null +++ b/sysctl.conf @@ -0,0 +1,6 @@ +net.ipv4.ip_forward = 0 +net.ipv4.tcp_syncookies = 1 +net.ipv4.conf.default.rp_filter = 1 +net.ipv4.conf.all.rp_filter = 1 + +kernel.grsecurity.rand_pids = 1 @@ -0,0 +1,17 @@ +#!/bin/sh + +# try to load the proper driver for usb devices +case "$ACTION" in + add|"") + for i in /sys/class/usb_device/$MDEV/device/*/modalias ; do + modprobe `cat $i` 2>/dev/null + done + ;; + remove) + for i in /sys/class/usb_device/$MDEV/device/*/modalias ; do + modprobe -r `cat $i` 2>/dev/null + done +esac + +# we dont want the ugly usbdev[0-9].[0-9] dev. +rm -f $MDEV |