Commit Graph

15652 Commits

Author SHA1 Message Date
Demi Marie Obenour 1f03aba8b2 Check that the CRC length is correct
Also fix a memory leak in an error path.
2022-02-07 15:55:26 +02:00
Panu Matilainen 2a8d89a1c3 Reimplement --restore as a transaction element, obsolete --setperms & co
--setperms, --setugids and --setcaps were fun demos of alias capabilities
in the nineties, but they can be downright dangerous when used
separately, are blisfully unaware of all state in rpm yet try to
duplicate functionality existing in C, and thus are a constant source
of bugs that are between hard to impossible to fix in the alias space.

Add a new transaction element type for the restore operation, wire
through all the necessary places. In places (like ordering) this is
an overkill but otherwise it seems like a natural thing to be able
to process restore alongside package install/remove. The restore
operation is a cross between install and erase codepath-wise so touches
some funny places, but FA_TOUCH does just the thing, and now all the
regular disablers like --nocontext and --nocaps can be used if
necessary, plugins get to do their work and also timestamps are
restored.

Remove the dangerous shell implementations of things and just make them
aliases to --restore.

Fixes: #965
2022-02-03 13:47:28 +02:00
Panu Matilainen 99f8997082 Drop redundant argument from rpmcliTransaction()
The transaction knows the number of packages in it, it doesn't need
double-accounting really.
2022-02-03 13:47:28 +02:00
Panu Matilainen d9cbfdf95d Refactor Python addErase() argument parsing to helper method
We'll need this shortly to avoid repeating in another method.
2022-02-03 13:47:28 +02:00
Panu Matilainen a3b12f40f4 Refactor lowlevel element addition to a helper function 2022-02-03 13:47:28 +02:00
Panu Matilainen 0988ccb53a Really fix spurious %transfiletriggerpostun execution (RhBug:2023311)
Commit b3d672a552 got the base reasoning
in the ballpark but the code all wrong, introducing a severe performance
regression without actually fixing what it claimed to.

The missing incredient is actually comparing the current prefix with the
triggers in matched package (trying to describe this makes my head
spin): a package may have multiple triggers on multiple prefixes and
we need to make sure we only execute triggers of this type, from this
prefix.

This stuff really needs more and better testcases.

Fixes: b3d672a552
2022-02-02 14:11:19 +02:00
Panu Matilainen a26f665554 Bump hash for rpmdb cookie to SHA256 to appease FIPS
The rpmdb cookie is not a security feature, but as these existing
hashes are more convenient than coming up with our own... we then
run into the great big wall of FIPS which in its current incarnation
disallows use of SHA1. And so rpmdbCookie() fails under current FIPS.

Just bumping the algorithm to SHA256 seems the path of lowest
resistance, whether that algo makes sense for this purpose or not.
2022-01-31 12:00:22 +02:00
Florian Festi 6058b070b4 Make exit code reflect broken rcfile on --showrc
by checking for error log entries. Issues in the macro files also
trigger the EXIT_FAILURE exit code.

Resolves: #1796
2022-01-28 11:29:14 +02:00
Thomas Moschny e53b7e2008
Explicitly state that \0 is not supported in queryformat strings. (#1904)
* Explicitly state that \0 is not supported in queryformat strings.

Signed-off-by: Thomas Moschny <thomas.moschny@gmx.de>
Co-authored-by: Florian Festi <ffesti@redhat.com>
2022-01-28 09:26:34 +01:00
Panu Matilainen 482eaef4e5 Fix --justdb test depending on files outside the test-root
For whatever reason, `runroot_other test -d /foo` ends up testing
for `/foo` outside our test-root, which makes the test broken for what
it's supposed to test, and behave funny should somebody have a `/foo`
directory on their system.

Avoid having to test for the directory by ensuring it's always there,
this would still catch --justdb not working because then find would find
multiple files inside.
2022-01-27 09:58:01 +02:00
Panu Matilainen 36d8b37b0c Add emphasis to ask before working on rpm features 2022-01-26 17:01:24 +02:00
Demi Marie Obenour 714e606558 Fix bounds checks in public key parsing
If a public key was too short for the curve ID, the code would
previously perform out-of-bounds pointer arithmetic, which is undefined
behavior in C.  Check that the packet is long enough to contain the
curve ID before bumping `se` past the curve ID.

Furthermore, if a public key is too short to even contain the fixed-size
header, an out-of-bounds pointer would be created, which is also
undefined behavior.  Fix this by returning early if the buffer is too
short.

Finally, return early if the public key algorithm or curve ID is
invalid, rather than relying in processMpis() to fail.  While
processMpis() will error out, bailing out explicitly is much clearer.
2022-01-25 09:38:32 +01:00
Carlo Cabrera d5d743dcf3 Fix stat64 handling on Intel macOS
ad87ced fixed compilation for ARM64 macOS, but it broke builds on Intel
macOS.

Let's fix it by gating the changes from ad87ced behind
`_DARWIN_FEATURE_ONLY_64_BIT_INODE`. This macro is defined whenever the
ARM64 macOS fix is appropriate, but only after we've included
`sys/cdefs.h`.

This does mean that we're still using a deprecated API on Intel macOS
10.6+. I looked into avoiding this, but it seems to require more
significant refactoring. It's not clear that these changes would be
worth it given that Apple is slowly phasing out their Intel machines.
2022-01-25 08:18:06 +01:00
Panu Matilainen 51070554e2 Add test for --justdb to go 2022-01-25 08:11:18 +01:00
Panu Matilainen 6de0d31ed3 Add --justdb counterpart --nodb and matching API flag
Sometimes you just want to extract the files without touching the
database, just like sometimes you just want the database changed.
Potential use-cases include rpm2cpio style operation and src.rpm
install.
2022-01-25 08:11:18 +01:00
Dan Čermák 709dab9f78 Add a rpm_macro() provides generator
This commit adds a very simple provides generator for rpm macros as suggested on
the Fedora packaging mailing list:
https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.org/thread/DUFER7QAFYIBYDANJQQ37FBNL5YISZQ2/
2022-01-25 08:07:01 +01:00
Denys Vlasenko 8763969a4a Do not unset $MALLOC_CHECK_
How do we even _know_ user wants to debug malloc in rpmbuild,
maybe user wants to debug it in _the child_?

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
2022-01-24 14:35:24 +02:00
Panu Matilainen ed61ee28d0 Support relocatable packages in Lua scriptlets too (#1531)
Pass relocatable package prefixes as RPM_INSTALL_PREFIX Lua table
to Lua scriptlets, add a test-case.

In Lua, indexes start at 1 rather than 0, so the numbers appear
off by one which is annoying, but consistent within Lua and our other
similar Lua constructs such as scriptlet arg.

Fixes: #1531
2022-01-24 12:46:46 +01:00
Demi Marie Obenour fc8386be36 rpmkeys: exit non-zero on I/O errors
If writing to stdout or stderr fails, rpmkeys should exit with a
non-zero status code.
2022-01-21 15:44:28 +01:00
Michal Domonkos ed07a18773 Skip recorded symlinks in --setperms (RhBug:1900662)
If a package contains a symlink in the buildroot which is declared as a
ghost or config file but is a regular file or directory on the system
where it's installed, a --setperms call will reset its permissions to
those of a symlink (777 on Linux), which almost certainly is not the
correct thing to do.

To fix that, just skip files that were recorded as symlinks.

This is a special case of a general issue in --setperms; since file
permission semantics may change depending on the file type, to stay on
the safe side, any (ghost or config) file whose type changes after
installation should probably be skipped.  However, symlinks are the most
prominent case here, so let's just focus on that now and avoid adding
too much cleverness to a popt alias (this got us into trouble not too
long ago, see commits 38c2f6e and 0d83637).  We may revisit this in the
eventual C implementation.
2022-01-21 16:07:32 +02:00
Aleš Matěj c624966e13 Add an option for zstd long distance matching compression
The behavior is supposed to match the --long[=#] option of zstd binary.
2022-01-21 14:57:00 +01:00
Aleš Matěj 1fdf660ba5 Replace hardcoded min/max values for zstd compression levels 2022-01-21 14:57:00 +01:00
Ettore Atalan e9ef74ae2d Translated using Weblate (German)
Currently translated at 93.1% (825 of 886 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/de/

Translated using Weblate (German)

Currently translated at 92.2% (817 of 886 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/de/
2022-01-21 14:04:54 +01:00
tsinglion 847b3ba15d Translated using Weblate (Chinese (Simplified) (zh_CN))
Currently translated at 84.0% (745 of 886 strings)

Translation: rpm/master
Translate-URL: https://translate.fedoraproject.org/projects/rpm/master/zh_CN/
2022-01-21 14:04:54 +01:00
licunlong be64821b90 treat 0 as valid file descriptor
The descriptor is openned in rpmpkgOpen, and we treat 0 as valid file descriptor.
Here we should do the same or fail earlier.
2022-01-21 13:34:07 +01:00
Malcolm Inglis b0795abfd1 Fix failing 'rpm -q' tests on non-i386-derived arches
These three changed tests were failing, on at least aarch64, due to
architectural incompatibility errors on installing the
`hello-1.0-1.i386.rpm`, though the tests themselves aren't concerned
with executing the binaries, just querying the installed files. Thus, we
can just install them with `--ignorearch`.
2022-01-21 12:20:06 +02:00
Florian Festi e7312f6f62 Manual/tags: Use consistent language for scripts 2022-01-21 12:17:29 +02:00
Florian Festi f5c4da98ea Manual: OrderWithRequires dependency generators
Add new generator type to refence manual
2022-01-21 12:17:29 +02:00
Florian Festi 507ff17515 Manual/tags: Move Pubkeys to Internal / special section 2022-01-21 12:17:29 +02:00
Florian Festi 5484c9c4e6 Manual/tags: Add column descriptions to tables 2022-01-21 12:17:29 +02:00
Florian Festi 1ee34abdc2 Manual/tags: Add introductions to different sections 2022-01-21 12:17:29 +02:00
Florian Festi 9107b6d791 Manual/tags: Convert to tables
for better readability. No change to the content.
2022-01-21 12:17:29 +02:00
zhangwenlong 7a014dae73
Add support for loongarch64
* add support for loongarch64

Signed-off-by: Zhang Wenlong <zhangwenlong@loongson.cn>
2022-01-18 17:16:54 +01:00
Peter Pentchev 1cdb72ae48 Strip the target triplet GNU suffix more precisely.
Make the regular expressions more precise (anchor them to
the end of the input string), and try to catch any future
unrecognized target triplets by checking for a "-gnu" part
left over after the known variants were supposedly stripped.
2022-01-18 17:15:57 +01:00
Peter Pentchev e6277e4ab0 Fix the build on armhf and mipsel.
There were two problems here: first, the -gnueabihf and -gnuabi64
suffixes were not recognized at all, and second, -gnueabihf was
misdetected as -gnueabi since the regular expression is not precise
enough (no "$" at the end), leading to an inconsistent situation of
host_os_gnu being set (incorrectly) and the suffix *not* removed from
host_os.
2022-01-18 17:15:57 +01:00
Peter Pentchev 989d7c593c Fix __cplusplus misspelled as _cplusplus. 2022-01-18 12:17:40 +01:00
Otto Urpelainen d09ca2c103 Document %doc relative path stripping 2022-01-18 11:11:24 +01:00
Evgeniy Taishev 9b4c50dd67 Close file before replacing signed 2022-01-18 11:06:58 +01:00
Panu Matilainen 0edd64ea4a Argh, dumb thinko in commit d6353c96fe 2022-01-17 16:44:12 +02:00
Florian Festi 06cd39a4e9 Allow qualifiers like pre, post, preun, ... for weak dependencies, too
We are using weak dependency for ordering now. So it make sense to also
qualify weak dependencies with the time they are needed/wanted in the
transaction to make use of this information in ordering.

Especially (posttrans) could be useful to remove weak deps from dependency
loops during ordering when they are only needed after the installation.

Resolves: #624
2022-01-17 16:42:32 +02:00
Panu Matilainen d6353c96fe Ignore strong ordering hints from weak dependencies
Most qualifiers make as much sense to weak dependencies as they do for
normal dependencies, so we'd like to allow them in packages. Rpmbuild
doesn't currently allow them but packages from other implementations may
have them anyway.

To protect rpm's primary means of dependency loop cutting, don't let
weak dependencies inflate the value of pre/post etc dependencies by
simply ignoring those flags.
2022-01-17 16:31:21 +02:00
Panu Matilainen 002b9741d1 Clarify signatures/digests table purpose in the manual. 2022-01-17 13:05:55 +02:00
Panu Matilainen d0ad515494 Fix brp-compress regression from f3f763e54d
Since that commit builds would fail with

	RPM build errors:
	    Installed (but unpackaged) file(s) found:
	    /.gz

Use a similar find -print0 construct as the other loop above.
2022-01-14 14:50:37 +02:00
Panu Matilainen 03f146e955 Fix minimize_writes not minimizing writes since 4.15 regression
Commit 13f70e3710 caused minimize_writes
to actually not minimize anything since fsmVerify() only "verifies"
the thing does NOT exist anymore when it exist. Sigh.

FA_TOUCH needs different kind of verification, stat the file instead
to see if it needs creating afterall. This is all soooo broken...

Fixes: #1881
2022-01-13 11:39:46 +02:00
Michal Domonkos ae3d2d234a Fix use-after-free in haveSignature()
pgpPrtParams() may leave sig2 unchanged and if we're not in the very
first iteration of the while() loop, we could pass a freed pointer to
pgpDigParamsCmp().  Fix by setting it to NULL after freeing.

Found by Coverity, after commit bd36c5d (subkey binding validation),
although note that the commit didn't introduce this bug; it just seems
to have been a false negative that got "fixed" by the changes in
pgpPrtParams() in that commit.
2022-01-10 13:23:46 +02:00
Michal Domonkos b6dffb6dc5 Fix memory leak in pgpPrtParams()
Make sure selfsig is freed in case we break out of the loop in this
block.

Note that the tests added with the binding validation commit bd36c5d do
not cover this code path so valgrind won't show this.
2022-01-10 13:20:56 +02:00
Panu Matilainen f0c158cbc8 Fix old Python ts.check() argument order regression
Commit fab2debfe4 managed to mess up the
order of the last two callback arguments, doh.

Goes to show that nobody has missed this stuff in 12+ years, so it might
be more merciful to put this thing out of its misery...

Fixes: #1871
2022-01-04 15:59:13 +02:00
Dmitry Gerasimov 1c15d748d3 Fix possible NULL pointer dereference in rpmfcClassify
Here is simplified overview of possible dereference:

        if (fc == NULL) {
            rpmlog(RPMLOG_ERR, _("Empty file classifier\n"));
            goto exit;
        }

        // ...

    exit:
        rpmstrPoolFreeze(fc->cdict, 0);
                         ~~~~~~~~~

This issue was found by Svace Static Analyzer.
2022-01-03 10:18:25 +02:00
Panu Matilainen 5c5cd9f30b Fix a memleak in ndb from opened but not closed dbis.
Fixes: #1861
2022-01-03 09:52:52 +02:00
Otto Urpelainen 97ff3474dc Fix Relocatable Packages manual page formatting
Manual page Relocatable Packges was corrupted
due to use of unescaped angle brackets '<' and '>'.
Parser attempts to interpret these as a html tag.
Fixed by escaping the brackets with '\'.
2021-12-30 18:41:00 +01:00