gioele / bashrc_dispatch

Launch different bash configurations for Linux vs OSX, interactive vs batch
40 stars 6 forks source link

Can't login to X11 #1

Open chigh opened 11 years ago

chigh commented 11 years ago

When using this bashrc_dispatch, I noticed that I am unable to login to X11. I haven't had the opportunity to check on other Linux distributions, but it certainly happens on Ubuntu 12.10, and 13.04.

This is what's logged in ~/.xsession-errors:

/usr/sbin/lightdm-session: 15: /home/userid/.bashrc_interactive: shopt: not found
/usr/sbin/lightdm-session: 34: [: 1000: unexpected operator
/usr/sbin/lightdm-session: 46: [: ==: unexpected operator
/usr/sbin/lightdm-session: 46: [: ==: unexpected operator
/usr/sbin/lightdm-session: 41: [: unexpected operator
/usr/sbin/lightdm-session: 40: [: unexpected operator
/usr/sbin/lightdm-session: 46: /home/userid/.profile: [[: not found
/usr/sbin/lightdm-session: 42: /home/userid/.profile: shopt: not found
/usr/sbin/lightdm-session: 73: export: Illegal option -f

I've narrowed it down to the last error. When logging in, and the shell it hits the following lines in the .bashrc_dispatch:

    $fn_cmd -f shell_is_linux
    $fn_cmd -f shell_is_osx
    $fn_cmd -f shell_is_login
    $fn_cmd -f shell_is_interactive
    $fn_cmd -f shell_is_script

that error is logged and the X11 session is terminated and brought back to the login screen. If I comment those lines out, I can login (the previous errors are still logged, but apparently are not fatal to the X11 session), but I cannot tell if I'm missing any functionality.

I am hardly a shell expert, so are those lines absolutely necessary? What exactly do they do? Is there something that can be done to work around them?

Thanks.

gioele commented 11 years ago

It looks like bashrc_dispatch is being read by Dash instead of Bash. bashrc_dispatch uses options available only in Bash, as the name implies.

How did you install bashrc_dispatch?

chigh commented 11 years ago

bashrc_dispatch is a file and .bashrc .bash_login .bash_profile and .profile are symlinks to bashrc_dispatch.

These are located in my home directory.

On May 24, 2013, at 16:51, Gioele notifications@github.com wrote:

It looks like bashrc_dispatch is being read by Dash instead of Bash. bashrc_dispatch uses options available only in Bash, as the name implies.

How did you install bashrc_dispatch?

— Reply to this email directly or view it on GitHub.

gioele commented 11 years ago

You have hit this bug in GDM and LightDM:

https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1097903 https://bugs.launchpad.net/ubuntu/+source/gdm/+bug/678421

I will commit a work around soon. In the meantime you can add

[ -n "$BASH_VERSION" ] && exit

at the beginning of bashrc_dispatch.

chigh commented 11 years ago

That doesn't seem to help and prevents me from logging in X11 or otherwise (e.g. via su - user or ssh).

gioele commented 11 years ago

Can you please try adding the following at the beginning of bashrc_dispatch?

[ -n "$BASH_VERSION" ] && return
chigh commented 11 years ago

I apologize; that was one of the modifications I didn't try on my own. When I use that, I am able to login to X, but all of the shells (terminal, ssh, etc) do not load any of the rc files, thus no variables are set, and no functions or aliases are loaded.

If this is helpful to you, I can continue. If not, I can just work around this problem.

chigh commented 11 years ago

This is also true when logging into a BASH shell on OSX (in Terminal, ssh, etc). If the [ -n "$BASH_VERSION" ] && return is set, I am dropped to shell with only the system rc files having been sourced.

chigh commented 11 years ago

As a work-around, I have reconfigured sh to be bash instead of dash. However, I may not be able to do this to systems to which I do not have root access. So, if there's a better fix as a normal user, I'd like to use it.

dpkg-reconfigure dash

chigh commented 9 years ago

I found a bit of a better work-around for this. At the beginning of .bashrc_dispatch:

export OLD_DISPLAY=$DISPLAY
[[ $SESSION = ubuntu && ! -z $DISPLAY ]] && unset DISPLAY

And at the end of .bashrc_dispatch

if [[ $SESSION = ubuntu ]]; then
    export DISPLAY="$OLD_DISPLAY"
fi