Skip to content

spec: avoid owning systemd-user#966

Merged
dougsland merged 1 commit intomainfrom
qmwayland-systemd
Feb 6, 2026
Merged

spec: avoid owning systemd-user#966
dougsland merged 1 commit intomainfrom
qmwayland-systemd

Conversation

@dougsland
Copy link
Copy Markdown
Member

@dougsland dougsland commented Jan 27, 2026

systemd-user is owned by systemd, we cannot define %{_sysconfdir}/pam.d/systemd-user in the files.

Fix #965

Summary by Sourcery

Adjust qm-wayland packaging to ship a separate PAM configuration for systemd-user without owning the upstream-managed file.

Enhancements:

  • Install a qm-wayland-specific systemd-user PAM configuration alongside the default and use scriptlets to swap it in on install and restore the original on uninstall.
  • Limit PAM installation to the wayland-autologin file and mark the qm-wayland systemd-user PAM file as the packaged configuration instead of the upstream-owned path.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jan 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the qm-wayland RPM spec to stop owning the upstream systemd-user PAM file while still deploying a custom configuration by installing a suffixed copy and swapping it in via scriptlets during install and uninstall.

File-Level Changes

Change Details Files
Limit installed PAM files and introduce a suffixed systemd-user PAM config instead of owning the upstream file.
  • Replace wildcard PAM installation with explicit install of wayland-autologin PAM configuration.
  • Install the custom systemd-user PAM file as systemd-user.qm-wayland under %{_sysconfdir}/pam.d instead of overwriting systemd-user directly.
  • Adjust the RPM file list to own only systemd-user.qm-wayland and not systemd-user.
rpm/wayland/qm-wayland.spec
Add RPM %post and %postun scriptlets to safely swap the systemd-user PAM configuration at install and uninstall time.
  • In %post, on initial install or upgrade, back up an existing non-symlink systemd-user PAM file to systemd-user.rpmsave if no backup exists.
  • In %post, copy the packaged systemd-user.qm-wayland to systemd-user, effectively activating the custom PAM configuration.
  • In %postun, on final uninstall, restore systemd-user from systemd-user.rpmsave if present.
rpm/wayland/qm-wayland.spec

Possibly linked issues

  • #(unknown): PR changes qm-wayland spec to avoid owning systemd-user directly, resolving the CI file conflict with systemd.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @dougsland, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the RPM spec file for qm-wayland to resolve a packaging conflict where it was attempting to own the systemd-user PAM configuration file, which is already managed by the systemd package. The changes introduce a mechanism to install a custom systemd-user PAM configuration with a unique suffix and then dynamically manage its activation and deactivation during package installation and uninstallation, respectively, ensuring compatibility and proper system behavior without direct file ownership conflicts.

Highlights

  • Avoid direct ownership of systemd-user PAM config: The package no longer directly installs or claims ownership of /etc/pam.d/systemd-user to prevent conflicts with the systemd package, which already owns this file.
  • Custom PAM config with suffix: The systemd-user PAM configuration specific to qm-wayland is now installed with a .qm-wayland suffix at /etc/pam.d/systemd-user.qm-wayland.
  • Runtime PAM config management: Post-installation scripts (%post) are introduced to back up the existing /etc/pam.d/systemd-user (if it's not a symlink and no .rpmsave exists) and then replace it with the qm-wayland specific version (systemd-user.qm-wayland).
  • Uninstallation cleanup: Post-uninstallation scripts (%postun) are added to restore the original /etc/pam.d/systemd-user from the .rpmsave backup, ensuring a clean removal and restoration of the system's default configuration.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dougsland dougsland removed the request for review from nsednev January 27, 2026 16:42
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • The %post script unconditionally overwrites /etc/pam.d/systemd-user with the qm-wayland variant on install/upgrade; consider using a drop-in or include mechanism instead of replacing the main PAM file to avoid clobbering local or upstream changes.
  • When restoring systemd-user.rpmsave in %postun, you may overwrite a newer version provided by systemd or local modifications; consider restoring only if the current file matches the qm-wayland variant or if it doesn’t exist.
  • To preserve file metadata, you might want to use cp -p (and similarly ensure permissions/ownership are correct) instead of cp -f when copying the PAM configuration in %post.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The %post script unconditionally overwrites /etc/pam.d/systemd-user with the qm-wayland variant on install/upgrade; consider using a drop-in or include mechanism instead of replacing the main PAM file to avoid clobbering local or upstream changes.
- When restoring systemd-user.rpmsave in %postun, you may overwrite a newer version provided by systemd or local modifications; consider restoring only if the current file matches the qm-wayland variant or if it doesn’t exist.
- To preserve file metadata, you might want to use cp -p (and similarly ensure permissions/ownership are correct) instead of cp -f when copying the PAM configuration in %post.

## Individual Comments

### Comment 1
<location> `rpm/wayland/qm-wayland.spec:74-79` </location>
<code_context>
 %post
+# Backup original systemd-user PAM config and replace with our version
+if [ $1 -eq 1 ] || [ $1 -eq 2 ]; then
+    if [ -f %{_sysconfdir}/pam.d/systemd-user ] && [ ! -L %{_sysconfdir}/pam.d/systemd-user ]; then
+        if [ ! -f %{_sysconfdir}/pam.d/systemd-user.rpmsave ]; then
+            cp -p %{_sysconfdir}/pam.d/systemd-user %{_sysconfdir}/pam.d/systemd-user.rpmsave
+        fi
+    fi
+    cp -f %{_sysconfdir}/pam.d/systemd-user.qm-wayland %{_sysconfdir}/pam.d/systemd-user
+fi
 %systemd_post qm-dbus.socket
</code_context>

<issue_to_address>
**issue (bug_risk):** Unconditional overwrite may modify the target of an existing symlink for systemd-user.

The backup step intentionally skips `systemd-user` when it’s a symlink, but the final `cp -f` always runs. If `systemd-user` is a symlink owned by another package or the admin, this will overwrite the symlink’s target instead of replacing a regular file. Please either skip this `cp` when `systemd-user` is a symlink or guard it (e.g., only run `cp` when `! -L`).
</issue_to_address>

### Comment 2
<location> `rpm/wayland/qm-wayland.spec:123` </location>
<code_context>
 %{_unitdir}/wayland-session.service
 %{_unitdir}/wayland.socket
-%{_sysconfdir}/pam.d/systemd-user
+%{_sysconfdir}/pam.d/systemd-user.qm-wayland
 %{_sysconfdir}/pam.d/wayland-autologin
 # Weston compositor configuration
</code_context>

<issue_to_address>
**suggestion (bug_risk):** Consider marking `systemd-user.qm-wayland` as a config file to preserve local edits.

Because this file is used as the source for `/etc/pam.d/systemd-user`, any local changes would be overwritten on upgrade. Declaring it as `%config` (likely `%config(noreplace)`) would let RPM preserve admin modifications across package updates.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread rpm/wayland/qm-wayland.spec Outdated
Comment thread rpm/wayland/qm-wayland.spec Outdated
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly avoids owning the systemd-user PAM configuration file by packaging a custom version and using scriptlets to manage it. The approach of backing up the original file on install and restoring it on uninstall is sound.

I've found a potential issue in the %post scriptlet where it could incorrectly handle a pre-existing symbolic link for systemd-user, leading to its replacement without a way to restore it. I've suggested a change to make this safer. I also have a minor suggestion to improve the robustness of the scriptlets by quoting variables. Overall, this is a good change that addresses the file ownership problem.

Comment thread rpm/wayland/qm-wayland.spec Outdated
Comment thread rpm/wayland/qm-wayland.spec Outdated
systemd-user is owned by systemd, we cannot define
%{_sysconfdir}/pam.d/systemd-user in the files.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
@Yarboa
Copy link
Copy Markdown
Collaborator

Yarboa commented Feb 2, 2026

@dougsland try to build the packages manually

@dougsland
Copy link
Copy Markdown
Member Author

/packit test

@dougsland
Copy link
Copy Markdown
Member Author

@dougsland try to build the packages manually

believe the failures are not related to the patch still validating the errors and re-running the jobs.

@dougsland
Copy link
Copy Markdown
Member Author

ci/cd errors not related to the patch.

@dougsland dougsland merged commit ed41340 into main Feb 6, 2026
24 of 26 checks passed
@dougsland dougsland deleted the qmwayland-systemd branch February 6, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error: Transaction test error: /etc/pam.d/systemd-user from install of qm-wayland conflicts with file from package systemd

2 participants