* [PATCH] runqemu: Fix TAP='TUNSETGROUP: Invalid argument' by falling back to tunctl -u
@ 2012-05-02 11:30 Jason Wessel
2012-05-02 15:54 ` Scott Garman
0 siblings, 1 reply; 4+ messages in thread
From: Jason Wessel @ 2012-05-02 11:30 UTC (permalink / raw)
To: Openembedded-core
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.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
scripts/runqemu-ifup | 20 +++++++++++++-------
scripts/runqemu-internal | 5 +++--
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index f80538f..e4c3daf 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) <gid> <native-sysroot-basedir>"
+ echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir>"
}
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`
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 1831a09..fb0d806 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -173,13 +173,14 @@ if [ "$TAP" = "" ]; then
fi
GROUPID=`id -g`
+ USERID=`id -u`
echo "Setting up tap interface under sudo"
# Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded
# but inactive. This looks scary but is harmless
- tap=`sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
+ tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
if [ $? -ne 0 ]; then
# Re-run standalone to see verbose errors
- sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT
+ sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
return
fi
LOCKFILE="$LOCKDIR/$tap"
--
1.6.6.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] runqemu: Fix TAP='TUNSETGROUP: Invalid argument' by falling back to tunctl -u
2012-05-02 11:30 [PATCH] runqemu: Fix TAP='TUNSETGROUP: Invalid argument' by falling back to tunctl -u Jason Wessel
@ 2012-05-02 15:54 ` Scott Garman
0 siblings, 0 replies; 4+ messages in thread
From: Scott Garman @ 2012-05-02 15:54 UTC (permalink / raw)
To: openembedded-core
On 05/02/2012 04:30 AM, Jason Wessel wrote:
> 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.
Thanks for this, looks good to me without having done any testing on it.
Acked-by: Scott Garman <scott.a.garman@intel.com>
>
> 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.
>
> Signed-off-by: Jason Wessel<jason.wessel@windriver.com>
> ---
> scripts/runqemu-ifup | 20 +++++++++++++-------
> scripts/runqemu-internal | 5 +++--
> 2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
> index f80538f..e4c3daf 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)<gid> <native-sysroot-basedir>"
> + echo "sudo $(basename $0)<uid> <gid> <native-sysroot-basedir>"
> }
>
> 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`
> diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
> index 1831a09..fb0d806 100755
> --- a/scripts/runqemu-internal
> +++ b/scripts/runqemu-internal
> @@ -173,13 +173,14 @@ if [ "$TAP" = "" ]; then
> fi
>
> GROUPID=`id -g`
> + USERID=`id -u`
> echo "Setting up tap interface under sudo"
> # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded
> # but inactive. This looks scary but is harmless
> - tap=`sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
> + tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
> if [ $? -ne 0 ]; then
> # Re-run standalone to see verbose errors
> - sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT
> + sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
> return
> fi
> LOCKFILE="$LOCKDIR/$tap"
--
Scott Garman
Embedded Linux Engineer - Yocto Project
Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] runqemu: Fix TAP='TUNSETGROUP: Invalid argument' by falling back to tunctl -u
@ 2012-05-02 14:24 Jason Wessel
2012-05-03 20:07 ` Saul Wold
0 siblings, 1 reply; 4+ messages in thread
From: Jason Wessel @ 2012-05-02 14:24 UTC (permalink / raw)
To: Openembedded-core
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.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
scripts/runqemu-ifup | 20 +++++++++++++-------
scripts/runqemu-internal | 5 +++--
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index f80538f..e4c3daf 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) <gid> <native-sysroot-basedir>"
+ echo "sudo $(basename $0) <uid> <gid> <native-sysroot-basedir>"
}
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`
diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
index 1831a09..fb0d806 100755
--- a/scripts/runqemu-internal
+++ b/scripts/runqemu-internal
@@ -173,13 +173,14 @@ if [ "$TAP" = "" ]; then
fi
GROUPID=`id -g`
+ USERID=`id -u`
echo "Setting up tap interface under sudo"
# Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded
# but inactive. This looks scary but is harmless
- tap=`sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
+ tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
if [ $? -ne 0 ]; then
# Re-run standalone to see verbose errors
- sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT
+ sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
return
fi
LOCKFILE="$LOCKDIR/$tap"
--
1.6.6.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] runqemu: Fix TAP='TUNSETGROUP: Invalid argument' by falling back to tunctl -u
2012-05-02 14:24 Jason Wessel
@ 2012-05-03 20:07 ` Saul Wold
0 siblings, 0 replies; 4+ messages in thread
From: Saul Wold @ 2012-05-03 20:07 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On 05/02/2012 07:24 AM, Jason Wessel wrote:
> 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.
>
> Signed-off-by: Jason Wessel<jason.wessel@windriver.com>
> ---
> scripts/runqemu-ifup | 20 +++++++++++++-------
> scripts/runqemu-internal | 5 +++--
> 2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
> index f80538f..e4c3daf 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)<gid> <native-sysroot-basedir>"
> + echo "sudo $(basename $0)<uid> <gid> <native-sysroot-basedir>"
> }
>
> 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`
> diff --git a/scripts/runqemu-internal b/scripts/runqemu-internal
> index 1831a09..fb0d806 100755
> --- a/scripts/runqemu-internal
> +++ b/scripts/runqemu-internal
> @@ -173,13 +173,14 @@ if [ "$TAP" = "" ]; then
> fi
>
> GROUPID=`id -g`
> + USERID=`id -u`
> echo "Setting up tap interface under sudo"
> # Redirect stderr since we could see a LD_PRELOAD warning here if pseudo is loaded
> # but inactive. This looks scary but is harmless
> - tap=`sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
> + tap=`sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT 2> /dev/null`
> if [ $? -ne 0 ]; then
> # Re-run standalone to see verbose errors
> - sudo $QEMUIFUP $GROUPID $OECORE_NATIVE_SYSROOT
> + sudo $QEMUIFUP $USERID $GROUPID $OECORE_NATIVE_SYSROOT
> return
> fi
> LOCKFILE="$LOCKDIR/$tap"
Merged into OE-Core
Thanks
Sau!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-03 20:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-02 11:30 [PATCH] runqemu: Fix TAP='TUNSETGROUP: Invalid argument' by falling back to tunctl -u Jason Wessel
2012-05-02 15:54 ` Scott Garman
-- strict thread matches above, loose matches on Subject: below --
2012-05-02 14:24 Jason Wessel
2012-05-03 20:07 ` Saul Wold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox