Bug 1349664 - Incorrect pattern in convert-to-edition.lua clear_presets() results in erroneous removal of non-product presets
Summary: Incorrect pattern in convert-to-edition.lua clear_presets() results in errone...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: fedora-release
Version: rawhide
Hardware: All
OS: All
unspecified
high
Target Milestone: ---
Assignee: Dennis Gilmore
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1337546
TreeView+ depends on / blocked
 
Reported: 2016-06-23 22:59 UTC by Adam Williamson
Modified: 2016-06-26 20:54 UTC (History)
7 users (show)

Fixed In Version: fedora-release-24-2
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-26 20:54:35 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
patch to fix the bug (1.02 KB, text/plain)
2016-06-23 23:04 UTC, Adam Williamson
no flags Details

Description Adam Williamson 2016-06-23 22:59:03 UTC
The convert-to-edition.lua script has this function, which is called by convert_to_edition, which is called by install_edition:

-- Remove preset files for other editions
-- This should never be necessary, but it's best to be safe
local function clear_presets()
  local path = "/usr/lib/systemd/system-preset"
  for file in posix.files(path) do
    if file:match("^80-.*%.preset$") then
      os.remove(path .. "/" .. file)
    end
  end
end

It's obviously intended to do, basically, `rm -f /usr/lib/systemd/system-preset/80-*.preset` . The problem is, the pattern's wrong.

What it actually does is more like `rm -f /usr/lib/systemd/system-preset/8*.preset`. This is because '-' is a special character in lua patterns. See http://lua-users.org/wiki/PatternsTutorial:

- Match the previous character (or class) zero or more times, as few times as possible.

so the '-' effectively negates the 0 character that precedes it. The pattern will match 80-foo.preset , but it will also match 85-foo.preset , or 8aaaaa.preset .

The %post scriptlets for all fedora-release subpackages call install_edition, and there's a fedora-release %posttrans scriptlet which also calls install_edition. The upshot is that 8*.preset will be wiped at some point during *any* Fedora 24+ install - if any 'edition' is installed, they'll be wiped during the %post of that package install; if you do a non-edition install (e.g. a minimal install), they'll be wiped in %posttrans.

Notably, this affects /usr/lib/systemd/system-preset/85-display-manager.preset , whose job is to ensure that display managers are enabled by default.

It happens (fortunately...I guess?) that in a network install of Workstation, for e.g., gdm is installed before fedora-release-workstation - so when gdm's %post runs, 85-display-manager.preset is present, and gdm gets enabled (gdm's %post calls `systemctl --no-reload preset gdm.service`). And in an install of any other graphical environment, no 'edition' package will be installed, so the preset file will only be wiped in %posttrans and again the display manager will be enabled properly.

But if you install without a graphical environment, then install one and do `systemctl set-default graphical.target` then reboot, you don't get a graphical boot - because the display manager will not be enabled.

I noticed this because it affects the openQA upgrade test disk images: we build those by (effectively) doing a minimal install and then installing the desktop package group and enabling graphical.target , but I still wasn't getting a graphical boot after doing that, whereas it worked just fine on F23. Turns out, this is the cause.

The fix for this is trivial - we just have to escape the '-' with a '%'. I'm attaching a patch.

Comment 1 Adam Williamson 2016-06-23 23:04:15 UTC
Created attachment 1171748 [details]
patch to fix the bug

should be applied to both Rawhide and F24, and an update shipped for F24.

Comment 2 Fedora Update System 2016-06-24 01:28:36 UTC
fedora-release-24-2 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-0b6e9310b2

Comment 3 Stephen Gallagher 2016-06-24 12:26:01 UTC
Adam, thanks for the detailed investigation, explanation and patch!

Comment 4 Fedora Update System 2016-06-25 00:31:44 UTC
fedora-release-24-2 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-0b6e9310b2

Comment 5 Fedora Update System 2016-06-26 20:54:28 UTC
fedora-release-24-2 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.