Skip to content
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

RPM fails to install paths when a path is a directory and marked with "%config" flag #2890

Closed
rmetrich opened this issue Feb 7, 2024 · 0 comments · Fixed by #2906
Closed
Assignees
Labels

Comments

@rmetrich
Copy link

rmetrich commented Feb 7, 2024

Describe the bug

A Red Hat customer is using the gradle plugin to build his RPM packages.
When using a snippet as shown below, it ends up creating a RPM with directories marked with %config flag, e.g.:

from ('src'){
    fileType CONFIG
    into '/opt/foo/bar'
    createDirectoryEntry true
    addParentDirs false
}
fileMode = 0755

ends up getting a RPM with /opt/foo/bar being tagged:

# rpm -qp --qf "[%{filenames} %{fileflags:fflags} \n]"  ~/foo-1.0.noarch.rpm
/opt/foo/bar c
/opt/foo/bar/somedir c
/opt/foo/bar/somefile c

This leads to getting the following error when installing the package with latest RPM found on Fedora 38 (rpm-4.18.2-1.fc38) and RHEL8 (rpm-4.14.3-28.el8_9), in case /opt/foo/bar doesn't already exist:

# rpm -i ~/foo-1.0.noarch.rpm 
error: failed to open dir platform of /opt/foo/bar/: No such file or directory
error: unpacking of archive failed on file /opt/foo/bar/somedir: cpio: open failed - No such file or directory
error: foo-1.0.noarch: install failed

On RHEL8, such package could be installed with older releases of RPM, up to rpm-4.14.3-26.el8 included, i.e. before fixing CVE-2021-35937, CVE-2021-35938 and CVE-2021-35939.

We believe (@ffesti and myself) that tagging a directory with %config flag is an error, the flag should only be used with regular files.

Could you please confirm it's indeed an error to flag directories with %config flag.
If so, would it be possible to harden RPM to fail with a different error, clearly stating the RPM is not following the spec.

To Reproduce
Steps to reproduce the behavior:

I don't know, this seems to require gradle plugin.

@ffesti ffesti added the bug label Feb 7, 2024
ffesti added a commit to ffesti/rpm that referenced this issue Feb 13, 2024
%config is only allowed for regular files and links. While rpmbuild won't
produce package with other files with %config other tools might. Handle
these cases gracefully by ignoring the %config flag.

Resolves: rpm-software-management#2890
dmnks pushed a commit that referenced this issue Feb 21, 2024
%config is only allowed for regular files and links. While rpmbuild won't
produce package with other files with %config other tools might. Handle
these cases gracefully by ignoring the %config flag.

Resolves: #2890
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants