Skip to content

Commit

Permalink
Don't run plugins on src.rpm unpacking
Browse files Browse the repository at this point in the history
The (current) plugin architecture is designed for transactions, really,
so don't run the hooks when we're just unpacking a source package.

This also fixes potential unpacking failures on systems with a plugin
installed that requires root privileges, such as the ima plugin, since
src.rpm unpacking is often done as a regular user (see RhBug:2316785).
  • Loading branch information
dmnks committed Nov 26, 2024
1 parent fe9a914 commit 4b79787
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/depends.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,14 +453,14 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
fnpyKey key, int upgrade, rpmRelocation * relocs)
{
int op = (upgrade == 0) ? RPMTE_INSTALL : RPMTE_UPGRADE;
if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL)
if (rpmtsSetupTransactionPlugins(ts, h) == RPMRC_FAIL)
return 1;
return addPackage(ts, h, key, op, relocs);
}

int rpmtsAddReinstallElement(rpmts ts, Header h, fnpyKey key)
{
if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL)
if (rpmtsSetupTransactionPlugins(ts, h) == RPMRC_FAIL)
return 1;
/* TODO: pull relocations from installed package */
/* TODO: should reinstall of non-installed package fail? */
Expand All @@ -470,7 +470,7 @@ int rpmtsAddReinstallElement(rpmts ts, Header h, fnpyKey key)
int rpmtsAddRestoreElement(rpmts ts, Header h)
{
tsMembers tsmem = rpmtsMembers(ts);
if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL)
if (rpmtsSetupTransactionPlugins(ts, h) == RPMRC_FAIL)
return 1;

rpmte p = rpmteNew(ts, h, TR_RESTORED, NULL, NULL, 0);
Expand All @@ -485,7 +485,7 @@ int rpmtsAddRestoreElement(rpmts ts, Header h)

int rpmtsAddEraseElement(rpmts ts, Header h, int dboffset)
{
if (rpmtsSetupTransactionPlugins(ts) == RPMRC_FAIL)
if (rpmtsSetupTransactionPlugins(ts, h) == RPMRC_FAIL)
return 1;
return removePackage(ts, h, NULL);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rpmts_internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ RPM_GNUC_INTERNAL
int rpmtsSolve(rpmts ts, rpmds key);

RPM_GNUC_INTERNAL
rpmRC rpmtsSetupTransactionPlugins(rpmts ts);
rpmRC rpmtsSetupTransactionPlugins(rpmts ts, Header h);

RPM_GNUC_INTERNAL
rpmRC runScript(rpmts ts, rpmte te, Header h, ARGV_const_t prefixes,
Expand Down
6 changes: 5 additions & 1 deletion lib/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1590,13 +1590,17 @@ static int rpmtsProcess(rpmts ts)
return rc;
}

rpmRC rpmtsSetupTransactionPlugins(rpmts ts)
rpmRC rpmtsSetupTransactionPlugins(rpmts ts, Header h)
{
rpmRC rc = RPMRC_OK;
ARGV_t files = NULL;
int nfiles = 0;
char *dsoPath = NULL;

/* Source packages aren't really installed, only unpacked */
if (headerIsSource(h))
return RPMRC_OK;

/*
* Assume allocated equals initialized. There are some oddball cases
* (verification of non-installed package) where this is not true
Expand Down
12 changes: 11 additions & 1 deletion tests/rpmdevel.at
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ 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}
Expand Down Expand Up @@ -70,5 +73,12 @@ 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],
[],
[])

RPMTEST_CLEANUP

0 comments on commit 4b79787

Please sign in to comment.