summaryrefslogtreecommitdiff
path: root/lib/rpmte.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-11-14 13:05:41 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-11-14 16:22:51 +0200
commitee59836299c5e1c293b64a826552cbfba5dcec12 (patch)
tree8509547c6b1f655d4d39cfb291b55ee8d18ad16b /lib/rpmte.c
parent0b0fe33d3c086e9bc3d7caa351a8304a64f724f1 (diff)
downloadrpm-ee59836299c5e1c293b64a826552cbfba5dcec12.tar.gz
rpm-ee59836299c5e1c293b64a826552cbfba5dcec12.tar.bz2
rpm-ee59836299c5e1c293b64a826552cbfba5dcec12.zip
Move open + close of files during install to separate functions
- internal rpmteOpen() and rpmteClose() functions replacing copy-paste slop between rpmtsRun() and runTransScripts() - eliminates bunch of rpmte privacy violations - rpmtsRun() doesn't need the file descriptor for anything, might as well keep it hidden
Diffstat (limited to 'lib/rpmte.c')
-rw-r--r--lib/rpmte.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/rpmte.c b/lib/rpmte.c
index 8c885e226..9227c451f 100644
--- a/lib/rpmte.c
+++ b/lib/rpmte.c
@@ -606,3 +606,46 @@ rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
}
return te;
}
+
+int rpmteOpen(rpmte te, rpmts ts)
+{
+ int rc = 0;
+ if (te == NULL || ts == NULL)
+ goto exit;
+
+ te->h = NULL;
+ te->fd = rpmtsNotify(ts, te, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
+ if (te->fd != NULL) {
+ rpmVSFlags ovsflags;
+ rpmRC pkgrc;
+
+ ovsflags = rpmtsSetVSFlags(ts, rpmtsVSFlags(ts) | RPMVSF_NEEDPAYLOAD);
+ pkgrc = rpmReadPackageFile(ts, rpmteFd(te), rpmteNEVRA(te), &te->h);
+ rpmtsSetVSFlags(ts, ovsflags);
+ switch (pkgrc) {
+ default:
+ rpmteClose(te, ts);
+ break;
+ case RPMRC_NOTTRUSTED:
+ case RPMRC_NOKEY:
+ case RPMRC_OK:
+ rc = 1;
+ break;
+ }
+ }
+
+exit:
+ return rc;
+}
+
+int rpmteClose(rpmte te, rpmts ts)
+{
+ int rc = 0;
+ if (te != NULL && ts != NULL) {
+ rpmtsNotify(ts, te, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
+ te->fd = NULL;
+ te->h = headerFree(te->h);
+ rc = 1;
+ }
+ return rc;
+}