[Bug 1099987] [NEW] /etc/skel/.profile does not detect bash properly
Alec Warner
1099987 at bugs.launchpad.net
Tue Jan 15 19:58:28 UTC 2013
Public bug reported:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
So if I run bash in posix mode or as /bin/sh.
antarus at goats5 /etc/skel $ env -i /bin/sh -c 'echo $BASH_VERSION'
4.2.24(1)-release
antarus at goats5 /etc/skel $ env -i bash --posix -c 'echo $BASH_VERSION'
4.2.24(1)-release
This means when lightdm-session-wrapper sources the users $HOME/.profile
(created from /etc/skel) it will also sources their $HOME/.bashrc.
lightdm-session-wrapper runs as posix sh, and not bash. Sourcing a
.bashrc as posix sh does not work well.
antarus at goats5 ~/antarus $ /bin/sh
sh-4.2$ source ~/.bashrc
sh: `break-posix-sh': not a valid identifier
antarus at goats5 ~/antarus $ grep 'break-posix-sh' ~/.bashrc
function break-posix-sh() {
Functions cannot have dashes in them in posix, but can in bash, for
example.
If you replace the .profile login with something like:
if ! shopt -oq posix; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
It seems to work properly.
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS"
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
antarus at goats5 ~/antarus $ apt-cache policy bash
bash:
Installed: 4.2-2ubuntu2
Candidate: 4.2-2ubuntu2
Version table:
If lightdm cannot source my .bashrc, I cannot login. Also, thousands of
my users cannot login.
-A
** Affects: bash (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bash in Ubuntu.
https://bugs.launchpad.net/bugs/1099987
Title:
/etc/skel/.profile does not detect bash properly
Status in “bash” package in Ubuntu:
New
Bug description:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
So if I run bash in posix mode or as /bin/sh.
antarus at goats5 /etc/skel $ env -i /bin/sh -c 'echo $BASH_VERSION'
4.2.24(1)-release
antarus at goats5 /etc/skel $ env -i bash --posix -c 'echo $BASH_VERSION'
4.2.24(1)-release
This means when lightdm-session-wrapper sources the users
$HOME/.profile (created from /etc/skel) it will also sources their
$HOME/.bashrc. lightdm-session-wrapper runs as posix sh, and not bash.
Sourcing a .bashrc as posix sh does not work well.
antarus at goats5 ~/antarus $ /bin/sh
sh-4.2$ source ~/.bashrc
sh: `break-posix-sh': not a valid identifier
antarus at goats5 ~/antarus $ grep 'break-posix-sh' ~/.bashrc
function break-posix-sh() {
Functions cannot have dashes in them in posix, but can in bash, for
example.
If you replace the .profile login with something like:
if ! shopt -oq posix; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
It seems to work properly.
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.1 LTS"
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
antarus at goats5 ~/antarus $ apt-cache policy bash
bash:
Installed: 4.2-2ubuntu2
Candidate: 4.2-2ubuntu2
Version table:
If lightdm cannot source my .bashrc, I cannot login. Also, thousands
of my users cannot login.
-A
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1099987/+subscriptions
More information about the foundations-bugs
mailing list