Commit Graph

16575 Commits

Author SHA1 Message Date
Michal Domonkos adafe8d047 Replace AT_CHECK and AT_CLEANUP with RPMTEST_*
We're going to do some stuff before and after these macros in the next
commits/PRs so better do this beforehand.
2023-07-05 13:41:03 +03:00
Panu Matilainen 2d68e5feda Silence mknod "failure" in the test-suite setup
We're only testing whether mknod is usable or not, so a failure is not a
failure, just information. Silence the distracting message.
2023-07-05 13:25:09 +03:00
Panu Matilainen b22ab58460 Drop bogus %{?dist} from test-suite specs
The only thing that %{?dist} conditional achieves is breaking the test
if defined.
2023-07-05 11:57:02 +02:00
Panu Matilainen a09f68e4f4 Fix library version test to only look for ourn own libraries
This causes a bogus failure when there's something else in the
same directory.
2023-07-05 11:57:02 +02:00
Panu Matilainen 36c48df0fe Test user-creation + verify in a --root operation 2023-07-04 10:09:47 +03:00
Panu Matilainen fe645f822d Simplify rpmug caching
The simple cache whose efficiency troubled ewt back in 1997
(see commit 97999ce92c)
has proven more than adequate over the years.

In a local testcase based on Fedora 33 server iso contents, an install
of 1765 packages consisting of 201344 files did a whopping 27 user +
groups combined. So a few more alloc+free is not going to make the
damnest difference, don't bother with reallocing the cache buffer, just
strdup() a new one when needed.
2023-07-04 10:09:47 +03:00
Panu Matilainen f3eaeeb734 Make user/group info reliable operation across chroot
There's no telling what sort of caching getpwnam() and friends perform
behind the scenes, and worse, there's no way to explicitly reset those
caches. This can lead to chrooted operations using user/group data from
the host, which is simply wrong.

Do our own parsing of /etc/passwd and /etc/group to fix. Besides the
chroot matter, we then only ever lookup local system users and groups
and not something from eg network name services. We cannot reliably
do NSS in a chroot because doing so would require relying on binaries
in the chroot, which in itself is completely unreliable. NSS is also
unreliable in various rescue mode situations. Bottom line, local files
are the only ones that can be guaranteed for rpm operation, and this
change basically enforces that.

Technically we should track chroot status for each lookup and flush the
cache if the state changed, but this is an internal API and rpm usages
only ever call it from one side of the chroot for a given operation.

Fixes: #882, #1789
2023-07-04 10:09:47 +03:00
Panu Matilainen 9de8502fc6 Mention systemd dynamic user feature in user/group manual
Suggested by Colin Walters.
2023-07-03 10:36:09 +03:00
Panu Matilainen 9e24ba1269 Unset RPM_CONFIG_DIR for package building scripts 2023-06-30 14:22:11 +03:00
Panu Matilainen 00085e2b1f Bump version to mark the beginning of a new devel cycle 2023-06-28 13:58:39 +03:00
Panu Matilainen 909fd823f1 Ensure reproducability test runs with hard requires for user/group
This distro tunable can throw off the results by quite a bit.
2023-06-28 13:50:22 +03:00
Panu Matilainen 7ec148c1d6 Fix reproducability test --define usage
--define's should never start with % because it can cause unexpected
expansions to take place, causing the define to do something else than
intended.
2023-06-28 13:46:22 +03:00
Panu Matilainen 0aca51b138 Require real names for contributions
Real names in git commits has always been the expectation, even if there
have been some slippages. Make it an explicit requirement so the
contributors know what to expect.
2023-06-28 11:08:00 +03:00
Panu Matilainen 6f5d9b4677 Really handle hardlinks in the rpmunpack python example, doh 2023-06-27 15:19:49 +03:00
Panu Matilainen 9e3bb9fd43 Add some Python binding examples
It's not whether these are particularly important examples or not
(they're not), but adding more will be so much easier once the place
to add them has been established.

Fixes: #2075
2023-06-27 14:18:42 +03:00
Fabian Vogt 911a4f253c Actually return an error in parseScript if parsing fails
The return value is stored in the "res" variable which is set to the return
value of parseLines early in the function. Past that point, any "goto exit;"
caused the function to return success. This was introduced by 52ce88851a
("Port parseScript() to use parseLines(), no functional changes"). To fix it,
reintroduce the nextPart variable.
2023-06-27 13:47:40 +03:00
Panu Matilainen ea3187cfcf Don't muck with per-process global sqlite configuration from the db backend
sqlite3_config() affects all in-process uses of sqlite. librpm being a
low-level library, it has no business whatsoever making such decisions
for the applications running on top of it. Besides that, the callback can
easily end up pointing to an already closed database, causing an
innocent API user to crash in librpm on an entirely unrelated error on
some other database. "Oops."

The sqlite API doesn't seem to provide any per-db or non-global context
for logging errors, thus we can only remove the call and let sqlite output
errors the way it pleases (print through stderr, presumably).

Thanks to Jan Palus for spotting and reporting!
2023-06-26 13:03:30 +03:00
Panu Matilainen 27c2a7ba97 Drop unnecessary internal includes from the fsverity plugin
Same as 995d1b3fc9, don't know how I
missed this despite actually looking.
2023-06-20 12:14:08 +03:00
Fabian Vogt d4bf132d6b For completeness, make sure CPUID leaf 7 is supported before using it
It's theoretically possible for a x86-64-v2 compatible processor to not
have CPUID leaf 7, in which case it returns the data for a lower leaf instead
(instead of a sensible value of all zeros...). While this is already covered
by the use of __builtin_cpu_supports now, do it explicitly for completeness.
2023-06-20 10:26:06 +03:00
Fabian Vogt 34d657bfa8 Use __builtin_cpu_supports in x86-64 CPU feature level detection
Just CPUID is not enough and neither is just __builtin_cpu_supports,
so use both.

Fixes: #2463
2023-06-20 10:26:06 +03:00
Panu Matilainen 7072b2d2b9 Fix per-file plugin hook regression introduced in 4.18
Commit 6dd62720fe neglected to update
rpmpluginsCallFsmFilePost() to pass the absolute path in the case
of unowned directories. Because in that case there's no rpmfi to
pass to the plugin in that case, there's simply no way for the plugin
to know what path is being manipulated. Oops.

Fixes: #2543
2023-06-20 10:11:20 +03:00
Panu Matilainen cebdb1e88a Document spec parse recursing at BuildArch
Fixes: #2545
2023-06-20 09:49:57 +03:00
Panu Matilainen 3a50688558 Fix rpmDigestBundleFinal() and Update() return code on invalid arguments
Discovered via #2548, these functions merrily return zero for success
when passed NULL data. In rpm nothing bothers to check for their return
codes but it doesn't mean it's the right thing to do
2023-06-20 09:37:57 +03:00
Florian Festi ced4d24f08 Only add arch, os and platform, self-provides once
per package even if we do multiple parse passes. This is a quick fix for
the dynamic spec feature that executes the parsing code multiple times.

This needs to be sorted out properly to only do the necessary things
(for the build scripts) here and postpone everything else after the
secondary parses. But that requires larger changes.
2023-06-19 11:42:24 +03:00
yuxiaojun 8ec9cfc81c Fix possible null pointer reference in ndb
slot1 and slot2 may be NULL

Signed-off-by: yuxiaojun <yuxiaojun1011@outlook.com>
2023-06-14 09:46:53 +03:00
Panu Matilainen 119350cd9a Show the tag number for unknown tags in --xml output
--xml is only really useful for diagnostics, and for that purpose in
particular, showing "(unknown)" text instead of the tag number
for unknown tags is just offensively dumb. No more!
2023-06-13 14:58:09 +03:00
Ralf Habacker 0830d4876b Add doc note that getopt processing only supports short options
See #2541
2023-06-13 13:58:51 +03:00
Ralf Habacker c8f06a5353 Add doc note about 'disabled option processing'
See #2541
2023-06-13 13:58:51 +03:00
Panu Matilainen 995d1b3fc9 Drop unnecessary internal includes from the IMA plugin 2023-06-13 12:57:26 +03:00
Florian Festi df8d1fb1b3 Add %specpartsdir to macros.in
so it can be configured from the spec file

Also move the dir beside the %buildsubdir as %{buildsubdir}-SPECPARTS so
it doesn't pollute the %buildsubdir.

Resolves: #2532
2023-06-13 12:04:54 +03:00
Panu Matilainen 9fce490988 Fix error handling of rpm.execute() and rpm.redirect2null()
The error handling of these Lua functions is wrong in so many ways I
wont list them all here, but eg. rpm.execute() tries to find an
strerror() string for an exit code of a process, returns a waitpid()
error with code 0 and string "success" and rpm.redirect2null() always
returns a failure despite success and never any meaningful error code.
The latter probably did the right thing when it was in lposix.c but
the pushresult() and pusherror() versions in rpmlua.c are rather
different.

To sort the mess, handle the actual error code checking at call site
and the pushfoo() functions do just that: push the result on the stack
and nothing else. Add some test-cases to go.

Fixes: #2528
2023-06-13 11:58:19 +03:00
Arun Ajith S 26d3802390 rpmrc: Fix how x86 models are derived
The code to autodetect x86 CPU model runs the cpuid instruction after
setting up 1 in eax. This gives the processor signature back in eax
which encodes the model number.

As per Intel Application Note 485 and AMD publication #25481, when
deriving model, we should look at both the base model in eax[7:4] and
the extended model in eax[19:16]. However current code is only looking
at base model and this causes some newer CPUs like Icelake(Model 0x6a)
to be detected wrongly as Pentium 3(Model 0x0a).

Note that this code is only exercised when rpm is built as 32-bit
binary because all of this is within a `#if defined(__i386__)`.

Because of this misdetection on Icelake, `setarch x86_64 rpm --showrc`
has `pentium3` as the `installed arch` instead of the expected `x86_64`.
It doesn't have `x86_64` as one of the `compatible archs` as expected.
Attempting to install a x86_64 rpm with `setarch x86_64 rpm -i` is
failing with `is intended for a different architecture` errors.

```
ARCHITECTURE AND OS:
build arch            : i386
compatible build archs: pentium3 i686 i586 i486 i386 noarch fat
build os              : Linux
compatible build os's : Linux
install arch          : pentium3
install os            : Linux
compatible archs      : pentium3 i686 i586 i486 i386 noarch fat
compatible os's       : Linux
```

Fix the code to also consider extended model and extended family when
applicable. The implementation is similar to the one in the linuxi
kernel.

References:
https://www.scss.tcd.ie/~jones/CS4021/processor-identification-cpuid-instruction-note.pdf
https://www.amd.com/system/files/TechDocs/25481.pdf
https://elixir.bootlin.com/linux/v6.3.6/source/arch/x86/lib/cpu.c#L19

Fixes: #2535
2023-06-09 10:17:25 +03:00
Florian Festi e9f95c5985 Add RPM_LD_FLAGS to build environment
Added in Fedora in 2011 to allow to %define _hardened_build 1 in one's
specfile and have all the necessary gcc and ld flags configured in the
common cases.

See also rhbz#728974 and FESCO ticket 563 (https://pagure.io/fesco/issue/563)
2023-06-08 12:13:49 +03:00
Florian Festi 51c596a6c8 Move dbus announce plugin config to DATADIR
Users are not supposed to meddle with this. So it really should not go
into /etc.

Use the DATADIR from dbus-1 and not our own install prefix.

Resolves: #2474
2023-06-05 10:18:39 +03:00
Panu Matilainen 6caf2a5f58 Remove obscure check for package build time from --rebuilddb (#2527)
Back in 1997, commit be0b90359b added a
sanity check for --rebuilddb operation, skipping headers which lack
some basic tags. Name, version and release are real requirements for
packages, but checking for buildtime is odd, and plain wrong.
Yes, we expect that to be present in packages built by rpm, but that's
not used for any processing and certainly is not required for a package
to be installable. And if it can be installed then it can't be
right to throw it away when rebuilding, leaving untrackable orphan
files in the process.

It is also documented as informational and optional by LSB. While
severely outdated, it is right on this account.

Fixes: #2527
2023-06-01 10:47:46 +03:00
Panu Matilainen 9f568c459e Export rpmGlobPath() to Lua as rpm.glob()
Lua doesn't ship with batteries, or glob functionality. It's not
unthinkable that packagers and macro writers may find globbing useful
in this space.
2023-05-30 12:10:10 +03:00
Panu Matilainen 636eaddf03 Fix Lua docs rpmio mode table rendering (missing newline) 2023-05-30 11:52:58 +03:00
Panu Matilainen b38077eae0 Add %{rpmversion} builtin macro for getting the running rpm version
Seems like a useful thing to have, and a bit crazy that we haven't had any
reasonable mechanism for this before now.

Fixes: #2523
2023-05-30 10:34:08 +03:00
Panu Matilainen 83413bfd39 Revert %_smp_build_ncpus change to a parametric macro (RhBug:2210347)
Commit a213101bc3 changed %_smp_build_ncpus
into a parametric macro, but this breaks common usage via the Lua macros
table as parametric macros are returned as closures rather than the
expanded value.

This seems like a design flaw of the macros table, but as an immediate
remedy for the breakage, add another layer of indirection to revert
%_smp_build_ncpus back to a non-parametric macro.

Fixes %constrain_build macro in Fedora, which ironically is made obsolete by
the change that (unintentionally) broke it.
2023-05-29 11:04:51 +03:00
Panu Matilainen 015c829c76 Macro documentation improvements
Use tables where they make sense, group builtins by category that
can be linked to, add version introduced where relevant. In addition,
some awkward/misleading wordings fixed.
2023-05-26 11:19:22 +03:00
Panu Matilainen 03525592c9 Fix a copy-paste --help description of --whatconflicts (RhBug:2208661) 2023-05-23 12:46:22 +03:00
Panu Matilainen acfe252822 Fix undefined symbols from plugins in some circumstances
Another bit lost in the cmake transition: plugin linkage to librpm and
librpmio. In rpm itself this doesn't really matter because the running
process supplies the necessary symbols but it's a different story when eg
a Python process uses dlopen()'ed bindings.
2023-05-22 17:29:23 +02:00
Florian Festi 021a7d3aaa Use mkdir -p for creating SPECPARTS dir
to not error out when invoking %setup more than once or shipping the
directory in the sources.
2023-05-17 17:40:11 +02:00
Michal Domonkos 2df8008d22 Enable large file support on 32-bit systems again
Replace 32-bit sizes in types like off_t with 64-bits when building on
32-bit architectures, to enable large file support there.

This fixes a nasty regression introduced in the cmake transition.  As
autotools would set this flag to 64 automatically for us, applications
linking against librpm (such as libdnf, librepo, libsolv or drpm) are
already adapted to that and are also building with the value of 64
(explicitly, we never exported this flag through pkg-config ourselves).
However, us suddenly expecting 32-bits in those types on 32-bit systems
can blow up badly e.g. in functions that take an off_t parameter, like
Fseek().

There perhaps aren't that many low-level users of librpm but drpm is one
such example where exactly this happens when built against our current
master.  It calls headerRead(), leading to Fseek() which receives a
64-bit offset parameter where it expects a 32-bit one, thus silently
overwriting the following parameter from 1 to 0 (SEEK_CUR to SEEK_SET)
which messes up the whole reading sequence in drpm's rpm_read(),
producing a failure in drpm's test suite that doesn't make any sense at
first sight.

While at it, also export the flag through pkg-config so that anyone
linking against librpm is now guaranteed to work correctly even if they
don't set the flag themselves (kudos to Petr Pisar for suggesting this).
2023-05-17 14:06:41 +02:00
Panu Matilainen 93ee7d9c61 Silence an apparent false positive warning from gcc in -Og mode
Haven't looked at the assembler but I don't see how xx could be
uninitialized by the time it gets to the if(), regardless of the
optimization used.
2023-05-11 09:30:10 +03:00
Panu Matilainen ae1b8c8c4e Test for the variable rather than it's expansion in cmake files
Testing for the expansion was a cmake newbie mistake that can go wrong
in weird ways, test for the variable instead, consistently. Don't try to be
clever with for-loops, just test for each case separately. This makes it
greppable as well.
2023-05-09 15:45:29 +03:00
Florian Festi d18d6ce41d Fix bzip2 detection
HAVE_BZLIB_H was not set due to a typo leading to the bz2 support not
being compiled in although the library was detected correctly.
2023-05-09 10:08:12 +03:00
Panu Matilainen 760eb86380 Verify user/group in tests when possible
Take advantage of root(less) aware $VERIFYOPTS added in commit
fb040f16ec.
2023-05-05 13:16:40 +03:00
Panu Matilainen f4c6fc4c17 Don't mask the user verify fail on invalid symlink test
This test only runs as root so let it do its job.
2023-05-05 13:16:40 +03:00
Panu Matilainen a97c376f37 Fix thinko in archive size tag(s) description
The archive size tags are on the uncompressed archive, an apparent
thinko in 5032470056.

Fixes: #2498
2023-05-03 11:03:22 +03:00