summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2010-08-22 16:30:24 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2010-08-22 16:30:24 +0200
commit74a4ddc5a50cb93f15733626982731f522585506 (patch)
tree348ea06297f408e5b20cb5e59815e97279304920
parent1c59956cf90a8b855b09c02cd6a5d6c96b106bf5 (diff)
Better parse kernel command line to only keep proper variable names
-rwxr-xr-xdebian/local/runsystem36
1 files changed, 20 insertions, 16 deletions
diff --git a/debian/local/runsystem b/debian/local/runsystem
index 028ee2ef..150d4c9c 100755
--- a/debian/local/runsystem
+++ b/debian/local/runsystem
@@ -24,22 +24,26 @@ echo "Console started."
# Set the console device used by /sbin/reopen-console
echo /dev/tty1 >/var/run/console-device
-export TERM=hurd
-
-# Preset the terminal type for /lib/debian-installer/detect-console
-export TERM_TYPE=virtual
-
-# Export kernel parameters into environment, like Linux does.
-for i in $*
-do
- var=$(echo $i | sed "s/=.*$//")
- [ $var != $i ] || continue
- [ $var != root ] || continue
- val=$(echo $i | sed "s/^$var=//")
- echo $var is $val
- eval export $var=\$val
-done
+# Get all kernel parameters that can be exported as environment variables
+envvars="$(echo $* | tr ' ' '\012' | egrep '^[-_/[:alnum:]]+=.*$')"
# Invoke init as linuxrc to work around pid != 1
-exec /bin/busybox linuxrc
+init='/bin/busybox linuxrc'
+
+# Parse kernel parameters
+for i in $envvars ; do
+ case "$i" in
+ init="/sbin/init"|init="init")
+ # Avoid endless loop
+ : ;;
+ init=*)
+ init=${i#init=}
+ ;;
+ noshell=*)
+ sed -i '/^tty[12]/s/^/#/' /etc/inittab
+ ;;
+ esac
+done
+# Preset the terminal type for /lib/debian-installer/detect-console
+eval exec env - $envvars TERM=hurd TERM_TYPE=virtual $init