May. 2, 2008

Have you ever found yourself calling your collegue to show them your mad skills during an application test. Just to seconds later realize that you're a Teletubby as session information got mixed up between browsers and you actually achieved nothing?


Good, me neither. Anyway I sometimes find myself doing test using several different accounts, running simultaneously in both Firefox and Internet Explorer. However, once in a while Firefox is sufficient and I would like to run a separate instance of each on a separate desktop of my Compiz cube just to keep them apart. In order to make sure no session information or other contaminating data gets picked up by the browsers I run them in separate user accounts. This is how I set it up:

First add a user under which the second browser is going to run. This user does not require a shell, as we won't log in using this account. My user is called firefox.

useradd -m firefox -s /bin/false

Then create a script similar to this one in order to be able to start the second instance from you own account. My is called firefox-browser.sh

#!/bin/sh
USER="firefox"
XAUTH=/home/$USER/.Xauthority
 
if [ `id -u` -ne 0 ]; then
   echo "$0 must be run as root..."
   exit
fi
 
xauth extract - $DISPLAY | sudo -H -u $USER XAUTHORITY=$XAUTH xauth merge -
sudo -H -u $USER XAUTHORITY=$XAUTH firefox
rm -f $XAUTH

Start a second browser running as the firefox using sudo

sudo ./firefox-browser.sh

Posted by Patrik in Testing

Post a Comment