- fix: error message on failed package installs resurrected.

- python: memory leaks in headerLoad/headerunload bindings.
- python: retrofit sha1 digest using RPMTAG_SHA1RHN.
- python: change rhnUnload bindings.

CVS patchset: 5032
CVS date: 2001/08/27 18:39:17
This commit is contained in:
jbj 2001-08-27 18:39:17 +00:00
parent f847cb330c
commit 64a1d1afdc
9 changed files with 105 additions and 79 deletions

View File

@ -222,6 +222,10 @@
- verify perms (but not mode) on %ghost files. - verify perms (but not mode) on %ghost files.
- headers without RPMTAG_NAME are skipped when retrieved. - headers without RPMTAG_NAME are skipped when retrieved.
- within a region, entries sort by address; added drips sort by tag. - within a region, entries sort by address; added drips sort by tag.
- fix: error message on failed package installs resurrected.
- python: memory leaks in headerLoad/headerunload bindings.
- python: retrofit sha1 digest using RPMTAG_SHA1RHN.
- python: change rhnUnload bindings.
4.0 -> 4.0.[12] 4.0 -> 4.0.[12]
- add doxygen and lclint annotations most everywhere. - add doxygen and lclint annotations most everywhere.

View File

@ -450,7 +450,7 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
if (headerWrite(fd, h, HEADER_MAGIC_YES)) { if (headerWrite(fd, h, HEADER_MAGIC_YES)) {
rc = RPMERR_NOSPACE; rc = RPMERR_NOSPACE;
rpmError(RPMERR_NOSPACE, _("Unable to write %s header\n"), "temp"); rpmError(RPMERR_NOSPACE, _("Unable to write temp header\n"));
} else { /* Write the archive and get the size */ } else { /* Write the archive and get the size */
if (csa->cpioList != NULL) { if (csa->cpioList != NULL) {
rc = cpio_doio(fd, h, csa, rpmio_flags); rc = cpio_doio(fd, h, csa, rpmio_flags);
@ -493,7 +493,7 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
fdInitSHA1(fd, 0); fdInitSHA1(fd, 0);
if (headerWrite(fd, h, HEADER_MAGIC_NO)) { if (headerWrite(fd, h, HEADER_MAGIC_NO)) {
rc = RPMERR_NOSPACE; rc = RPMERR_NOSPACE;
rpmError(RPMERR_NOSPACE, _("Unable to write %s header\n"), "final"); rpmError(RPMERR_NOSPACE, _("Unable to write final header\n"));
} }
(void) Fflush(fd); (void) Fflush(fd);
fdFiniSHA1(fd, (void **)&sha1, NULL, 1); fdFiniSHA1(fd, (void **)&sha1, NULL, 1);
@ -524,7 +524,7 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
sig = headerReload(sig, RPMTAG_HEADERSIGNATURES); sig = headerReload(sig, RPMTAG_HEADERSIGNATURES);
if (sig == NULL) { /* XXX can't happen */ if (sig == NULL) { /* XXX can't happen */
rc = RPMERR_RELOAD; rc = RPMERR_RELOAD;
rpmError(RPMERR_RELOAD, _("Unable to reload %s header.\n"), "signature"); rpmError(RPMERR_RELOAD, _("Unable to reload signature header.\n"));
goto exit; goto exit;
} }

View File

@ -456,7 +456,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,
unsigned int * archiveSize, const char ** failedFile) unsigned int * archiveSize, const char ** failedFile)
{ {
size_t pos = 0; size_t pos = 0;
int rc; int rc, ec = 0;
fsm->goal = goal; fsm->goal = goal;
if (cfd) { if (cfd) {
@ -488,15 +488,17 @@ int fsmSetup(FSM_t fsm, fileStage goal,
sprintf(fsm->sufbuf, ";%08x", (unsigned)ts->id); sprintf(fsm->sufbuf, ";%08x", (unsigned)ts->id);
} }
rc = fsm->rc = 0; ec = fsm->rc = 0;
rc = fsmStage(fsm, FSM_CREATE); rc = fsmStage(fsm, FSM_CREATE);
if (rc && !ec) ec = rc;
rc = fsmStage(fsm, fsm->goal); rc = fsmStage(fsm, fsm->goal);
if (rc && !ec) ec = rc;
if (fsm->archiveSize && rc == 0) if (fsm->archiveSize && ec == 0)
*fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos); *fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos);
return rc; return ec;
} }
int fsmTeardown(FSM_t fsm) { int fsmTeardown(FSM_t fsm) {
@ -1255,9 +1257,11 @@ int fsmStage(FSM_t fsm, fileStage stage)
/* Notify on success. */ /* Notify on success. */
(void) fsmStage(fsm, FSM_NOTIFY); (void) fsmStage(fsm, FSM_NOTIFY);
if (fsmStage(fsm, FSM_FINI)) rc = fsmStage(fsm, FSM_FINI);
if (rc) {
/*@loopbreak@*/ break; /*@loopbreak@*/ break;
} }
}
break; break;
case FSM_PKGERASE: case FSM_PKGERASE:
case FSM_PKGCOMMIT: case FSM_PKGCOMMIT:
@ -1669,13 +1673,13 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
/* XXX common error message. */ /* XXX common error message. */
rpmError( rpmError(
(strict_erasures ? RPMERR_RMDIR : RPMWARN_RMDIR), (strict_erasures ? RPMERR_RMDIR : RPMDEBUG_RMDIR),
_("%s rmdir of %s failed: Directory not empty\n"), _("%s rmdir of %s failed: Directory not empty\n"),
fiTypeString(fi), fsm->path); fiTypeString(fi), fsm->path);
break; break;
default: default:
rpmError( rpmError(
(strict_erasures ? RPMERR_RMDIR : RPMWARN_RMDIR), (strict_erasures ? RPMERR_RMDIR : RPMDEBUG_RMDIR),
_("%s rmdir of %s failed: %s\n"), _("%s rmdir of %s failed: %s\n"),
fiTypeString(fi), fsm->path, strerror(errno)); fiTypeString(fi), fsm->path, strerror(errno));
break; break;
@ -1685,7 +1689,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
if (!rc) break; if (!rc) break;
if (!(errno == ENOENT && (fsm->fflags & RPMFILE_MISSINGOK))) if (!(errno == ENOENT && (fsm->fflags & RPMFILE_MISSINGOK)))
rpmError( rpmError(
(strict_erasures ? RPMERR_UNLINK : RPMWARN_UNLINK), (strict_erasures ? RPMERR_UNLINK : RPMDEBUG_UNLINK),
_("%s unlink of %s failed: %s\n"), _("%s unlink of %s failed: %s\n"),
fiTypeString(fi), fsm->path, strerror(errno)); fiTypeString(fi), fsm->path, strerror(errno));
} }
@ -1732,6 +1736,10 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
/* Notify on success. */ /* Notify on success. */
if (!rc) rc = fsmStage(fsm, FSM_NOTIFY); if (!rc) rc = fsmStage(fsm, FSM_NOTIFY);
else if (fsm->failedFile && *fsm->failedFile == NULL) {
*fsm->failedFile = fsm->path;
fsm->path = NULL;
}
break; break;
case FSM_DESTROY: case FSM_DESTROY:
fsm->path = _free(fsm->path); fsm->path = _free(fsm->path);

View File

@ -1779,15 +1779,17 @@ assert(psm->mi == NULL);
if (!rc) { if (!rc) {
rpmMessage(RPMMESS_VERBOSE, _("Wrote: %s\n"), rpmMessage(RPMMESS_VERBOSE, _("Wrote: %s\n"),
(psm->pkgURL ? psm->pkgURL : "???")); (psm->pkgURL ? psm->pkgURL : "???"));
} else { }
}
if (rc) {
if (psm->failedFile) if (psm->failedFile)
rpmError(RPMERR_CPIO, rpmError(RPMERR_CPIO,
_("create archive failed on file %s: %s\n"), _("%s failed on file %s: %s\n"),
psm->failedFile, cpioStrerror(rc)); psm->stepName, psm->failedFile, cpioStrerror(rc));
else else
rpmError(RPMERR_CPIO, _("create archive failed: %s\n"), rpmError(RPMERR_CPIO, _("%s failed: %s\n"),
cpioStrerror(rc)); psm->stepName, cpioStrerror(rc));
}
} }
if (fi->h && (psm->goal == PSM_PKGERASE || psm->goal == PSM_PKGSAVE)) if (fi->h && (psm->goal == PSM_PKGERASE || psm->goal == PSM_PKGSAVE))
@ -1803,7 +1805,6 @@ assert(psm->mi == NULL);
fi->fuser = hfd(fi->fuser, -1); fi->fuser = hfd(fi->fuser, -1);
fi->apath = _free(fi->apath); fi->apath = _free(fi->apath);
fi->fstates = _free(fi->fstates); fi->fstates = _free(fi->fstates);
break; break;
case PSM_PKGINSTALL: case PSM_PKGINSTALL:

View File

@ -355,6 +355,7 @@ typedef enum rpmTag_e {
RPMTAG_MULTILIBS = 1127, RPMTAG_MULTILIBS = 1127,
RPMTAG_INSTALLTID = 1128, RPMTAG_INSTALLTID = 1128,
RPMTAG_REMOVETID = 1129, RPMTAG_REMOVETID = 1129,
RPMTAG_SHA1RHN = 1130, /*!< internal */
/*@-enummemuse@*/ /*@-enummemuse@*/
RPMTAG_FIRSTFREE_TAG /*!< internal */ RPMTAG_FIRSTFREE_TAG /*!< internal */
/*@=enummemuse@*/ /*@=enummemuse@*/

View File

@ -347,7 +347,9 @@ int rpmVerifyDigest(Header h)
int ec = 0; /* assume no problems */ int ec = 0; /* assume no problems */
/* Retrieve header digest. */ /* Retrieve header digest. */
if (!hge(h, RPMTAG_SHA1HEADER, &hdt, (void **) &hdigest, NULL)) { if (!hge(h, RPMTAG_SHA1HEADER, &hdt, (void **) &hdigest, NULL)
&& !hge(h, RPMTAG_SHA1RHN, &hdt, (void **) &hdigest, NULL))
{
if (hge(h, RPMTAG_BADSHA1HEADER, &hdt, (void **) &hdigest, NULL)) if (hge(h, RPMTAG_BADSHA1HEADER, &hdt, (void **) &hdigest, NULL))
flags |= (RPMDIGEST_REVERSE|RPMDIGEST_BCSWAP); flags |= (RPMDIGEST_REVERSE|RPMDIGEST_BCSWAP);
else else

View File

@ -6,7 +6,7 @@
#define PY_POPT_VERSION "0.2" #define PY_POPT_VERSION "0.2"
static const char *rcs_id = "$Id: poptmodule.c,v 1.4 2001/07/21 19:44:22 jbj Exp $"; static const char *rcs_id = "$Id: poptmodule.c,v 1.5 2001/08/27 18:39:17 jbj Exp $";
static char *module_doc = "Python bindings for the popt library\n\ static char *module_doc = "Python bindings for the popt library\n\
\n\ \n\
@ -622,8 +622,8 @@ static PyObject * _strerror(PyObject *self, PyObject *args)
/* Methods for the popt module */ /* Methods for the popt module */
static struct PyMethodDef poptModuleMethods[] = { static struct PyMethodDef poptModuleMethods[] = {
{"getContext", (PyCFunction)getContext}, {"getContext", (PyCFunction)getContext, METH_VARARGS, NULL},
{"strerror", (PyCFunction)_strerror}, {"strerror", (PyCFunction)_strerror, METH_VARARGS, NULL},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -18,10 +18,16 @@
#include "rpmcli.h" /* XXX for rpmCheckSig */ #include "rpmcli.h" /* XXX for rpmCheckSig */
#include "misc.h" #include "misc.h"
#include "rpmio_internal.h" #include "rpmio_internal.h"
#include "header_internal.h"
#include "upgrade.h" #include "upgrade.h"
extern int _rpmio_debug; extern int _rpmio_debug;
/*@unused@*/ static inline Header headerAllocated(Header h) {
h->flags |= HEADERFLAG_ALLOCATED;
return 0;
}
#ifdef __LCLINT__ #ifdef __LCLINT__
#undef PyObject_HEAD #undef PyObject_HEAD
#define PyObject_HEAD int _PyObjectHead #define PyObject_HEAD int _PyObjectHead
@ -439,6 +445,59 @@ static void mungeFilelist(Header h)
free((void *)fileNames); free((void *)fileNames);
} }
/**
*/
static PyObject * rhnUnload(PyObject * self, PyObject * args) {
int len;
char * uh;
PyObject * rc;
hdrObject *s;
Header h;
if (!PyArg_ParseTuple(args, ""))
return NULL;
h = headerLink(s->h);
/* Legacy headers are forced into immutable region. */
if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
Header nh = headerReload(h, RPMTAG_HEADERIMMUTABLE);
/* XXX Another unload/load cycle to "seal" the immutable region. */
uh = headerUnload(nh);
headerFree(nh);
h = headerLoad(uh);
headerAllocated(h);
}
/* All headers have SHA1 digest, compute and add if necessary. */
if (!headerIsEntry(h, RPMTAG_SHA1HEADER)) {
int_32 uht, uhc;
const char * digest;
size_t digestlen;
DIGEST_CTX ctx;
headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, (void **)&uh, &uhc);
ctx = rpmDigestInit(RPMDIGEST_SHA1);
rpmDigestUpdate(ctx, uh, uhc);
rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
headerAddEntry(h, RPMTAG_SHA1RHN, RPM_STRING_TYPE, digest, 1);
uh = headerFreeData(uh, uht);
digest = _free(digest);
}
len = headerSizeof(h, 0);
uh = headerUnload(h);
headerFree(h);
rc = PyString_FromStringAndSize(uh, len);
free(uh);
return rc;
}
/** \ingroup python /** \ingroup python
*/ */
static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) { static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) {
@ -457,6 +516,7 @@ static struct PyMethodDef hdrMethods[] = {
{"expandFilelist", (PyCFunction) hdrExpandFilelist, 1 }, {"expandFilelist", (PyCFunction) hdrExpandFilelist, 1 },
{"compressFilelist", (PyCFunction) hdrCompressFilelist, 1 }, {"compressFilelist", (PyCFunction) hdrCompressFilelist, 1 },
{"fullFilelist", (PyCFunction) hdrFullFilelist, 1 }, {"fullFilelist", (PyCFunction) hdrFullFilelist, 1 },
{"rhnUnload", (PyCFunction) rhnUnload, 1 },
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
@ -1804,6 +1864,7 @@ static PyObject * hdrLoad(PyObject * self, PyObject * args) {
PyErr_SetString(pyrpmError, "bad header"); PyErr_SetString(pyrpmError, "bad header");
return NULL; return NULL;
} }
headerAllocated(hdr);
compressFilelist (hdr); compressFilelist (hdr);
providePackageNVR (hdr); providePackageNVR (hdr);
@ -1840,6 +1901,7 @@ static PyObject * rhnLoad(PyObject * self, PyObject * args) {
PyErr_SetString(pyrpmError, "bad header"); PyErr_SetString(pyrpmError, "bad header");
return NULL; return NULL;
} }
headerAllocated(hdr);
if (!headerIsEntry(hdr, RPMTAG_HEADERIMMUTABLE)) { if (!headerIsEntry(hdr, RPMTAG_HEADERIMMUTABLE)) {
PyErr_SetString(pyrpmError, "bad header, not immutable"); PyErr_SetString(pyrpmError, "bad header, not immutable");
@ -1869,57 +1931,6 @@ static PyObject * rhnLoad(PyObject * self, PyObject * args) {
return (PyObject *) h; return (PyObject *) h;
} }
/**
*/
static PyObject * rhnUnload(PyObject * self, PyObject * args) {
int len;
char * uh;
PyObject * rc;
hdrObject *s;
Header h;
if (!PyArg_ParseTuple(args, "O!", &hdrType, &s))
return NULL;
h = headerLink(s->h);
/* Legacy headers are forced into immutable region. */
if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
Header nh = headerReload(h, RPMTAG_HEADERIMMUTABLE);
/* XXX Another unload/load cycle to "seal" the immutable region. */
uh = headerUnload(nh);
headerFree(nh);
h = headerLoad(uh);
}
/* All headers have SHA1 digest, compute and add if necessary. */
if (!headerIsEntry(h, RPMTAG_SHA1HEADER)) {
int_32 uht, uhc;
const char * digest;
size_t digestlen;
DIGEST_CTX ctx;
headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, (void **)&uh, &uhc);
ctx = rpmDigestInit(RPMDIGEST_SHA1);
rpmDigestUpdate(ctx, uh, uhc);
rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
headerAddEntry(h, RPMTAG_SHA1HEADER, RPM_STRING_TYPE, digest, 1);
uh = headerFreeData(uh, uht);
digest = _free(digest);
}
len = headerSizeof(h, 0);
uh = headerUnload(h);
headerFree(h);
rc = PyString_FromStringAndSize(uh, len);
free(uh);
return rc;
}
/** /**
*/ */
static PyObject * rpmInitDB(PyObject * self, PyObject * args) { static PyObject * rpmInitDB(PyObject * self, PyObject * args) {
@ -2415,7 +2426,6 @@ static PyMethodDef rpmModuleMethods[] = {
{ "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL }, { "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL },
{ "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL }, { "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL },
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, NULL }, { "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, NULL },
{ "rhnUnload", (PyCFunction) rhnUnload, METH_VARARGS, NULL },
{ "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS, NULL }, { "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS, NULL },
{ "initdb", (PyCFunction) rpmInitDB, METH_VARARGS, NULL }, { "initdb", (PyCFunction) rpmInitDB, METH_VARARGS, NULL },
{ "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL }, { "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL },

View File

@ -128,8 +128,8 @@ typedef enum rpmerrCode_e {
RPMERR_SIGGEN = _em(201), /*!< Error generating signature */ RPMERR_SIGGEN = _em(201), /*!< Error generating signature */
RPMERR_SIGVFY = _nm(202), /*!< */ RPMERR_SIGVFY = _nm(202), /*!< */
RPMWARN_UNLINK = _wm(512u+16), /*!< unlink(2) failed */ RPMDEBUG_UNLINK = _dm(512u+16), /*!< unlink(2) failed */
RPMWARN_RMDIR = _wm(512u+17), /*!< rmdir(2) failed */ RPMDEBUG_RMDIR = _dm(512u+17), /*!< rmdir(2) failed */
RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */ RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */
} rpmerrCode; } rpmerrCode;
/*@=typeuse @*/ /*@=typeuse @*/