You are not logged in.

#1 2018-11-29 22:55:58

nrz
Member
Registered: 2016-07-24
Posts: 19

LightDM failed to login after I added a function to the /etc/profile

I solved this one by myself, but would appreciate some clarification regarding the matter.

So I added similar to the following function to /etc/profile:

function 1tst() {
  echo 'This is the function that prevents LightDM to login... :('
}

On the next reboot I was not able to login. After some trial/error and log digging... I found ~/.xsession-errors:

/etc/profile: line 47: `1tst': not a valid identifier

So it seems that when LightDM attempts to log in, it's using /bin/sh even though my user's default shell is:

$ getent passwd nrz 
nrz:x:1000:1000::/home/nrz:/bin/bash

Presumably culprit is LightDM's session-wrapper script??

$ head -1 /etc/lightdm/Xsession 
#!/bin/sh

I know it's not wise to start fn name with a digit, but let's just assume that I had a good reason, especially because bash does not complain about it.

Last edited by nrz (2018-11-30 01:00:12)

Offline

#2 2018-11-30 07:33:56

seth
Member
Registered: 2012-09-03
Posts: 51,143

Re: LightDM failed to login after I added a function to the /etc/profile

It's not "not wise" but "illegal" - even on bash.
https://www.gnu.org/software/bash/manua … efinitions

That bash let's one get away w/ it if it's *explicitly* invoked (ie. the shebang *has* to be /bin/bash, not /bin/sh even if sh is a symlink to bash) is no indicator that one is good to go.
It's an indicator that bash scripters generally don't read docs ;-)

One *could* alter the shebang, but really the only sane thing to do is to prepend an underscore "_"

Offline

Board footer

Powered by FluxBB