From 76551e02edb51a0638762a8b0e6cea0976b5d85e Mon Sep 17 00:00:00 2001 From: Jason Wessel Date: Wed, 2 May 2012 06:30:46 -0500 Subject: 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 Signed-off-by: Richard Purdie --- scripts/runqemu-ifup | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'scripts/runqemu-ifup') 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 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. usage() { - echo "sudo $(basename $0) " + echo "sudo $(basename $0) " } if [ $EUID -ne 0 ]; then @@ -42,13 +42,14 @@ if [ $EUID -ne 0 ]; then exit 1 fi -if [ $# -ne 2 ]; then +if [ $# -ne 3 ]; then usage exit 1 fi -GROUP="-g $1" -NATIVE_SYSROOT_DIR=$2 +USERID="-u $1" +GROUP="-g $2" +NATIVE_SYSROOT_DIR=$3 TUNCTL=$NATIVE_SYSROOT_DIR/usr/bin/tunctl if [ ! -x "$TUNCTL" ]; then @@ -59,9 +60,14 @@ fi TAP=`$TUNCTL -b $GROUP 2>&1` STATUS=$? if [ $STATUS -ne 0 ]; then - echo "tunctl failed:" - echo $TAP - exit 1 +# If tunctl -g fails, try using tunctl -u, for older host kernels +# which do not support the TUNSETGROUP ioctl + TAP=`$TUNCTL -b $USERID 2>&1` + STATUS=$? + if [ $STATUS -ne 0 ]; then + echo "tunctl failed:" + exit 1 + fi fi IFCONFIG=`which ifconfig 2> /dev/null` -- cgit v1.2.3-54-g00ecf