My suggestion would be (without looking too deeply) that logging into a Gnome session is not logging into a bash shell. /etc/X11/Xsession appears to be running ksh. I would suggest using a GDM logout script, also known as a "PostSession" script instead.
http://www.linuxquestions.org/questions/linux-desktop-74/run-script-on-gdm-logout-634678/ ... that is vaguely the same issue, and probably effectively the same solution :) Tommy -- This message posted from opensolaris.org