Xsessions has_option code error with fix
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
xorg (Ubuntu) |
Expired
|
Undecided
|
Unassigned |
Bug Description
Jammy Jellyfish 22.04.1 LTS and others. There have been numerous bug reports and failed fixes for this over several years and releases.
There are a couple of problems in /etc/X11/Xsessions where it fails to handle options, causing bogus error messages and, doubtless, many errors.
The first bug is that the entire options file, including comments, is read into a variable.
Where the variable "OPTIONS" is assigned;
Replacing "cat" with "grep" strips out comments and blank lines;
$ diff Xsession Xsession.orig
65c65
< grep -v "^\s*\#\|^\s*$" "$OPTIONFILE"
---
> cat "$OPTIONFILE"
The second problem is that checking for a non-existent directory inside a command substitution does not work. It just appends garbage onto the output string.
That is probably a bug in BASH, but I defer to your opinion there.
The immediate work around is to create an empty directory so that the test does not fail. Better still, force the creation of the directory and remove the test.
eg. change this;
OPTIONS="$(
if [ -r "$OPTIONFILE" ]; then
cat "$OPTIONFILE"
fi
if [ -d /etc/X11/
run-parts --list --regex '\.conf$' /etc/X11/
fi
)"
to this;
OPTIONSDIR=
mkdir --parents ${OPTIONSDIR}
OPTIONS="$(
if [ -r "$OPTIONFILE" ]; then
grep -v "^\s*\#\|^\s*$" "$OPTIONFILE"
fi
run-parts --list --regex '\.conf$' /etc/X11/
)"
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: xorg 1:7.7+23ubuntu2
ProcVersionSign
Uname: Linux 5.15.0-52-generic x86_64
.tmp.unity_
ApportVersion: 2.20.11-0ubuntu82.1
Architecture: amd64
BootLog: Error: [Errno 13] Permission denied: '/var/log/boot.log'
CasperMD5CheckR
CompositorRunning: None
CurrentDesktop: XFCE
Date: Mon Oct 31 16:33:14 2022
DistUpgraded: Fresh install
DistroCodename: jammy
DistroVariant: ubuntu
DkmsStatus:
virtualbox/6.1.38, 5.15.0-
virtualbox/6.1.38, 5.15.0-52-generic, x86_64: installed
ExtraDebuggingI
GraphicsCard:
Advanced Micro Devices, Inc. [AMD/ATI] Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series] [1002:15dd] (rev c8) (prog-if 00 [VGA controller])
Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series] [1002:15dd]
InstallationDate: Installed on 2022-10-20 (11 days ago)
InstallationMedia: Kubuntu 22.04.1 LTS "Jammy Jellyfish" - Release amd64 (20220809.1)
MachineType: Micro-Star International Co., Ltd. MS-7B89
ProcKernelCmdLine: ro root=PARTUUID=
SourcePackage: xorg
Symptom: display
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 02/01/2021
dmi.bios.release: 5.17
dmi.bios.vendor: American Megatrends International, LLC.
dmi.bios.version: 2.C0
dmi.board.
dmi.board.name: B450M MORTAR MAX (MS-7B89)
dmi.board.vendor: Micro-Star International Co., Ltd.
dmi.board.version: 1.0
dmi.chassis.
dmi.chassis.type: 3
dmi.chassis.vendor: Micro-Star International Co., Ltd.
dmi.chassis.
dmi.modalias: dmi:bvnAmerican
dmi.product.family: To be filled by O.E.M.
dmi.product.name: MS-7B89
dmi.product.sku: To be filled by O.E.M.
dmi.product.
dmi.sys.vendor: Micro-Star International Co., Ltd.
version.compiz: compiz 1:0.9.14.
version.libdrm2: libdrm2 2.4.110-1ubuntu1
version.
version.
version.
version.
version.
version.
version.
Changed in xorg (Ubuntu): | |
status: | New → Incomplete |
Bother. There is a third problem, a scope issue of some sort.
The errors in ~/.xsession.error go away if "has_options" is moved from Xsession to its own file in Xsession.d
I don't see why sourceing it should make any difference, but it does.
$ cat /etc/X11/ Xsession. d/00
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
}
Also I changed a "=" to "==", but that should be cosmetic.