Index: /trunk/src/VBox/Additions/linux/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/linux/Makefile.kmk	(revision 44079)
+++ /trunk/src/VBox/Additions/linux/Makefile.kmk	(revision 44080)
@@ -126,5 +126,6 @@
 
 VBOX_ADD_STRIP_SBIN += \
-	VBoxService
+	VBoxService \
+	$(if $(VBOX_WITH_LIGHTDM_GREETER),vbox-greeter)
 
 VBOX_ADD_STRIP_LIB += \
@@ -336,5 +337,4 @@
 	$(QUIET)$(CP) -RPf -- $< $@
 
-
 INSTALLS += GuestDrivers-src
 GuestDrivers-src_INST = $(INST_ADDITIONS)src/
@@ -358,5 +358,6 @@
 	$(VBOX_REL_X11_ADD_INST)vboxvideo.ids \
 	selinux-fedora/vbox_x11.pp \
-	selinux-fedora/vbox_accel.pp
+	selinux-fedora/vbox_accel.pp \
+    $(if $(VBOX_WITH_LIGHTDM_GREETER),lightdm-greeter/vbox-greeter.desktop)
 
 INSTALLS += lnx_add_inst-license
Index: /trunk/src/VBox/Additions/linux/installer/deffiles
===================================================================
--- /trunk/src/VBox/Additions/linux/installer/deffiles	(revision 44079)
+++ /trunk/src/VBox/Additions/linux/installer/deffiles	(revision 44080)
@@ -26,4 +26,5 @@
     /usr/bin/VBoxClient \
     /usr/bin/VBoxControl \
+    /usr/sbin/vbox-greeter \
     /usr/sbin/vboxadd-timesync \
     /usr/sbin/vboxadd-service \
@@ -44,4 +45,5 @@
     /usr/lib/VBoxOGL.so \
     /usr/lib64/VBoxOGL.so \
+    /usr/share/xgreeters/vbox-greeter.desktop \
     /etc/X11/Xsession.d/98vboxadd-xclient \
     /etc/X11/xinit.d/98vboxadd-xclient \
Index: /trunk/src/VBox/Installer/linux/routines.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/routines.sh	(revision 44079)
+++ /trunk/src/VBox/Installer/linux/routines.sh	(revision 44080)
@@ -621,2 +621,117 @@
     return 0
 }
+
+install_autologon() {
+    info "Installing auto-logon support ..."
+
+    ## Parameters:
+    # Greeter directory. Defaults to /usr/share/xgreeters.
+    greeter_dir="$1"
+    # LightDM config. Defaults to /etc/lightdm/lightdm.conf.
+    lightdm_config="$2"
+    # Whether to force installation if non-compatible distribution
+    # is detected.
+    force="$3"
+    
+    # Check for Ubuntu and derivates. @todo Debian?
+    distros="Ubuntu UbuntuStudio Edubuntu Kubuntu Lubuntu Mythbuntu Xubuntu"
+    ## @todo Map Linux Mint versions to Ubuntu ones.
+
+    ## @todo Move the distro check to a routine / globals as soon as
+    ##       we have other distribution-dependent stuff.
+    which lsb_release &>/dev/null
+    if test "$?" -ne "0"; then
+        info "Error: lsb_release not found (path set?), skipping auto-logon installation"
+        return 1
+    fi
+    distro_name=$(lsb_release -si)
+    distro_ver=$(lsb_release -sr)
+
+    for distro_cur in ${distros}; do
+        if test "$distro_name" = "$distro_cur"; then
+            distro_found="true"
+            break
+        fi
+    done
+
+    if test -z "$distro_found"; then
+        if ! test "$force" = "force"; then
+            info "Error: Unsupported distribution \"$distro_name\" found, skipping auto-logon installation"
+            return 1
+        fi
+        info "Warning: Unsupported distribution \"$distro_name\" found"
+    else
+        # Do we have Ubuntu 11.10 or greater?
+        # Use AWK for comparison since we run on plan sh.
+        echo | awk 'END { exit ( !('"$distro_ver >= 11.10"') ); }'
+        if test "$?" -ne "0"; then
+            if ! test "$force" = "force"; then
+                info "Error: Version $distro_ver of \"$distro_name\" not supported, skipping auto-logon installation"
+                return 1
+            fi
+            info "Warning: Unsupported \"$distro_name\" version $distro_ver found"
+        fi
+    fi
+
+    # Install dependencies (lightdm and FLTK 1.3+) using apt-get.
+    which apt-get &>/dev/null
+    if test "$?" -ne "0"; then
+        info "Error: apt-get not found (path set?), skipping auto-logon installation"
+        return 1
+    fi
+    info "Checking and installing necessary dependencies ..."
+    apt-get -qqq -y install libfltk1.3 libfltk-images1.3 || return 1
+    apt-get -qqq -y install lightdm || return 1
+
+    # Check for LightDM config.
+    if ! test -f "$lightdm_config"; then
+        info "Error: LightDM config \"$lightdm_config\" not found (LightDM installed?), skipping auto-logon installation"
+        return 1
+    fi 
+
+    # Check for /usr/share/xgreeters.
+    if ! test -d "$greeter_dir"; then
+        if ! test "$force" = "force"; then
+            info "Error: Directory \"$greeter_dir\" does not exist, skipping auto-logon installation"
+            return 1
+        fi
+        info "Warning: Directory \"$greeter_dir\" does not exist, creating it"
+        mkdir -p -m 755 "$greeter_dir" || return 1
+    fi
+    
+    # Link to required greeter files into $greeter_dir.
+    add_symlink "$INSTALLATION_DIR/share/VBoxGuestAdditions/vbox-greeter.desktop" "$greeter_dir/vbox-greeter.desktop"
+
+    # Backup and activate greeter config.
+    if ! test -f "$lightdm_config.vbox-backup"; then
+        info "Backing up LightDM configuration file ..."
+        cp "$lightdm_config" "$lightdm_config.vbox-backup" || return 1
+        chmod 644 "$lightdm_config.vbox-backup" || return 1
+    fi
+    sed -i -e 's/^\s*greeter-session\s*=/greeter-sessio**n=vbox-greeter/g' "$lightdm_config" || return 1
+    chmod 644 "$lightdm_config" || return 1
+
+    info "Auto-logon installation successful"
+    return 0
+}
+
+remove_autologon() {
+    if test -z "$LIGHTDM_CONFIG"; then
+        return 0
+    fi
+    info "Un-installing auto-logon support ..."
+
+    # Switch back to original greeter.
+    if test -f "$LIGHTDM_CONFIG.vbox-backup"; then
+        mv "$LIGHTDM_CONFIG.vbox-backup" "$LIGHTDM_CONFIG"
+        if test "$?" -ne "0"; then
+            info "Warning: Could not restore original LightDM config \"$LIGHTDM_CONFIG\""
+        fi 
+    fi
+
+    # Remove greeter directory (if not empty).
+    rm "$LIGHTDM_GREETER_DIR" 2>/dev/null
+
+    return 0
+}
+
Index: /trunk/src/VBox/Installer/linux/run-inst.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/run-inst.sh	(revision 44079)
+++ /trunk/src/VBox/Installer/linux/run-inst.sh	(revision 44080)
@@ -2,8 +2,9 @@
 #
 # Oracle VM VirtualBox
-# VirtualBox Makeself installation starter script for Linux
+# VirtualBox Makeself installation starter script 
+# for Linux Guest Additions
 
 #
-# Copyright (C) 2006-2009 Oracle Corporation
+# Copyright (C) 2006-2012 Oracle Corporation
 #
 # This file is part of VirtualBox Open Source Edition (OSE), as
@@ -21,5 +22,4 @@
 # installation script.
 #
-
 PATH=$PATH:/bin:/sbin:/usr/sbin
 
@@ -43,4 +43,7 @@
 LOGFILE="/var/log/$PACKAGE.log"
 
+INSTALLATION_LIGHTDM_CONFIG="/etc/lightdm/lightdm.conf"
+INSTALLATION_LIGHTDM_GREETER_DIR="/usr/share/xgreeters"
+
 . "./$ROUTINES"
 
@@ -49,8 +52,12 @@
 create_log "$LOGFILE"
 
+## @todo r=andy: Explain options like "force" and "no_setup" -- not self-explanatory
+#        to the user.
 usage()
 {
     info ""
-    info "Usage: install [<installation directory>] | uninstall [force] [no_setup]"
+    info "Usage: $SELF install [<installation directory>] [--with-autologon] |"
+    info "       uninstall"
+    info "       [--force] [--no-setup]"
     info ""
     info "Example:"
@@ -146,4 +153,6 @@
     done
 
+    remove_autologon
+
     # Get rid of any remaining files
     for i in $DEFAULT_FILE_NAMES; do
@@ -192,4 +201,5 @@
 # Sensible default actions
 ACTION="install"
+WITH_AUTOLOGON=""
 DO_SETUP="true"
 NO_CLEANUP=""
@@ -210,11 +220,30 @@
             ;;
 
-        force)
+        --lightdm-config)
+            INSTALLATION_LIGHTDM_CONFIG="$2"
+            shift
+            ;;
+
+        --lightdm-greeter-dir)
+            INSTALLATION_LIGHTDM_GREETER_DIR="$2"
+            shift
+            ;;
+
+        --with-autologon)
+            WITH_AUTOLOGON="true"
+            ;;
+
+        --force)
+        force) # Keep for backwards compatibility.
             FORCE_UPGRADE="force"
             ;;
-        no_setup)
+
+        --no-setup)
+        no_setup) # Keep for backwards compatibility.
             DO_SETUP=""
             ;;
-        no_cleanup)
+
+        --no-cleanup)
+        no_cleanup) # Keep for backwards compatibility.
             # Do not do cleanup of old modules when removing them.  For
             # testing purposes only.
@@ -222,4 +251,5 @@
             NO_CLEANUP="no_cleanup"
             ;;
+
         *)
             if [ "`echo $1|cut -c1`" != "/" ]; then
@@ -292,4 +322,7 @@
 BUILD_TYPE='$BUILD_TYPE'
 USERNAME='$USERNAME'
+# LightDM greeter configuration
+LIGHTDM_CONFIG='$INSTALLATION_LIGHTDM_CONFIG'
+LIGHTDM_GREETER_DIR='$INSTALLATION_LIGHTDM_GREETER_DIR'
 EOF
 
@@ -356,4 +389,12 @@
         esac
     done
+
+# Load configuration values
+test -r "$CONFIG_DIR/$CONFIG" && . "$CONFIG_DIR/$CONFIG"
+
+# Remove auto-logon support
+remove_autologon
+
+# Remove configuration files
 rm "$CONFIG_DIR/$CONFIG_FILES" 2>/dev/null
 rm "$CONFIG_DIR/$CONFIG" 2>/dev/null
@@ -365,2 +406,9 @@
 test -n "$REMOVE_INSTALLATION_DIR" &&
   echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG_FILES"
+
+# Install auto-logon support.
+if test -n "$WITH_AUTOLOGON"; then
+    ## @todo Make parameters configurable thru command line.
+    install_autologon "$INSTALLATION_LIGHTDM_GREETER_DIR" "$INSTALLATION_LIGHTDM_CONFIG" "$FORCE_UPGRADE"
+fi
+
