Xorg scripts fail with "has_option: command not found"

Bug #1922414 reported by Laurent Bonnaud
128
This bug affects 25 people
Affects Status Importance Assigned to Milestone
Light Display Manager
Invalid
Undecided
Unassigned
gdm3 (Ubuntu)
Fix Released
Low
Unassigned
lightdm (Ubuntu)
Invalid
Undecided
Unassigned
xorg (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Hi,

I have been using ssh-agent for years and since I upgraded my system to Ubuntu 21.04/groovy, ssh-agent fails to start.

Here is the error message:

# journalctl | grep ssh-agent
[...]
Apr 02 20:16:32 vougeot /usr/libexec/gdm-x-session[3752]: /etc/X11/Xsession.d/90x11-common_ssh-agent: line 9: has_option: command not found

ProblemType: Bug
DistroRelease: Ubuntu 21.04
Package: x11-common 1:7.7+22ubuntu1
Uname: Linux 5.11.11-051111-lowlatency x86_64
ApportVersion: 2.20.11-0ubuntu61
Architecture: amd64
BootLog: Error: [Errno 13] Permission denied: '/var/log/boot.log'
CasperMD5CheckResult: unknown
CompizPlugins: No value set for `/apps/compiz-1/general/screen0/options/active_plugins'
CompositorRunning: None
CurrentDesktop: KDE
Date: Sat Apr 3 09:02:46 2021
Dependencies: lsb-base 11.1.0ubuntu2
DistUpgraded: Fresh install
DistroCodename: hirsute
DistroVariant: ubuntu
DkmsStatus:
 tuxedo-keyboard, 3.0.4, 5.11.0-13-generic, x86_64: installed
 tuxedo-keyboard, 3.0.4, 5.11.0-13-lowlatency, x86_64: installed
 tuxedo-keyboard, 3.0.4, 5.11.11-051111-lowlatency, x86_64: installed
ExtraDebuggingInterest: No
GraphicsCard:
 Intel Corporation TigerLake GT2 [Iris Xe Graphics] [8086:9a49] (rev 01) (prog-if 00 [VGA controller])
   Subsystem: CLEVO/KAPOK Computer Iris Xe Graphics [1558:51a1]
MachineType: TUXEDO TUXEDO InfinityBook S 15 Gen6
PackageArchitecture: all
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-5.11.11-051111-lowlatency root=/dev/mapper/MonVolume2-UbuntuRacine ro vsyscall=none security=apparmor quiet splash vt.handoff=7
SourcePackage: xorg
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 09/07/2020
dmi.bios.release: 7.3
dmi.bios.vendor: INSYDE Corp.
dmi.bios.version: 1.07.03RTR
dmi.board.name: NS50MU
dmi.board.vendor: TUXEDO
dmi.board.version: Not Applicable
dmi.chassis.asset.tag: No Asset Tag
dmi.chassis.type: 10
dmi.chassis.vendor: Notebook
dmi.chassis.version: N/A
dmi.ec.firmware.release: 7.2
dmi.modalias: dmi:bvnINSYDECorp.:bvr1.07.03RTR:bd09/07/2020:br7.3:efr7.2:svnTUXEDO:pnTUXEDOInfinityBookS15Gen6:pvrNotApplicable:rvnTUXEDO:rnNS50MU:rvrNotApplicable:cvnNotebook:ct10:cvrN/A:
dmi.product.family: Not Applicable
dmi.product.name: TUXEDO InfinityBook S 15 Gen6
dmi.product.sku: Not Applicable
dmi.product.version: Not Applicable
dmi.sys.vendor: TUXEDO
version.compiz: compiz 1:0.9.14.1+20.10.20200813-0ubuntu4
version.libdrm2: libdrm2 2.4.104-1build1
version.libgl1-mesa-dri: libgl1-mesa-dri 21.0.1-1
version.libgl1-mesa-glx: libgl1-mesa-glx 21.0.1-1
version.xserver-xorg-core: xserver-xorg-core 2:1.20.10-3ubuntu5
version.xserver-xorg-input-evdev: xserver-xorg-input-evdev 1:2.10.6-2build1
version.xserver-xorg-video-ati: xserver-xorg-video-ati 1:19.1.0-2
version.xserver-xorg-video-intel: xserver-xorg-video-intel N/A
version.xserver-xorg-video-nouveau: xserver-xorg-video-nouveau 1:1.0.17-1

Revision history for this message
Laurent Bonnaud (laurent-bonnaud) wrote :
Revision history for this message
Laurent Bonnaud (laurent-bonnaud) wrote :

The /etc/X11/Xsession.d/90x11-common_ssh-agent file is the same in Ubuntu groovy and hirsute. Therefore, the problem is elsewhere.

Revision history for this message
Laurent Bonnaud (laurent-bonnaud) wrote :

The has_option shell function is not defined in the same file:

 - in Ubuntu groovy it is defined in
/etc/X11/Xsession.d/20x11-common_process-args

 - in Ubuntu hirsute it is defined in
/etc/X11/Xsession

Revision history for this message
Achim Settelmeier (settel) wrote :

Looks like /etc/X11/Xsession is not executed, but the files in /etc/X11/Xsession.d/ are sourced somehow. My best guess is that there's some other mechanism emulating Xsession's behaviour but without defining has_option.

Maybe this is a pending bug introduced in an earlier version of Ubuntu that has come to light just now, after has_option has been moved as #3 points out.

BTW: I'm using lightdm with the Arctica Greeter.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gdm3 (Ubuntu):
status: New → Confirmed
Changed in xorg (Ubuntu):
status: New → Confirmed
Revision history for this message
Achim Settelmeier (settel) wrote :

As a workaround, I created the file 01x11-has_option (find it attached) and placed it in /etc/X11/Xsession.d/. It defines has_option unless it is already defined somewhere else. ssh-agent now runs in the background on startup again.

Revision history for this message
Ricardo Garicano Arenas (rgaricano) wrote :

Same problem here,
after upgrade ubuntu studio 20.04 to 21.04 & change default plasma desktop to xfce:

/etc/X11/Xsession.d/30x11-common_xresources: línea 16: has_option: orden no encontrada
/etc/X11/Xsession.d/75dbus_dbus-launch: línea 9: has_option: orden no encontrada

Achim solution (https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/1922414/comments/7 ) solve this errors.

Revision history for this message
Sebastien Bacher (seb128) wrote :
Changed in xorg (Ubuntu):
importance: Undecided → Low
status: Confirmed → Invalid
Revision history for this message
Sebastien Bacher (seb128) wrote :
Changed in gdm3 (Ubuntu):
importance: Undecided → Low
status: Confirmed → Fix Released
Revision history for this message
Laurent Bonnaud (laurent-bonnaud) wrote :

Great, thank you for the fix!

Revision history for this message
Ryan Anderson (ryan-michonline) wrote :

This is still broken on impish when running i3 under X11.

Oct 22 15:23:39 operations /usr/libexec/gdm-x-session[5615]: /etc/X11/Xsession.d/30x11-common_xresources: line 16: has_option: command not found
Oct 22 15:23:39 operations /usr/libexec/gdm-x-session[5646]: /etc/X11/Xsession.d/75dbus_dbus-launch: line 9: has_option: command not found
Oct 22 15:23:39 operations /usr/libexec/gdm-x-session[5658]: /etc/X11/Xsession.d/90x11-common_ssh-agent: line 9: has_option: command not found

tags: added: impish jammy
Changed in xorg (Ubuntu):
status: Invalid → Confirmed
Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1922414

tags: added: iso-testing
tags: removed: hirsute
Revision history for this message
Tuxo (tuxoholic) wrote :

running fluxbox still can trigger this in 22.04

Affected scripts in my case:

/etc/X11/Xsession.d/30x11-common_xresources
/etc/X11/Xsession.d/90x11-common_ssh-agent

Revision history for this message
Mark Eichin (eichin-gmail) wrote :

still seeing
Apr 9 15:30:54 drafting-table /usr/libexec/gdm-x-session[355145]: /etc/X11/Xsession.d/30x11-common_xresources: line 16: has_option: command not found
in an install which is "jammy daily iso from a week or two back with daily dist upgrades", under i3;

$ dpkg -l gdm3 x11-common i3-wm
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-===============-============-======================================
ii gdm3 42.0-1ubuntu2 amd64 GNOME Display Manager
ii i3-wm 4.20.1-1 amd64 improved dynamic tiling window manager
ii x11-common 1:7.7+23ubuntu2 all X Window System (X.Org) infrastructure

Revision history for this message
Norbert (nrbrtx) wrote :

Still happens on UM Jammy.

Revision history for this message
Norbert (nrbrtx) wrote :

Still happens on UM Jammy.

How Long?????

Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

I also see it on Ubuntu MATE Jammy.
Will the fix come from Xorg,
or should we add LightDM to the affected projects list?

Revision history for this message
R. Grieger (iamlunchbox) wrote :

I can confirm this bug on jammy using lightdm and gdm3 in conjunction with x11 and i3.

Revision history for this message
Chris Wilson (jakdaw) wrote :

I'm affected by this on jammy with lightdm and wmaker.

tags: removed: impish
Revision history for this message
Norbert (nrbrtx) wrote :

Please finally fix this bug!

tags: added: kinetic
Revision history for this message
Philipp Keck (philipp-v) wrote (last edit ):

Reported here: https://github.com/canonical/lightdm/issues/198

There's also a workaround for lightdm users posted there.

Revision history for this message
Andreas Perhab (ap-wtioit) wrote :

Upgraded from 20.04 LTS to 22.04 LTS and still got the same issue:
Aug 18 08:35:14 redacted /usr/libexec/gdm-x-session[6714]: /etc/X11/Xsession.d/30x11-common_xresources: line 16: has_option: command not found
Aug 18 08:35:14 redacted /usr/libexec/gdm-x-session[6749]: /etc/X11/Xsession.d/75dbus_dbus-launch: line 9: has_option: command not found
Aug 18 08:35:14 redacted /usr/libexec/gdm-x-session[6780]: /etc/X11/Xsession.d/90x11-common_ssh-agent: line 9: has_option: command not found

Revision history for this message
Boris Steiner (boris-steiner) wrote (last edit ):

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

Revision history for this message
Tony Martin Berbel (wingarmac) wrote :

Same for me on Ubuntu Mate 22.04 5.15.0-52-generic and Cinnamon 5.2.7
/etc/X11/Xsession.d/30x11-common_xresources: ligne 16: has_option : commande introuvable
/etc/X11/Xsession.d/75dbus_dbus-launch: ligne 9: has_option : commande introuvable

Revision history for this message
ALinuxUser (buntulongername-new) wrote :

Like the previous poster, I too have this problem whilst running the Cinnamon DE.

Revision history for this message
Arjan (iafilius) wrote :

Hi,

a 'meetoo' for ubuntu 22.10, using sddm/plasma-x11

Can sddm please be added to the 'Affects'?

Did notice the has_option not found in .xsession-errors
and applied workaround as suggested by Boris Steiner above, but had to make a small fixup to the script:

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
}

Notice the
has_option 2>&1
instead of
has_option 2>1

original proposed version will create file '1' in your home folder

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in lightdm (Ubuntu):
status: New → Confirmed
Revision history for this message
al (riota123) wrote :

I also see it on Ubuntu MATE Jammy.
Will the fix come from Xorg,
or should we add LightDM to the affected projects list?

Revision history for this message
Laurent Bonnaud (laurent-bonnaud) wrote :

Hi,
the bug is still there on an Ubuntu 23.10/mantic system:

# journalctl | grep has_option
Sep 22 13:46:02 xeelee /usr/libexec/gdm-x-session[2101]: /etc/X11/Xsession.d/30x11-common_xresources: line 16: has_option: command not found
Sep 22 13:46:03 xeelee /usr/libexec/gdm-x-session[2123]: /etc/X11/Xsession.d/75dbus_dbus-launch: line 9: has_option: command not found
Sep 22 13:46:03 xeelee /usr/libexec/gdm-x-session[2150]: /etc/X11/Xsession.d/90x11-common_ssh-agent: line 9: has_option: command not found

tags: added: lunar mantic
Changed in lightdm (Ubuntu):
status: Confirmed → Invalid
Changed in lightdm:
status: New → Invalid
summary: - ssh-agent fails to start (has_option: command not found)
+ Xorg scripts fail with "has_option: command not found"
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

See also bug 2049016.

Ken Sharp (kennybobs)
tags: removed: ubuntu
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.