Comment 26 for bug 1922414

Revision history for this message
Boris Steiner (boris-steiner) wrote (last edit ): Re: ssh-agent fails to start (has_option: command not found)

This issue is caused by lightdm running /usr/sbin/lightdm-session instead of /etc/X11/Xsession.

The simplest workaround for me was:
- introduce has_option functon as 1st step in Xsession.d sourced scripts
- as root create file /etc/X11/Xsession.d/01custom-has-option with following content:

OPTIONS="$(
  if [ -r "$OPTIONFILE" ]; then
    cat "$OPTIONFILE"
  fi
  if [ -d /etc/X11/Xsession.options.d ]; then
    run-parts --list --regex '\.conf$' /etc/X11/Xsession.options.d | xargs -d '\n' cat
  fi
)"

#check if has_option is already defined; if not, define

has_option 2>1 > /dev/null || has_option() {
  # Ensure that a later no-foo overrides an earlier foo
  if [ "$(echo "$OPTIONS" | grep -Eo "^(no-)?$1\>" | tail -n 1)" = "$1" ]; then
    return 0
  else
    return 1
  fi
}

- logout and login

Details:
- /etc/X11/Xsession introduces has_option shell function that check if Xsession.options contains predefined option
- /etc/X11/Xsession sources all files under /etc/X11/Xsession.d in alphabetic order
- as the scripts are sourced they maintain the same environemnt and definitions of variables or functions as Xsession
- however, lightdm uses lightdm-session that also sources /etc/X11/Xsession.d/* BUT does NOT define has_option function
- provided script checks if the function has_option already exists (Xsession is in play) and if not (lightdm-session's game) it defines it the same way as is in /etc/X11/Xsession

Alternative solutions:
- modify lightdm-session to contain has_option the same way as /etc/X11/Xsession
- modify (create) /etc/lightdm/lightdm.conf containing:
[Seat:*]
session-wrapper=/etc/X11/Xsession

- requires reboot; it did not work ok for 100% as my .profile env vars were not correctly propagated