← Back to team overview

touch-packages team mailing list archive

[Bug 1468832] Re: lightdm sources .profile

 

> The user's .profile is to be read by the shell, on interactive shell
> (i.e. terminal) logins ONLY

This is incorrect, .profile is read by the shell also when the shell is
non-interactive. Here is the quote from the bash manual:

> When Bash is invoked as an interactive login shell, or as a
> non-interactive shell with the --login option, it first reads and
> executes commands from the file /etc/profile, if that file exists.
> After reading that file, it looks for ~/.bash_profile, ~/.bash_login,
> and ~/.profile, in that order, and reads and executes commands from the
> first one that exists and is readable. 

A not so far fetched example of a non interactive login shell is
something like this, where I want to source .profile but not .bashrc

$ ssh localhost "bash --login -c 'env'"

This means that .profile might be read with no tty attached, and we
should test for the presens of an attached tty when invoking stty in
.profile

.profile:
tty -s && stty erase ^H

I am interpreting a xsession as a login shell that should source
.profile.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to lightdm in Ubuntu.
https://bugs.launchpad.net/bugs/1468832

Title:
  lightdm sources .profile

Status in lightdm package in Ubuntu:
  New

Bug description:
  It is a bug for any display manager to read .profile--you guys are
  absolutely killing me with this.  The user's .profile is to be read by
  the shell, on interactive shell (i.e. terminal) logins ONLY.  The man
  page for bash explains this in detail; it's also discussed in the dash
  man page.  The problem with display managers reading .profile is that
  it is the place where commands to set up your terminal (i.e. stty) go
  --this is the entire point of differentiating interactive shells from
  non-interactive shells, and it's the reason only interactive shells
  read .profile at all.  Currently, if you have any such commands in
  your .profile, lightdm barfs on them, delaying the login session and
  forcing you to click on a prompt.  This is extremely annoying (and
  wrong)!

  It would be satisfactory to make lightdm not display the errors, but
  that's the wrong solution.  There's already a decades-established
  method of getting X display managers to source your environment
  settings: the .xsession file.  It should be read by ALL display
  managers (or the session file that starts them).  If you have common
  environment settings you want set in all your shells, the correct way
  to handle this is:

  .bashrc:
  # set all common environment vars here
  ENV_VAR=foo
  ...

  .profile:
  # set up terminal
  stty erase
  # BASH already sources .bashrc by default on interactive sessions

  .xsession:
  if [ -f .bashrc ] source .bashrc

  If you're not using BASH, you can still use this method without
  changing anything, except in .profile you need to explicitly source
  the .bashrc file.  Of course you can change the name of the file that
  contains the common settings to reflect that your shell is not BASH;
  since the file is sourced by your other files explicitly, it does not
  matter what the user calls it.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/1468832/+subscriptions


References