Skip to content

module: Warn if module config file is inaccessible #1695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Feb 7, 2025

module: Warn if module config file is inaccessible

If a DNF module configuration file is unreadable, dnf may return unexpected results without warning the user, potentially affecting command output.

Steps to reproduce:

  1. Enable the nginx module as root with a restrictive umask, making the config file unreadable for normal users:
   # umask 0066
   # dnf module enable nginx:1.24
   # ls -l /etc/dnf/modules.d/nginx.module
   -rw-------. 1 root root 55 Oct 16 09:59 /etc/dnf/modules.d/nginx.module
  1. Check available packages as root (CORRECT):
   # dnf list --available nginx
   [...]
   Available Packages
   nginx.x86_64            1:1.24.0-1.module+el9.4.0+21950+8ebc21e2.1
  1. Check available packages as a normal user (INCORRECT):
   $ dnf list --available nginx
   [...]
   Available Packages
   nginx.x86_64            1:1.20.1-16.el9_4.1

This patch introduces a warning when a module config file exists but is inaccessible, helping users diagnose potential issues:

   $ dnf list --available nginx
   [...]
   Cannot read "/etc/dnf/modules.d/nginx.module". Modular filtering may be affected.
   Available Packages
   nginx.x86_64            1:1.20.1-16.el9_4.1

Resolves: https://issues.redhat.com/browse/RHEL-62833
Test: rpm-software-management/ci-dnf-stack#1628

In some cases, we need to distinguish between a missing config file and
one that exists but is unreadable (e.g., due to insufficient
permissions).

This patch introduces a new FileDoesNotExist exception class, which is a
more specific subclass of the existing CantOpenFile class. This ensures
that any existing workflows remain unaffected.
If a DNF module configuration file is unreadable, `dnf` may return
unexpected results without warning the user, potentially affecting
command output.

Steps to reproduce:

1. Enable the `nginx` module as root with a restrictive `umask`, making
   the config file unreadable for normal users:

   # umask 0066
   # dnf module enable nginx:1.24
   # ls -l /etc/dnf/modules.d/nginx.module
   -rw-------. 1 root root 55 Oct 16 09:59 /etc/dnf/modules.d/nginx.module

2. Check available packages as root (CORRECT):

   # dnf list --available nginx
   [...]
   Available Packages
   nginx.x86_64            1:1.24.0-1.module+el9.4.0+21950+8ebc21e2.1

3. Check available packages as a normal user (INCORRECT):

   $ dnf list --available nginx
   [...]
   Available Packages
   nginx.x86_64            1:1.20.1-16.el9_4.1

This patch introduces a warning when a module config file exists but is
inaccessible, helping users diagnose potential issues:

   $ dnf list --available nginx
   [...]
   Cannot read "/etc/dnf/modules.d/nginx.module". Modular filtering may be affected.
   Available Packages
   nginx.x86_64            1:1.20.1-16.el9_4.1

Resolves: https://issues.redhat.com/browse/RHEL-62833
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

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

Thanks!

@kontura kontura merged commit 28805cd into dnf-4-master Feb 18, 2025
7 of 11 checks passed
@kontura kontura deleted the mblaha/inaccessible-module branch February 18, 2025 06:48
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.

2 participants