aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xvirtme/guest/virtme-init15
1 files changed, 14 insertions, 1 deletions
diff --git a/virtme/guest/virtme-init b/virtme/guest/virtme-init
index c2860ae..07833ec 100755
--- a/virtme/guest/virtme-init
+++ b/virtme/guest/virtme-init
@@ -19,7 +19,10 @@ mount -t sysfs -o nosuid,noexec,nodev sys /sys/
declare -A mount_tags
for i in /sys/bus/virtio/drivers/9pnet_virtio/virtio*/mount_tag; do
- mount_tags["`cat "$i"`"]=1
+ # mount_tag is terminated with a NUL byte, which leads to a
+ # "command substitution: ignored null byte in input" warning from
+ # bash; use sed instead of a bare 'cat' here to strip it off.
+ mount_tags["`sed '$s/\x00$//;' "$i"`"]=1
done
kver="`uname -r`"
@@ -122,6 +125,16 @@ mkdir -p -m 0755 /dev/shm /dev/pts
mount -t devpts -o gid=tty,mode=620,noexec,nosuid devpts /dev/pts
mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm
+# Install /proc/self/fd symlinks into /dev if not already present
+declare -r -A fdlinks=(["/dev/fd"]="/proc/self/fd"
+ ["/dev/stdin"]="/proc/self/fd/0"
+ ["/dev/stdout"]="/proc/self/fd/1"
+ ["/dev/stderr"]="/proc/self/fd/2")
+
+for p in "${!fdlinks[@]}"; do
+ [[ -e "$p" ]] || ln -s "${fdlinks[$p]}" "$p"
+done
+
# Bring up networking
ip link set dev lo up