VirtualBox

Changeset 36626 in vbox


Ignore:
Timestamp:
Apr 8, 2011 3:31:31 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71081
Message:

Installer/linux: fix quoting in the Additions auto-installer

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/installer/autorun.sh

    r36518 r36626  
    11#!/bin/sh
    22#
    3 # VirtualBox Guest Additions installation script for Linux
     3# VirtualBox Guest Additions installation script for *nix guests
    44#
    55
     
    1717
    1818PATH=$PATH:/bin:/sbin:/usr/sbin
     19
     20# Deal with differing "which" semantics
     21mywhich() {
     22    which "$1" 2>/dev/null | grep -v "no $1"
     23}
     24
     25# Get the name and execute switch for a useful terminal emulator
     26#
     27# Sets $gxtpath to the emulator path or empty
     28# Sets $gxttitle to the "title" switch for that emulator
     29# Sets $gxtexec to the "execute" switch for that emulator
     30# May clobber $gtx*
     31# Calls mywhich
     32getxterm() {
     33    # gnome-terminal uses -e differently to other emulators
     34    for gxti in "gnome-terminal --title -x" "konsole --title -e" "xterm -T -e"; do
     35        set $gxti
     36        gxtpath="`mywhich $1`"
     37        case "$gxtpath" in ?*)
     38            gxttitle=$2
     39            gxtexec=$3
     40            return
     41            ;;
     42        esac
     43    done
     44}
     45
     46# Quotes its argument by inserting '\' in front of every character save
     47# for 'A-Za-z0-9/'.  Prints the result to stdout.
     48quotify() {
     49    echo "$1" | sed -e 's/\([^a-zA-Z0-9/]\)/\\\1/g'
     50}
    1951
    2052ostype=`uname -s`
     
    4476        "$path/VBoxLinuxAdditions-$arch.run"; do
    4577        if test -f "$i"; then
    46             exec /bin/sh "$path/runasroot.sh" \
    47                 "VirtualBox Guest Additions installation" "$i" \
    48                 "Please try running $i manually."
     78            getxterm
     79            case "$gxtpath" in ?*)
     80                TITLE="VirtualBox Guest Additions installation"
     81                TITLE_QUOTED=`quotify "$TITLE"`
     82                BINARY=`quotify $i`
     83                exec /bin/sh "$path/runasroot.sh" \
     84                    "$TITLE" \
     85                    "$gxtpath $gxttitle $TITLE_QUOTED $gxtexec $BINARY --xwin" \
     86                    "Please try running $i manually."
     87                exit
     88                ;;
     89            esac
    4990        fi
    5091    done
  • trunk/src/VBox/Installer/linux/runasroot.sh

    r36542 r36626  
    1616#
    1717
    18 # Deal with differing "which" semantics on Linux and Solaris
     18# Deal with differing "which" semantics
    1919mywhich() {
    20     which "$1" | grep -v "no $1"
     20    which "$1" 2>/dev/null | grep -v "no $1"
     21}
     22
     23# Get the name and execute switch for a useful terminal emulator
     24#
     25# Sets $gxtpath to the emulator path or empty
     26# Sets $gxttitle to the "title" switch for that emulator
     27# Sets $gxtexec to the "execute" switch for that emulator
     28# May clobber $gtx*
     29# Calls mywhich
     30getxterm() {
     31    # gnome-terminal uses -e differently to other emulators
     32    for gxti in "gnome-terminal --title -x" "konsole --title -e" "xterm -T -e"; do
     33        set $gxti
     34        gxtpath="`mywhich $1`"
     35        case "$gxtpath" in ?*)
     36            gxttitle=$2
     37            gxtexec=$3
     38            return
     39            ;;
     40        esac
     41    done
     42}
     43
     44# Quotes its argument by inserting '\' in front of every character save
     45# for 'A-Za-z0-9/'.  Prints the result to stdout.
     46quotify() {
     47    echo $1 | sed -e 's/\([^a-zA-Z0-9/]\)/\\\1/g'
    2148}
    2249
     
    5582    KDESUDO="`mywhich kdesudo`"
    5683    case "$KDESUDO" in ?*)
    57         eval "\"$KDESUDO\" --comment \"$DESCRIPTION\" -- $COMMAND"
     84        eval "`quotify "$KDESUDO"` --comment `quotify "$DESCRIPTION"` -- $COMMAND"
    5885        exit
    5986        ;;
     
    88115    SU="`mywhich su`"
    89116    case "$SU" in ?*)
    90         GNOME_TERMINAL="`mywhich gnome-terminal`"
    91         case "$GNOME_TERMINAL" in ?*)
    92             "$GNOME_TERMINAL" --title "$DESCRIPTION - su" -x su - root -c "$COMMAND"
     117        getxterm
     118        case "$gxtpath" in ?*)
     119            "$gxtpath" "$gxttitle" "$DESCRIPTION - su" "$gxtexec" su - root -c "$COMMAND"
    93120            exit
    94121            ;;
    95122        esac
    96         XTERM="`mywhich xterm`"
    97         case "$XTERM" in ?*)
    98             "$XTERM" -T "$DESCRIPTION - su" -e su - root -c "$COMMAND"
    99             exit
    100             ;;
    101         esac
    102         ;;
    103123    esac
    104124esac # $DISPLAY
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette