Skip to content

Commit d4bf03b

Browse files
committed
Don't run plugins on src.rpm unpacking (RhBug:2316785)
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.
1 parent c820a3f commit d4bf03b

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/psm.cc

+9
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
150150
Header h = NULL;
151151
rpmpsm psm = NULL;
152152
rpmte te = NULL;
153+
rpmPlugins plugins = NULL;
153154
rpmRC rpmrc;
154155
int specix = -1;
155156

@@ -204,13 +205,21 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
204205
rpmfsSetAction(fs, i, FA_CREATE);
205206
}
206207

208+
/* Don't run any plugins */
209+
plugins = ts->plugins;
210+
ts->plugins = rpmpluginsNew(ts);
211+
207212
psm = rpmpsmNew(ts, te, PKG_INSTALL);
208213

209214
if (rpmpsmUnpack(psm) == RPMRC_OK)
210215
rpmrc = RPMRC_OK;
211216

212217
rpmpsmFree(psm);
213218

219+
/* Restore plugins */
220+
rpmpluginsFree(ts->plugins);
221+
ts->plugins = plugins;
222+
214223
exit:
215224
if (rpmrc == RPMRC_OK && specix >= 0) {
216225
if (cookie)

tests/rpmdevel.at

+14-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ 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}
4952

5053
RPMTEST_CHECK([
51-
runroot rpm -U /build/RPMS/noarch/simple-1.0-1.noarch.rpm
54+
runroot rpm -U /build/RPMS/noarch/simple-1.0-1.noarch.rpm /build/SRPMS/simple-1.0-1.src.rpm
5255
],
5356
[0],
5457
[],
@@ -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)