RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/build/ pack.c rpm/lib/ Makefile.am librpm....

From: Jeff Johnson <jbj@rpm5.org>
Date: Sat 08 Sep 2007 - 18:17:34 CEST
Message-Id: <20070908161734.F387B348472@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   08-Sep-2007 18:17:34
  Branch: HEAD                             Handle: 2007090817173202

  Added files:
    rpm/rpmdb               pkgio.c pkgio.h
  Modified files:
    rpm                     CHANGES
    rpm/build               pack.c
    rpm/lib                 Makefile.am librpm.vers package.c psm.c
                            rpmchecksig.c signature.c
    rpm/rpmdb               Makefile.am librpmdb.vers
  Removed files:
    rpm/lib                 rpmlead.c rpmlead.h

  Log:
    - refactor rpmlead I/O routines into rpmdb/pkgio.c.

  Summary:
    Revision    Changes     Path
    1.1622      +1  -0      rpm/CHANGES
    2.224       +1  -1      rpm/build/pack.c
    2.165       +2  -2      rpm/lib/Makefile.am
    1.11        +0  -3      rpm/lib/librpm.vers
    2.150       +2  -2      rpm/lib/package.c
    2.223       +1  -1      rpm/lib/psm.c
    1.136       +1  -1      rpm/lib/rpmchecksig.c
    2.47        +0  -121    rpm/lib/rpmlead.c
    2.21        +0  -74     rpm/lib/rpmlead.h
    2.183       +1  -1      rpm/lib/signature.c
    1.79        +2  -2      rpm/rpmdb/Makefile.am
    1.14        +3  -0      rpm/rpmdb/librpmdb.vers
    1.1         +122 -0     rpm/rpmdb/pkgio.c
    1.1         +74 -0      rpm/rpmdb/pkgio.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1621 -r1.1622 CHANGES
  --- rpm/CHANGES	8 Sep 2007 15:45:19 -0000	1.1621
  +++ rpm/CHANGES	8 Sep 2007 16:17:32 -0000	1.1622
  @@ -1,4 +1,5 @@
   4.5 -> 5.0:
  +    - jbj: refactor rpmlead I/O routines into rpmdb/pkgio.c.
       - jbj: protect rpmdb contents from cluelesser morons.
       - jbj: add sourcepkgid index and permit queries of the (non-existent) tag.
       - rpm.org: permit mire RE's against binary data. Useless ... (#277161).
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/pack.c
  ============================================================================
  $ cvs diff -u -r2.223 -r2.224 pack.c
  --- rpm/build/pack.c	19 Aug 2007 17:43:01 -0000	2.223
  +++ rpm/build/pack.c	8 Sep 2007 16:17:32 -0000	2.224
  @@ -23,7 +23,7 @@
   
   #include "signature.h"
   #define	_RPMLEAD_INTERNAL
  -#include "rpmlead.h"
  +#include <pkgio.h>
   #include "debug.h"
   
   /*@access rpmts @*/
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/Makefile.am
  ============================================================================
  $ cvs diff -u -r2.164 -r2.165 Makefile.am
  --- rpm/lib/Makefile.am	29 Jul 2007 14:02:33 -0000	2.164
  +++ rpm/lib/Makefile.am	8 Sep 2007 16:17:33 -0000	2.165
  @@ -27,7 +27,7 @@
   	rpmal.h rpmdpkg.h rpmds.h rpmevr.h rpmfc.h rpmfi.h rpmgi.h \
   	rpmns.h rpmps.h rpmsx.h rpmte.h rpmts.h stringbuf.h
   noinst_HEADERS = \
  -	cpio.h fsm.h manifest.h psm.h rpmlead.h rpmlock.h signature.h tar.h
  +	cpio.h fsm.h manifest.h psm.h rpmlock.h signature.h tar.h
   
   usrlibdir = $(libdir)
   usrlib_LTLIBRARIES = librpm.la
  @@ -37,7 +37,7 @@
   	poptALL.c poptI.c poptQV.c psm.c query.c \
   	rpmal.c rpmchecksig.c rpmdpkg.c rpmds.c rpmevr.c rpmfc.c \
   	rpmfi.c rpmgi.c rpminstall.c rpmrollback.c \
  -	rpmlead.c rpmlock.c rpmns.c rpmps.c rpmrc.c rpmsx.c rpmte.c rpmts.c \
  +	rpmlock.c rpmns.c rpmps.c rpmrc.c rpmsx.c rpmte.c rpmts.c \
   	signature.c stringbuf.c transaction.c \
   	verify.c tar.c
   librpm_la_LDFLAGS = -release $(LT_CURRENT).$(LT_REVISION)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/librpm.vers
  ============================================================================
  $ cvs diff -u -r1.10 -r1.11 librpm.vers
  --- rpm/lib/librpm.vers	21 Aug 2007 03:41:52 -0000	1.10
  +++ rpm/lib/librpm.vers	8 Sep 2007 16:17:33 -0000	1.11
  @@ -47,14 +47,12 @@
       makeTempFile;
       newFSM;
       newStringBuf;
  -    _nolead;
       _nosigh;
       nplatpat;
       platpat;
       _print_pkts;
       _psm_debug;
       _psm_threads;
  -    readLead;
       rpmAddSignature;
       rpmalAdd;
       rpmalAddProvides;
  @@ -429,7 +427,6 @@
       stripTrailingBlanksStringBuf;
       truncStringBuf;
       whatis;
  -    writeLead;
       XrpmdsLink;
       XrpmdsUnlink;
       XrpmfiLink;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/package.c
  ============================================================================
  $ cvs diff -u -r2.149 -r2.150 package.c
  --- rpm/lib/package.c	17 Aug 2007 16:04:50 -0000	2.149
  +++ rpm/lib/package.c	8 Sep 2007 16:17:33 -0000	2.150
  @@ -11,8 +11,8 @@
   
   #include "rpmts.h"
   
  -#include "misc.h"	/* XXX stripTrailingChar() */
  -#include "rpmlead.h"
  +#include "misc.h"		/* XXX stripTrailingChar() */
  +#include <pkgio.h>		/* XXX readLead */
   
   #include "header_internal.h"	/* XXX headerCheck */
   #include "signature.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/psm.c
  ============================================================================
  $ cvs diff -u -r2.222 -r2.223 psm.c
  --- rpm/lib/psm.c	5 Sep 2007 23:08:01 -0000	2.222
  +++ rpm/lib/psm.c	8 Sep 2007 16:17:33 -0000	2.223
  @@ -28,7 +28,7 @@
   #include "rpmts.h"
   
   #define	_RPMLEAD_INTERNAL
  -#include "rpmlead.h"		/* writeLead proto */
  +#include <pkgio.h>		/* writeLead proto, RPMLEAD_BINARY */
   #include "signature.h"		/* signature constants */
   #include "misc.h"		/* XXX stripTrailingChar() */
   #include "rpmdb.h"		/* XXX for db_chrootDone */
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmchecksig.c
  ============================================================================
  $ cvs diff -u -r1.135 -r1.136 rpmchecksig.c
  --- rpm/lib/rpmchecksig.c	4 Sep 2007 12:52:34 -0000	1.135
  +++ rpm/lib/rpmchecksig.c	8 Sep 2007 16:17:33 -0000	1.136
  @@ -15,7 +15,7 @@
   #include "rpmts.h"
   
   #define	_RPMLEAD_INTERNAL
  -#include "rpmlead.h"
  +#include <pkgio.h>		/* XXX readLead/writeLead */
   #include "signature.h"
   #include "misc.h"	/* XXX for makeTempFile() */
   #include "debug.h"
  @@ .
  rm -f rpm/lib/rpmlead.c <<'@@ .'
  Index: rpm/lib/rpmlead.c
  ============================================================================
  [NO CHANGE SUMMARY BECAUSE FILE AS A WHOLE IS JUST REMOVED]
  @@ .
  rm -f rpm/lib/rpmlead.h <<'@@ .'
  Index: rpm/lib/rpmlead.h
  ============================================================================
  [NO CHANGE SUMMARY BECAUSE FILE AS A WHOLE IS JUST REMOVED]
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/signature.c
  ============================================================================
  $ cvs diff -u -r2.182 -r2.183 signature.c
  --- rpm/lib/signature.c	24 Aug 2007 21:07:46 -0000	2.182
  +++ rpm/lib/signature.c	8 Sep 2007 16:17:33 -0000	2.183
  @@ -17,7 +17,7 @@
   #include "misc.h"	/* XXX for dosetenv() and makeTempFile() */
   #include "legacy.h"	/* XXX for mdbinfile() */
   #define	_RPMLEAD_INTERNAL
  -#include "rpmlead.h"
  +#include <pkgio.h>		/* XXX sizeof(struct rpmlead) */
   #include "signature.h"
   #include "header_internal.h"
   #include "debug.h"
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.78 -r1.79 Makefile.am
  --- rpm/rpmdb/Makefile.am	2 Aug 2007 18:04:32 -0000	1.78
  +++ rpm/rpmdb/Makefile.am	8 Sep 2007 16:17:34 -0000	1.79
  @@ -26,7 +26,7 @@
   tjfn_LDADD = librpmdb.la
   
   pkgincdir = $(pkgincludedir)$(WITH_PATH_VERSIONED_SUFFIX)
  -pkginc_HEADERS = header.h hdrinline.h rpmdb.h
  +pkginc_HEADERS = header.h hdrinline.h pkgio.h rpmdb.h
   noinst_HEADERS = fprint.h header_internal.h legacy.h
   
   pkglibdir =		@USRLIBRPM@
  @@ -41,7 +41,7 @@
   librpmdb_la_SOURCES = \
   	dbconfig.c fprint.c \
   	hdrfmt.c hdrNVR.c header.c header_internal.c legacy.c merge.c \
  -	poptDB.c rpmdb.c \
  +	pkgio.c poptDB.c rpmdb.c \
   	tagname.c tagtbl.c
   librpmdb_la_LDFLAGS = -release $(LT_CURRENT).$(LT_REVISION)
   if HAVE_LD_VERSION_SCRIPT
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/librpmdb.vers
  ============================================================================
  $ cvs diff -u -r1.13 -r1.14 librpmdb.vers
  --- rpm/rpmdb/librpmdb.vers	19 Aug 2007 21:12:23 -0000	1.13
  +++ rpm/rpmdb/librpmdb.vers	8 Sep 2007 16:17:34 -0000	1.14
  @@ -37,9 +37,11 @@
       headerNEVRA;
       hGetColor;
       _init;
  +    _nolead;
       _newmagic;
       prDbiOpenFlags;
       rdbOptions;
  +    readLead;
       rpmDatabasePoptTable;
       rpmdbAdd;
       rpmdbAppendIterator;
  @@ -77,6 +79,7 @@
       rpmTagTableSize;
       rpmTags;
       sqlitevec;
  +    writeLead;
       XrpmdbLink;
       XrpmdbUnlink;
     local:
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.c
  ============================================================================
  $ cvs diff -u -r0 -r1.1 pkgio.c
  --- /dev/null	2007-09-08 18:11:00 +0200
  +++ pkgio.c	2007-09-08 18:17:34 +0200
  @@ -0,0 +1,122 @@
  +
  +/** \ingroup lead
  + * \file rpmdb/pkgio.c
  + */
  +
  +#include "system.h"
  +
  +#if defined(HAVE_MACHINE_TYPES_H)
  +# include <machine/types.h>
  +#endif
  +
  +#include <netinet/in.h>
  +
  +#include <rpmlib.h>
  +#include <rpmio.h>
  +
  +#include "signature.h"		/* XXX RPMSIGTYPE_HEADERSIG */
  +#define	_RPMLEAD_INTERNAL
  +#include <pkgio.h>
  +#include "debug.h"
  +
  +/*@unchecked@*/
  +int _nolead = SUPPORT_RPMLEAD;
  +
  +/*@unchecked@*/ /*@observer@*/
  +static unsigned char lead_magic[] = {
  +    RPMLEAD_MAGIC0, RPMLEAD_MAGIC1, RPMLEAD_MAGIC2, RPMLEAD_MAGIC3
  +};
  +
  +/* The lead needs to be 8 byte aligned */
  +
  +rpmRC writeLead(FD_t fd, const struct rpmlead *lead)
  +{
  +    struct rpmlead l;
  +
  +/*@-boundswrite@*/
  +    memcpy(&l, lead, sizeof(l));
  +    
  +    memcpy(&l.magic, lead_magic, sizeof(l.magic));
  +/*@=boundswrite@*/
  +    l.type = htons(l.type);
  +    l.archnum = htons(l.archnum);
  +    l.osnum = htons(l.osnum);
  +    l.signature_type = htons(l.signature_type);
  +	
  +/*@-boundswrite@*/
  +    if (Fwrite(&l, 1, sizeof(l), fd) != sizeof(l))
  +	return RPMRC_FAIL;
  +/*@=boundswrite@*/
  +
  +    return RPMRC_OK;
  +}
  +
  +rpmRC readLead(FD_t fd, struct rpmlead ** leadp, const char ** msg)
  +{
  +    struct rpmlead * lead = xcalloc(1, sizeof(*lead));
  +    char buf[BUFSIZ];
  +    rpmRC rc = RPMRC_FAIL;		/* assume failure */
  +    int xx;
  +
  +    buf[0] = '\0';
  +    if (leadp != NULL) *leadp = NULL;
  +
  +    /*@-type@*/ /* FIX: remove timed read */
  +    if ((xx = timedRead(fd, (char *)lead, sizeof(*lead))) != sizeof(*lead)) {
  +	if (Ferror(fd)) {
  +	    (void) snprintf(buf, sizeof(buf),
  +		_("lead size(%u): BAD, read(%d), %s(%d)"),
  +		(unsigned)sizeof(*lead), xx, Fstrerror(fd), errno);
  +	    rc = RPMRC_FAIL;
  +	} else {
  +	    (void) snprintf(buf, sizeof(buf),
  +		_("lead size(%u): BAD, read(%d), %s(%d)"),
  +		(unsigned)sizeof(*lead), xx, strerror(errno), errno);
  +	    rc = RPMRC_NOTFOUND;
  +	}
  +	goto exit;
  +    }
  +    /*@=type@*/
  +
  +    if (memcmp(lead->magic, lead_magic, sizeof(lead_magic))) {
  +	(void) snprintf(buf, sizeof(buf), _("lead magic: BAD"));
  +	rc = RPMRC_NOTFOUND;
  +	goto exit;
  +    }
  +    lead->type = ntohs(lead->type);
  +    lead->archnum = ntohs(lead->archnum);
  +    lead->osnum = ntohs(lead->osnum);
  +    lead->signature_type = ntohs(lead->signature_type);
  +
  +    switch (lead->major) {
  +    default:
  +	(void) snprintf(buf, sizeof(buf),
  +		_("lead version(%d): UNSUPPORTED"), lead->major);
  +	rc = RPMRC_NOTFOUND;
  +	break;
  +    case 3:
  +    case 4:
  +	break;
  +    }
  +
  +    if (lead->signature_type != RPMSIGTYPE_HEADERSIG) {
  +	(void) snprintf(buf, sizeof(buf),
  +		_("sigh type(%d): UNSUPPORTED"), lead->signature_type);
  +	rc = RPMRC_NOTFOUND;
  +	goto exit;
  +    }
  +
  +    rc = RPMRC_OK;
  +
  +exit:
  +    if (rc == RPMRC_OK && leadp != NULL)
  +	*leadp = lead;
  +    else
  +	lead = _free(lead);
  +	
  +    if (msg != NULL) {
  +	buf[sizeof(buf)-1] = '\0';
  +	*msg = xstrdup(buf);
  +    }
  +    return rc;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/pkgio.h
  ============================================================================
  $ cvs diff -u -r0 -r1.1 pkgio.h
  --- /dev/null	2007-09-08 18:11:00 +0200
  +++ pkgio.h	2007-09-08 18:17:34 +0200
  @@ -0,0 +1,74 @@
  +#ifndef _H_PKGIO
  +#define _H_PKGIO
  +
  +/** \ingroup lead
  + * \file rpmdb/pkgio.h
  + * Routines to read and write an rpm lead structure for a a package.
  + */
  +
  +#ifdef __cplusplus
  +extern "C" {
  +#endif
  +
  +#if defined(_RPMLEAD_INTERNAL)
  +
  +#define	RPMLEAD_BINARY 0
  +#define	RPMLEAD_SOURCE 1
  +
  +#define	RPMLEAD_MAGIC0 0xed
  +#define	RPMLEAD_MAGIC1 0xab
  +#define	RPMLEAD_MAGIC2 0xee
  +#define	RPMLEAD_MAGIC3 0xdb
  +
  +#define	RPMLEAD_SIZE 96		/*!< Don't rely on sizeof(struct) */
  +
  +/** \ingroup lead
  + * The lead data structure.
  + * The lead needs to be 8 byte aligned.
  + * @deprecated The lead (except for signature_type) is legacy.
  + * @todo Don't use any information from lead.
  + */
  +struct rpmlead {
  +    unsigned char magic[4];
  +    unsigned char major;
  +    unsigned char minor;
  +    short type;
  +    short archnum;
  +    char name[66];
  +    short osnum;
  +    short signature_type;	/*!< Signature header type (RPMSIG_HEADERSIG) */
  +/*@unused@*/ char reserved[16];	/*!< Pad to 96 bytes -- 8 byte aligned! */
  +} ;
  +#else
  +struct rpmlead;
  +#endif
  +
  +/*@unchecked@*/
  +extern int _nolead;
  +
  +/** \ingroup lead
  + * Write lead to file handle.
  + * @param fd		file handle
  + * @param lead		package lead
  + * @return		RPMRC_OK on success, RPMRC_FAIL on error
  + */
  +rpmRC writeLead(FD_t fd, const struct rpmlead *lead)
  +	/*@globals fileSystem @*/
  +	/*@modifies fd, fileSystem @*/;
  +
  +/** \ingroup lead
  + * Read lead from file handle.
  + * @param fd		file handle
  + * @retval *leadp	package lead
  + * @retval *msg		failure msg
  + * @return		rpmRC return code
  + */
  +rpmRC readLead(FD_t fd, /*@null@*/ /*@out@*/ struct rpmlead ** leadp,
  +		const char ** msg)
  +	/*@modifies fd, *lead, *msg @*/;
  +
  +#ifdef __cplusplus
  +}
  +#endif
  +
  +#endif	/* _H_PKGIO */
  @@ .
Received on Sat Sep 8 18:17:35 2007
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.