diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2012-05-02 06:30:46 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-05-03 15:48:09 +0100 |
commit | 76551e02edb51a0638762a8b0e6cea0976b5d85e (patch) | |
tree | 204a0b02b62600e2bac0e9701f1e12ffc816d014 /scripts | |
parent | e8005eb9360070aef131c74e17bc7ca3f070053d (diff) | |
download | poky-76551e02edb51a0638762a8b0e6cea0976b5d85e.tar.gz |
runqemu: Fix TAP='TUNSETGROUP: Invalid argument' by falling back to tunctl -u
By default the runqemu script tries to set the group permissions on any
tap device it creates. The TUNSETGROUP ioctl is not implemented on some
popular host enterprise linux distributions.
Internally the script will exit as follows:
++ /opt/qemux86/bitbake_build/tmp/sysroots/x86_64-linux/usr/bin/tunctl -b -g 100
+ TAP='TUNSETGROUP: Invalid argument'
+ STATUS=1
+ '[' 1 -ne 0 ']'
+ echo 'tunctl failed:'
tunctl failed:
+ echo TUNSETGROUP: Invalid argument
This patch implements a fallback to using the userid as the owner of
the tap device which is supported by all 2.6 kernels, the default remains
to try and use the groupid first.
(From OE-Core rev: 3af2bc59776fb738bd795160512a2f3f49ce6d32)
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/runqemu-ifup | 20 | ||||
-rwxr-xr-x | scripts/runqemu-internal | 5 |
2 files changed, 16 insertions, 9 deletions
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup index f80538f53c..e4c3dafeef 100755 --- a/scripts/runqemu-ifup +++ b/scripts/runqemu-ifup | |||
@@ -34,7 +34,7 @@ | |||
34 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 34 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
35 | 35 | ||
36 | usage() { | 36 | usage() { |
37 | echo "sudo $(basename $0) <gid> <native-sysroot-basedir>" | 37 | echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir>" |
38 | } | 38 | } |
39 | 39 | ||
40 | if [ $EUID -ne 0 ]; then | 40 | if [ $EUID -ne 0 ]; then |
@@ -42,13 +42,14 @@ if [ $EUID -ne 0 ]; then | |||
42 | exit 1 | 42 | exit 1 |
43 | fi | 43 | fi |
44 | 44 | ||
45 | if [ $# -ne 2 ]; then | 45 | if [ $# -ne 3 ]; then |
46 | usage | 46 | usage |
47 | exit 1 | 47 | exit 1 |
48 | fi | 48 | fi |
49 | 49 | ||
50 | GROUP="-g $1" | 50 | USERID="-u $1" |
51 | NATIVE_SYSROOT_DIR=$2 | 51 | GROUP="-g $2" |
52 | NATIVE_SYSROOT_DIR=$3 | ||
52 | 53 | ||
53 | TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl | 54 | TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl |
54 | if [ ! -x "$TUNCTL" ]; then | 55 | if [ ! -x "$TUNCTL" ]; then |
@@ -59,9 +60,14 @@ fi | |||
59 | TAP=`$TUNCTL -b $GROUP 2>&1` | 60 | TAP=`$TUNCTL -b $GROUP 2>&1` |
60 | STATUS=$? | 61 | STATUS=$? |
61 | if [ $STATUS -ne 0 ]; then | 62 | if [ $STATUS -ne 0 ]; then |
62 | echo "tunctl failed:" | 63 | # If tunctl -g fails, try using tunctl -u, for older host kernels |
63 | echo $TAP | 64 | # which do not support the TUNSETGROUP ioctl |
64 | exit 1 | 65 | TAP=`$TUNCTL -b $USERID 2>&1` |
66 | STATUS=$? | ||
67 | if [ $STATUS -ne 0 ]; then | ||
68 | echo "tunctl failed:" | ||
69 | exit 1 | ||
70 | fi | ||
65 | fi | 71 | fi |
66 | 72 | ||
67 | IFCONFIG=`which ifconfig 2> /dev/null` | 73 | IFCONFIG=`which ifconfig 2> /dev/null` |
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal index 1831a098c6..fb0d80660f 100755 --- a/scripts/runqemu-internal +++ b/scripts/runqemu-internal | |||
@@ -173,13 +173,14 @@ if [ "$TAP" = "" ]; then | |||
173 | fi | 173 | fi |
174 | 174 | ||
175 | GROUPID=`id -g` | 175 | GROUPID=`id -g` |
176 | USERID=`id -u` | ||
176 | echo "Setting up tap interface under sudo" | 177 | echo "Setting up tap interface under sudo" |
177 | # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded | 178 | # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded |
178 | # but inactive. This looks scary but is harmless | 179 | # but inactive. This looks scary but is harmless |
179 | tap=`sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null` | 180 | tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null` |
180 | if [ $? -ne 0 ]; then | 181 | if [ $? -ne 0 ]; then |
181 | # Re-run standalone to see verbose errors | 182 | # Re-run standalone to see verbose errors |
182 | sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT | 183 | sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT |
183 | return | 184 | return |
184 | fi | 185 | fi |
185 | LOCKFILE="$LOCKDIR/$tap" | 186 | LOCKFILE="$LOCKDIR/$tap" |