summaryrefslogtreecommitdiff
path: root/python/rpmmodule.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2000-08-19 13:10:34 +0000
committerjbj <devnull@localhost>2000-08-19 13:10:34 +0000
commitd0e98332d4115aa087e1e1f8e39b80c02c406f10 (patch)
tree37382b177bb3a11f360eb28c176c328b23bbf41a /python/rpmmodule.c
parentc96e7513f8dd3ebd4030946720e2dff96a5c3cd2 (diff)
downloadrpm-d0e98332d4115aa087e1e1f8e39b80c02c406f10.tar.gz
rpm-d0e98332d4115aa087e1e1f8e39b80c02c406f10.tar.bz2
rpm-d0e98332d4115aa087e1e1f8e39b80c02c406f10.zip
- python bindings to query and verify signatures.
CVS patchset: 4085 CVS date: 2000/08/19 13:10:34
Diffstat (limited to 'python/rpmmodule.c')
-rw-r--r--python/rpmmodule.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index e73e9746f..464680e50 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -85,6 +85,8 @@ static PyObject * rpmtransGetAttr(rpmtransObject * o, char * name);
static int rpmtransSetAttr(rpmtransObject * o, char * name,
PyObject * val);
+/* signature verification */
+static PyObject * checkSig (PyObject * self, PyObject * args);
/* internal functions */
static long tagNumFromPyObject (PyObject *item);
@@ -116,6 +118,7 @@ struct rpmtransObject_s {
struct hdrObject_s {
PyObject_HEAD;
Header h;
+ Header sigs;
char ** md5list;
char ** fileList;
char ** linkList;
@@ -146,6 +149,7 @@ static PyMethodDef rpmModuleMethods[] = {
{ "errorString", (PyCFunction) errorString, METH_VARARGS, NULL },
{ "versionCompare", (PyCFunction) versionCompare, METH_VARARGS, NULL },
{ "labelCompare", (PyCFunction) labelCompare, METH_VARARGS, NULL },
+ { "checksig", (PyCFunction) checkSig, METH_VARARGS, NULL },
/* { "Fopen", (PyCFunction) doFopen, METH_VARARGS, NULL }, */
{ NULL }
} ;
@@ -416,6 +420,13 @@ void initrpm(void) {
PyInt_FromLong(RPMPROB_OLDPACKAGE));
PyDict_SetItemString(d, "RPMPROB_DISKSPACE",
PyInt_FromLong(RPMPROB_DISKSPACE));
+
+ PyDict_SetItemString(d, "CHECKSIG_PGP",
+ PyInt_FromLong(CHECKSIG_PGP));
+ PyDict_SetItemString(d, "CHECKSIG_GPG",
+ PyInt_FromLong(CHECKSIG_GPG));
+ PyDict_SetItemString(d, "CHECKSIG_MD5",
+ PyInt_FromLong(CHECKSIG_MD5));
}
/* make a header with _all_ the tags we need */
@@ -787,24 +798,28 @@ static PyObject * labelCompare (PyObject * self, PyObject * args) {
static PyObject * rpmHeaderFromPackage(PyObject * self, PyObject * args) {
hdrObject * h;
Header header;
+ Header sigs;
int rc;
FD_t fd;
int rawFd;
- int isSource;
+ int isSource = 0;
if (!PyArg_ParseTuple(args, "i", &rawFd)) return NULL;
fd = fdDup(rawFd);
- rc = rpmReadPackageHeader(fd, &header, &isSource, NULL, NULL);
+ rc = rpmReadPackageInfo(fd, &sigs, &header);
Fclose(fd);
switch (rc) {
case 0:
h = (hdrObject *) PyObject_NEW(PyObject, &hdrType);
h->h = header;
+ h->sigs = sigs;
h->fileList = h->linkList = h->md5list = NULL;
h->uids = h->gids = h->mtimes = h->fileSizes = NULL;
h->modes = h->rdevs = NULL;
+ if (headerIsEntry(header, RPMTAG_SOURCEPACKAGE))
+ isSource = 1;
break;
case 1:
@@ -1052,6 +1067,7 @@ static PyObject * rpmdbMIGetAttr (rpmdbObject *s, char *name) {
static void hdrDealloc(hdrObject * s) {
if (s->h) headerFree(s->h);
+ if (s->sigs) headerFree(s->sigs);
if (s->md5list) free(s->md5list);
if (s->fileList) free(s->fileList);
if (s->linkList) free(s->linkList);
@@ -1113,7 +1129,8 @@ static PyObject * hdrSubscript(hdrObject * s, PyObject * item) {
return NULL;
}
- if (!rpmHeaderGetEntry(s->h, tag, &type, &data, &count)) {
+ if (!rpmPackageGetEntry(NULL, s->sigs, s->h, tag, &type, &data, &count))
+ {
Py_INCREF(Py_None);
return Py_None;
}
@@ -1789,6 +1806,22 @@ static int closeCallback(FILE * f) {
}
return 0;
}
+
+static PyObject * checkSig (PyObject * self, PyObject * args) {
+ char * filename;
+ int flags;
+ int rc = 255;
+
+ if (PyArg_ParseTuple(args, "si", &filename, &flags)) {
+ const char *av[2];
+ av[0] = filename;
+ av[1] = NULL;
+fprintf(stderr, "*** rpmCheckSig(%x,%p) %s\n", flags, av, av[0]);
+ rc = rpmCheckSig(flags, av);
+ }
+ return Py_BuildValue("i", rc);
+}
+
/* disable
static PyObject * doFopen(PyObject * self, PyObject * args) {
char * path, * mode;