Commit Graph

16575 Commits

Author SHA1 Message Date
Panu Matilainen c110ad11c3 Fix segfault on %{?getncpus}, regression in 4.19.x
Commit deaebd0c89 assumed there would
always be args, but in the macro existence test none are set up.

Reported as a side-issue in https://issues.redhat.com/browse/RHEL-16557
2023-11-16 11:24:09 +02:00
Panu Matilainen 01fb42d42c Document pgpPrtParamsSubkeys() returning only signing-capable keys
Since commit a9cca032a2 we've only
returned signing capable subkeys, but this has seemed like an
implementation detail. Make it explicit.

Fixes: #2515
2023-11-15 14:44:42 +02:00
Panu Matilainen 6714ec7068 Fix %{getncpus proc/thread} potentially returning zero
Add the missing sanity check/fixup for memory starved systems where
we end up returning zero cpus. Should've been in commit
deaebd0c89 originally.

Reported in https://issues.redhat.com/browse/RHEL-16557
2023-11-15 09:31:37 +02:00
Panu Matilainen 0091214d2f Add a test-case for invalid intermediate symlink owner (CVE-2021-35939)
This should've been in commit 96ec957e28
but back then we didn't have a good way to test ownership matters.
2023-11-14 12:11:02 +02:00
Panu Matilainen 89ce4e7ca5 Fix wrong return code on O_DIRECTORY open of invalid symlink
The dir argument to fsmOpenpath() is supposed to be a rough O_DIRECTORY
equivalent, and if the path is actually a misowned symlink it should
return ENOTDIR instead of ELOOP. Makes the resulting error messages
at least a little more comprehensible.
2023-11-14 12:11:02 +02:00
Panu Matilainen 2c20f9677e Allow version to be omitted in the replace test spec 2023-11-14 12:11:02 +02:00
Panu Matilainen 833cd91bed Replace rpm2cpio by rpm2archive entirely
Now that rpm2archive knows how to impersonate rpm2cpio when called by
that name, we can just drop the latter entirely. The one notable
behavior change is src.rpm contents now getting ./ prepended to the
paths. We could fixup for that too, but there's doesn't seem to be
any reason to bother.

It's crucial that we start steering people away from rpm2cpio because it
wont be able to deal with v6 content. cpio is obsolete even in POSIX now.
2023-11-10 16:05:30 +02:00
Panu Matilainen 3151a18740 Refactor / cleanup rpm2archive entry fillup a bit
Do all the entry fillup in the function intended for that,
no functional changes intended. Drop the unnecessary nlink check
from the unpacking: if there's content, it should unpacked.
2023-11-10 16:05:30 +02:00
Panu Matilainen f6b47609a9 Document rpm2cpio as obsolete, add pointer to rpm2archive. 2023-11-10 16:05:30 +02:00
Panu Matilainen 04d49fbd2f Add cpio format support to rpm2archive
cpio is a legacy format but content in that format will remain with us
for a very, very, very long time still. Better support the format here
than have to support a separate tool just for the purpose.

The "new ascii cpio" format can't host files larger than 4GB, but
most rpm content fits and will continue to do so in that range easily,
so instead of just outlawing the good 'ole format, just skip over
anything we can't handle and emit a warning.

Additionally, if invoked as "rpm2cpio", behave like it: no compression,
cpio format.
2023-11-10 16:05:30 +02:00
Panu Matilainen b86f6ad4f0 Fix uid, gid and nlinks not getting populated by rpm2archive
Take advantage of rpmfiStat() and archive_entry_copy_stat() which
handle most of the dirty work here. Hardlink sizes are special because
in archives, the file size is 0 except for the one with the content,
but otherwise of course hardlinked files have sizes as usual.
2023-11-10 16:05:30 +02:00
Panu Matilainen fa1fbe95ed At least try to handle write errors in rpm2archive 2023-11-10 16:05:30 +02:00
Panu Matilainen 80d5fc3c9e Fix some invalid rpm2cpio invocations in the test-suite
runroot is the wrong thing to use with rpm2cpio which doesn't understand
things like --define. This has only worked because rpm2cpio is dumb
enough not to look at its arguments at all.
2023-11-10 16:05:30 +02:00
Panu Matilainen 243deae923 Use the expected rpm2cpio-like syntax for rpm2archive tests 2023-11-10 16:05:30 +02:00
Panu Matilainen d49e26498e Split the two rpm2archive tests to separate test-cases
No actual change, just allows more comprehensive testing, easier to
read and add more.
2023-11-10 16:05:30 +02:00
Panu Matilainen 7d3d9041af Fix sbit removal if fchmodat() doesn't support AT_SYMLINK_NOFOLLOW
glibc versions prior to 2020 know about AT_SYMLINK_NOFOLLOW but don't
actually implement it for fchmodat() and returns ENOSYS when used.
We don't check the return code in removeSBITS() so this silently fails
on those older versions.

We already verify the thing is not a link in the fstatat() condition
because cap_set_fileat() doesn't have any "dont follow" mode at all,
so we can just as well drop it from the fchmodat() and make this
work on more libc versions.

Add a test for the suid bit removal while at it.
2023-11-10 11:25:43 +02:00
Panu Matilainen e3ab8a9871 Split the dependency generation test into individual checks
No actual changes, just makes it much easier to read + work with.
2023-11-09 16:09:49 +02:00
Dirk Müller 4d219ed463 Switch brp-compress to bash
commit f3f763e54d introduced the use of 'read -d' which is
bash specific.

Signed-off-by: Dirk Müller <dirk@dmllr.de>
2023-11-09 15:48:57 +02:00
Michal Domonkos f851bce1ef Adapt Dockerfile.fedora to F39
The fedora-repos-modular package is gone from F39.  This commit makes
the Dockerfile work on a F39 host with the mktree.oci backend since we
override the release with "podman build --from fedora:39 ..." there.
2023-11-09 08:42:43 +02:00
Michal Domonkos bb1eeb4913 Allow SOURCE_DATE_EPOCH=0 again
Commit 11132fc21f assumed that the value
of 0 is never used in practice and thus used it to indicate "disabled",
however that assumption has turned out to be wrong because ostree uses
precisely that value as mtime in inodes, which in turn breaks existing
workflows in this space (see the associated ticket).

Fix this by reverting the above commit (except leaving source_date_epoch
initialized to 0, to prevent GCC warnings as mentioned in that commit).

As to why not just initialize source_date_epoch to -1: time_t happens to
be a signed integer on most platforms but POSIX doesn't specify its
signed-ness.

Add some accompanying tests too.

Fixes: #2679
2023-11-09 08:42:21 +02:00
Florian Festi 7a65f68d9c Set %_sharedstatedir to %{_var}/lib
Configure traditionally sets it to %{_prefix}/com which RPM has followed
so far. But this directory is not used anywhere and everybody changes
the location to /var/lib. This also changes the default for the %configure
macro. This is safe as everyone that cares about the the sharedstatedir
had to set it manually anyway.

Resolves: #2092
2023-11-08 09:27:59 +02:00
Takuya Wakazono 17f72c4e7f Fix a macro in the comment
Nothing defines RPMHOME, replace it with RPM_CONFIGDIR.
2023-11-08 09:17:42 +02:00
Florian Festi 5d5dc60769 Move OpenSSL code to newer API from version 3.0
Avoid the now deprecated RSA and DSA data types and use the generic EVP_PKEY

Resolves: #2294
2023-11-07 10:11:08 +02:00
Panu Matilainen f9ae0a4da8 Refactor %__file_lineno management into an auxiliary macro
Now that we can, just define __file_lineno as an auxiliary macro that
only does any work in the rare case where an error or warning occurred.
This saves an enormous amount of huffing and puffing defining and
undefining macros that are not used at all in the normal paths, on
every rpm startup and spec parse.

Technically we could use a common macro function for both but as they're
in separate libraries, this doesn't seem worth the few lines of saving.
2023-11-07 10:09:52 +02:00
Panu Matilainen a8ec768950 Fix comment line handling in sysusers.d(8) files
sysusers.d(8) format permits empty lines and commits, and so must we.
Add some extra fluff to the test-case for this.

This is the second half of
https://bugzilla.redhat.com/show_bug.cgi?id=2246236

Fixes: #2741
2023-11-07 10:09:38 +02:00
Panu Matilainen 43cf645fc1 Handle unsupported 'r' and 'm' sysusers types more gracefully
People will want to use existing sysusers.d files through rpm and while
we don't support 'r' and 'm' at this time, we shouldn't really call
them "invalid" and error out. Issue a warning instead, and ignore.

This is the first half of
https://bugzilla.redhat.com/show_bug.cgi?id=2246236
2023-11-07 10:09:38 +02:00
Panu Matilainen d141c874b3 Fix an apparent thinko/typo in the sysusers test spec
I'm quite sure I didn't really intend to test duplicate files behavior
here...
2023-11-07 10:09:38 +02:00
Panu Matilainen 22e177f428 Use macro error reporting for %add_sysuser errors
Lua has error() but no warning() (obviously) which we'll want in the next
step, so for consistency lets just use macro.error() instead.
2023-11-07 10:09:38 +02:00
Panu Matilainen 173b737f40 Expose and document rpmdb --verifydb operation
After years of BDB, sometimes folks just want some assurance that their db
is still fine. Properly exposing an operation to do so hopefully makes
less likely to poke at the db directly (with eg sqlite3 command).
2023-11-06 15:58:54 +02:00
Panu Matilainen e85a8a6369 Document rpmdb --exportdb and --importdb switches + minor other tweaks 2023-11-06 15:58:07 +02:00
Panu Matilainen f8b4c99bd8 Properly document our different macro types and their scopes 2023-11-06 12:35:56 +02:00
Michal Domonkos 302793af0b Exit from mktree on failure
Right now, if the podman image fails to build or rpm fails to
build/install, we happily continue and run the test-suite, only to
eventually fail with some cryptic error, such as:

    error: cannot find rpm

Not too helpful, indeed.  Instead, just fail the whole tree preparation
process if we encounter an error.

Fix the return code of unshared() so that we don't fail on that, though.
Also, when building the RPM layer, use a proper cleanup trap instead of
ignoring SIGINT since a failing make_install() can now terminate the
script.

Fixes: #2667
2023-11-01 09:27:05 +02:00
Michal Domonkos 05c3b37d1f Rename mktree.podman to mktree.oci
This name is a better fit as it puts more emphasis on the format of the
resulting tree, not as much on the actual container engine used (which
can be swapped, and currently is in the CI where we use docker instead
of podman).

Also drop the awkward .docker symlink now and instead pass the container
engine through the MKTREE_ENGINE environment variable.
2023-10-31 14:53:29 +02:00
Michal Domonkos 15897bca7f Remove sudo from GH workflow
Turns out the docker command in CI is set up such that it doesn't need
an explicit sudo, so remove it.  This will also allow us to easily pass
environment variables to mktree in the next commit (as otherwise we'd
have to use the ugly -E, --preserve-env option).

No functional change.
2023-10-31 14:53:29 +02:00
Michal Domonkos 47067768a3 Remove function keywords from atlocal
These are bashism, not really needed.
2023-10-31 14:53:29 +02:00
Michal Domonkos c7ed626fbf Move snapshot() back to atlocal
Commit 09e472040a moved the snapshot
function to mktree.common so that we could later use it in non-cmake
mode (outside of the build directory) too, to containerize rpmtests
itself.  In the end, however, we've decided to just use Podman/Docker
for the outer container as it simplifies things.

Therefore, the snapshot function is no longer needed outside of the
test-suite, it's an internal implementation detail at this point which
doesn't have anything to do with mktree, so move it back to atlocal
where it really belongs.

As a bonus, the rpmtests wrapper can now be simplified a bit more, too.

No functional change.
2023-10-31 14:53:29 +02:00
Michal Domonkos 93eef6d3a2 Standardize on OCI images in test-suite
Instead of manually bootstrapping our own base "image" using a host
specific script, just use the official, prebuilt OCI images with
Podman/Docker.  This has several advantages:

- Standard, ubiquitous OCI images (easy support for other distros)
- No manual setup of DNF, RPM macros, user namespaces and whatnot
- Single recipe (Dockerfile) for both the local and CI purposes
- Outsourced image caching (Podman/Docker storage)
- Faster (just downloads the prebuilt image)
- Less dependencies on the host

Now that we've prepared mktree.podman for local use, just switch to it
in cmake and drop the Fedora backend.  Update the docs and comments
accordingly, too, those should explain the details.

Fixes: #2643
2023-10-31 14:53:29 +02:00
Michal Domonkos 1a7956e008 Add native mode to mktree.podman
Instead of building RPM from scratch as part of the image, allow for
reusing the existing build artifacts on the host to produce the final
image.

This ensures we test the actual local build, not just the sources, and
speeds up the whole process, allowing it to be used for local
development as well.

No immediate effect, we'll hook this up to cmake in the next commit.
2023-10-31 14:53:29 +02:00
Michal Domonkos ec5ec79231 Add Dockerfile.fedora
Rename the existing Dockerfile and add a symlink for the original
filename.  This will allow for supporting other, non-Fedora, Linux
distros in the future and is a prerequisite for the next commits.
2023-10-31 14:53:29 +02:00
Michal Domonkos fe0c09f16f Only rebuild the RPM test layer
Right now, we build and tag a new image on each mktree.podman run.  This
causes an unnecessary buildup of images over time that needs to be
manually cleaned with podman-image-prune(1).  Instead, tag the base
layer and then only rebuild the RPM layer.
2023-10-31 14:53:29 +02:00
Michal Domonkos 5fd2e028b0 Bind mount $PWD at /srv in test container
This is another step towards the unified OCI backend, no functional
change yet.
2023-10-31 14:53:29 +02:00
Michal Domonkos b1eed579f0 Use --log only if running from source dir
Log mode is mostly useful in the CI environment so don't enable it by
default.  This is another step towards the unified OCI backend.

No functional change.
2023-10-31 14:53:29 +02:00
Michal Domonkos f59100b3e7 Use the new --shell command in mktree.podman 2023-10-31 14:53:29 +02:00
Michal Domonkos 0dc534891c Add --shell command to rpmtests wrapper
This invokes an interactive shell in a dummy test where all the usual
test commands work, and is meant as a replacement for what mktree.fedora
currently does for its shell/atshell commands.  This feature basically
emulates a single test so it really belongs to the rpmtests wrapper, not
mktree.

For consistency, also do the permission fixup for rpmtests.dir (just
like in mktree.fedora), this will be needed once we drop mktree.fedora.
2023-10-31 14:53:29 +02:00
Michal Domonkos 9ae317a81b Refactor rpmtests wrapper
Don't symlink rpmtests itself, we can run it directly from the
installation directory in the test tree.  This eliminates some extra
cd-ing.

No functional change.
2023-10-31 14:53:29 +02:00
Panu Matilainen 61000db0bc Add a blurb about portability expecations to contributing guidelines 2023-10-31 13:41:25 +02:00
MridulSharma03 6e93ab1eb6
Fix typos 2023-10-31 08:52:08 +01:00
Panu Matilainen 283935b920 Implement prepend and append modes for all build scriptlets
Allows %prep, %conf, %build, %install, %check, %clean and %generate_depends
to be augmented arbitrary number of times by appending or prepending to
them. The main use-case is to support automatic population of these
sections (declarative builds) while still allowing packagers to easily
tweak them, but could also be useful for complicated conditional specs
and such.

Related: #1087
2023-10-27 11:07:48 +03:00
Panu Matilainen 064ba642f6 Drop now unnecessary spec parse hack, no functional changes 2023-10-27 10:08:04 +03:00
Panu Matilainen 7639512c5d Convert %prep into a regular build scriptlet
Now that we can, implement %setup and %patch as auxiliary macros that are
defined only during %prep parsing. And voila, %prep is no longer special
at all. Not much anyhow.

Notably rpmspec --parse now emits %build where it belongs.
The error message on %patchN is now very much an ugly hack, but at least
it's something we can drop one sunny day.

Fixes: #2205
2023-10-27 10:08:04 +03:00