diff options
Diffstat (limited to 'scripts/runqemu-ifup')
-rwxr-xr-x | scripts/runqemu-ifup | 20 |
1 files changed, 13 insertions, 7 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` |