Skip to content

Commit 0f70f86

Browse files
committed
Don't run plugins on src.rpm unpacking
Source packages aren't really "installed", just unpacked, and plugins are by design meant for transactions, so disable the tsm/fsm/psm and scriptlet hooks for those. Note that the init and cleanup hooks will still run, those are supposed to only do reversible actions such as opening and closing files, and we wouldn't avoid them if there was a binary package supplied on the rpm -i command line anyway. This fixes, in particular, src.rpm installations done by a regular user (a common case) on systems with a plugin that requires root privileges, such as the ima plugin, which would otherwise cause a spurious warning or even failure (see RhBug:2316785). Extending rpmtsPlugins() here would be nicer but it's public API so just add a static wrapper. Reuse the plugin development test, we don't have anything better at the moment and it does the job well.
1 parent 4f9f5da commit 0f70f86

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/fsm.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -875,13 +875,21 @@ static rpmfi fsmIterFini(rpmfi fi, struct diriter_s *di)
875875
return rpmfiFree(fi);
876876
}
877877

878+
static rpmPlugins fsmPlugins(rpmts ts, rpmte te)
879+
{
880+
if (headerIsSource(rpmteHeader(te)))
881+
return NULL;
882+
else
883+
return rpmtsPlugins(ts);
884+
}
885+
878886
int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
879887
rpmpsm psm, char ** failedFile)
880888
{
881889
FD_t payload = rpmtePayload(te);
882890
rpmfi fi = NULL;
883891
rpmfs fs = rpmteGetFileStates(te);
884-
rpmPlugins plugins = rpmtsPlugins(ts);
892+
rpmPlugins plugins = fsmPlugins(ts, te);
885893
int rc = 0;
886894
int fx = -1;
887895
int fc = rpmfilesFC(files);
@@ -1123,7 +1131,7 @@ int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfiles files,
11231131
struct diriter_s di = { -1, -1 };
11241132
rpmfi fi = fsmIter(NULL, files, RPMFI_ITER_BACK, &di);
11251133
rpmfs fs = rpmteGetFileStates(te);
1126-
rpmPlugins plugins = rpmtsPlugins(ts);
1134+
rpmPlugins plugins = fsmPlugins(ts, te);
11271135
int fc = rpmfilesFC(files);
11281136
int fx = -1;
11291137
struct filedata_s *fdata = (struct filedata_s *)xcalloc(fc, sizeof(*fdata));

tests/rpmdevel.at

+13-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ runroot rpmbuild --quiet -bb \
4343
/data/SPECS/simple.spec \
4444
/data/SPECS/fakeshell.spec
4545

46+
runroot rpmbuild --quiet -bs \
47+
/data/SPECS/simple.spec
48+
4649
runroot rpm -U /build/RPMS/noarch/fakeshell-1.0-1.noarch.rpm
4750

4851
cmake /data/debugplugin && make && make install DESTDIR=${RPMTEST}
@@ -70,5 +73,14 @@ debug_psm_post: simple-1.0-1.noarch:0
7073
debug_tsm_post: 0
7174
debug_cleanup
7275
])
73-
RPMTEST_CLEANUP
7476

77+
RPMTEST_CHECK([
78+
runroot rpm -i /build/SRPMS/simple-1.0-1.src.rpm
79+
],
80+
[0],
81+
[],
82+
[debug_init
83+
debug_cleanup
84+
])
85+
86+
RPMTEST_CLEANUP

0 commit comments

Comments
 (0)