Skip to content

Commit

Permalink
Don't run plugins on src.rpm unpacking (RhBug:2316785)
Browse files Browse the repository at this point in the history
Source packages aren't really "installed", just unpacked, and plugins
operate on real transactions by design, so disable the tsm/psm/fsm and
scriptlet hooks for those.  This doesn't include the init and cleanup
hooks but those should be harmless and only do non-destructive actions
anyway.

Do this by simply replacing the plugins list with an empty one for the
duration of src.rpm unpacking.  This also is in line with what we do for
--noplugins.

This fixes, in particular, src.rpm installations done by a regular user
(a fairly common case) on systems equipped with a plugin that needs root
privileges (e.g. the ima plugin), which would otherwise cause a spurious
warning or even failure (see RhBug:2316785).

Reuse the plugin development test, we don't have anything better at the
moment and it does the job well.
  • Loading branch information
dmnks committed Dec 10, 2024
1 parent 0a40ccc commit 2537992
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/psm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
Header h = NULL;
rpmpsm psm = NULL;
rpmte te = NULL;
rpmPlugins origplugins = NULL;
rpmRC rpmrc;
int specix = -1;

Expand Down Expand Up @@ -204,13 +205,21 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
rpmfsSetAction(fs, i, FA_CREATE);
}

/* Don't run any plugins */
origplugins = ts->plugins;
ts->plugins = rpmpluginsNew(ts);

psm = rpmpsmNew(ts, te, PKG_INSTALL);

if (rpmpsmUnpack(psm) == RPMRC_OK)
rpmrc = RPMRC_OK;

rpmpsmFree(psm);

/* Restore plugins */
rpmpluginsFree(ts->plugins);
ts->plugins = origplugins;

exit:
if (rpmrc == RPMRC_OK && specix >= 0) {
if (cookie)
Expand Down
16 changes: 14 additions & 2 deletions tests/rpmdevel.at
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ runroot rpmbuild --quiet -bb \
/data/SPECS/simple.spec \
/data/SPECS/fakeshell.spec

runroot rpmbuild --quiet -bs \
/data/SPECS/simple.spec

runroot rpm -U /build/RPMS/noarch/fakeshell-1.0-1.noarch.rpm

cmake /data/debugplugin && make && make install DESTDIR=${RPMTEST}

RPMTEST_CHECK([
runroot rpm -U /build/RPMS/noarch/simple-1.0-1.noarch.rpm
runroot rpm -U /build/RPMS/noarch/simple-1.0-1.noarch.rpm /build/SRPMS/simple-1.0-1.src.rpm
],
[0],
[],
Expand All @@ -70,5 +73,14 @@ debug_psm_post: simple-1.0-1.noarch:0
debug_tsm_post: 0
debug_cleanup
])
RPMTEST_CLEANUP

RPMTEST_CHECK([
runroot rpm -i /build/SRPMS/simple-1.0-1.src.rpm
],
[0],
[],
[debug_init
debug_cleanup
])

RPMTEST_CLEANUP

0 comments on commit 2537992

Please sign in to comment.