- resurrect manifests, RPMRC_NOTFOUND returned by readLead().

CVS patchset: 6752
CVS date: 2003/04/16 17:48:04
This commit is contained in:
jbj 2003-04-16 17:48:04 +00:00
parent 14165bc558
commit c243ab099b
17 changed files with 454 additions and 69 deletions

View File

@ -35,7 +35,7 @@ librpmbuild_la_LDFLAGS = -release @VERSION@ $(LDFLAGS) \
@WITH_LIBELF_LIB@
rpmfile.h:
@ln -sf $(top_builddir)/file/file.h $@
@ln -sf $(top_builddir)/file/src/file.h $@
files.c rpmfc.c: rpmfile.h

View File

@ -18,10 +18,10 @@ magic: Header Localstuff $(magic_FRAGMENTS)
done >> $@
magic.mgc: magic
$(top_builddir)/file -C -m $(srcdir)/magic
$(top_builddir)/src/file -C -m $(srcdir)/magic
magic.mime.mgc: magic.mime
$(top_builddir)/file -C -m $(srcdir)/magic.mime
$(top_builddir)/src/file -C -m $(srcdir)/magic.mime
magic_FRAGMENTS = \
Magdir/acorn \
@ -40,12 +40,15 @@ Magdir/archive \
Magdir/asterix \
Magdir/att3b \
Magdir/audio \
Magdir/bFLT \
Magdir/blender \
Magdir/blit \
Magdir/bout \
Magdir/bsdi \
Magdir/c-lang \
Magdir/cddb \
Magdir/chi \
Magdir/chord \
Magdir/cisco \
Magdir/citrus \
Magdir/claris \
@ -77,13 +80,14 @@ Magdir/gimp \
Magdir/gnu \
Magdir/grace \
Magdir/gringotts \
Magdir/hdf \
Magdir/hitachi-sh \
Magdir/hp \
Magdir/human68k \
Magdir/ibm370 \
Magdir/ibm6000 \
Magdir/iff \
Magdir/images \
Magdir/impulse \
Magdir/intel \
Magdir/interleaf \
Magdir/island \
@ -107,8 +111,8 @@ Magdir/mime \
Magdir/mips \
Magdir/mirage \
Magdir/mkid \
Magdir/mmdf \
Magdir/mlssa \
Magdir/mmdf \
Magdir/modem \
Magdir/motorola \
Magdir/msdos \
@ -153,6 +157,7 @@ Magdir/smalltalk \
Magdir/sniffer \
Magdir/softquad \
Magdir/spectrum \
Magdir/sql \
Magdir/sun \
Magdir/sysex \
Magdir/teapot \

View File

@ -53,7 +53,7 @@ int os2_apptype (const char *fn, char *buf, int nb);
/*@unchecked@*/
static int nobuffer = 0; /* Don't buffer stdout */
/*@unchecked@*/
/*@unchecked@*/ /*@observer@*/
static const char * default_separator = ":";
/*
@ -161,10 +161,10 @@ help(void)
int
main(int argc, char **argv)
/*@globals global_fmagic, nobuffer,
default_magicfile, optind,
default_magicfile, default_separator, optind,
fileSystem, internalState @*/
/*@modifies global_fmagic, nobuffer,
default_magicfile, optind,
default_magicfile, default_separator, optind,
fileSystem, internalState @*/
{
int xx;
@ -273,8 +273,10 @@ main(int argc, char **argv)
++didsomefiles;
/*@switchbreak@*/ break;
case 'F':
/*@-assignexpose@*/
fm->separator = optarg;
break;
/*@=assignexpose@*/
/*@switchbreak@*/ break;
case 'i':
fm->flags |= FMAGIC_FLAGS_MIME;
mime = malloc(strlen(fm->magicfile) + sizeof(".mime"));

View File

@ -178,6 +178,7 @@ struct fmagic_s {
int flags; /*!< bit(s) to control fmagic behavior. */
/*@dependent@*/ /*@observer@*/ /*@relnull@*/
const char *magicfile; /*!< name of the magic file */
/*@dependent@*/ /*@observer@*/
const char *separator; /*!< file name/type separator (default ":" */
int lineno; /*!< current line number in magic file */
/*@relnull@*/

293
file/src/magic.c Normal file
View File

@ -0,0 +1,293 @@
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "magic.h"
#include "file.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/stat.h>
#include <fcntl.h> /* for open() */
#ifdef QUICK
#include <sys/mman.h>
#endif
#ifdef RESTORE_TIME
# if (__COHERENT__ >= 0x420)
# include <sys/utime.h>
# else
# ifdef USE_UTIMES
# include <sys/time.h>
# else
# include <utime.h>
# endif
# endif
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for read() */
#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <netinet/in.h> /* for byte swapping */
#include "patchlevel.h"
#ifndef lint
FILE_RCSID("@(#)$Id: magic.c,v 1.6 2003/03/26 15:35:30 christos Exp $")
#endif /* lint */
#ifdef __EMX__
private char *apptypeName = NULL;
protected int file_os2_apptype(struct magic_set *ms, const char *fn,
const void *buf, size_t nb);
#endif /* __EMX__ */
#ifndef MAGIC
# define MAGIC "/etc/magic"
#endif
private void free_mlist(struct mlist *);
public struct magic_set *
magic_open(int flags)
{
struct magic_set *ms;
if ((ms = malloc(sizeof(struct magic_set))) == NULL)
return NULL;
ms->o.ptr = ms->o.buf = malloc(ms->o.size = 1024);
ms->o.len = 0;
if (ms->o.buf == NULL) {
free(ms);
return NULL;
}
ms->c.off = malloc((ms->c.len = 10) * sizeof(*ms->c.off));
if (ms->c.off == NULL) {
free(ms->o.buf);
free(ms);
return NULL;
}
ms->flags = flags;
ms->haderr = 0;
return ms;
}
/*
* load a magic file
*/
public int
magic_load(struct magic_set *ms, const char *magicfile)
{
struct mlist *ml;
if (magicfile == NULL)
magicfile = (ms->flags & MAGIC_MIME) ? MAGIC ".mime" : MAGIC;
ml = file_apprentice(ms, magicfile, 0);
if (ml == NULL)
return -1;
ms->mlist = ml;
return 0;
}
private void
free_mlist(struct mlist *mlist)
{
struct mlist *ml;
if (mlist == NULL)
return;
for (ml = mlist->next; ml != mlist;) {
struct mlist *next = ml->next;
struct magic *mg = ml->magic;
switch (ml->mapped) {
case 0:
free(mg);
break;
case 1:
mg--;
free(mg);
break;
case 2:
mg--;
(void)munmap(mg, sizeof(*mg) * (ml->nmagic + 1));
break;
}
free(ml);
ml = next;
}
free(ml);
}
public void
magic_close(ms)
struct magic_set *ms;
{
free_mlist(ms->mlist);
free(ms->o.buf);
free(ms->c.off);
free(ms);
}
public int
magic_compile(struct magic_set *ms, const char *magicfile)
{
struct mlist *ml = file_apprentice(ms, magicfile, FILE_COMPILE);
if(ml == NULL)
return -1;
free_mlist(ml);
return ml ? 0 : -1;
}
public int
magic_check(struct magic_set *ms, const char *magicfile)
{
struct mlist *ml = file_apprentice(ms, magicfile, FILE_CHECK);
if(ml == NULL)
return -1;
free_mlist(ml);
return ml ? 0 : -1;
}
/*
* find type of named file
*/
public const char *
magic_file(struct magic_set *ms, const char *inname)
{
int fd = 0;
unsigned char buf[HOWMANY+1]; /* one extra for terminating '\0' */
struct stat sb;
int nbytes = 0; /* number of bytes read from a datafile */
if (file_reset(ms) == -1)
return NULL;
switch (file_fsmagic(ms, inname, &sb)) {
case -1:
return NULL;
case 0:
break;
default:
return ms->o.buf;
}
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
if (inname == NULL)
fd = STDIN_FILENO;
else if ((fd = open(inname, O_RDONLY)) < 0) {
/* We can't open it, but we were able to stat it. */
if (sb.st_mode & 0002)
if (file_printf(ms, "writable, ") == -1)
return NULL;
if (sb.st_mode & 0111)
if (file_printf(ms, "executable, ") == -1)
return NULL;
return ms->o.buf;
}
/*
* try looking at the first HOWMANY bytes
*/
if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
file_error(ms, "Cannot read `%s' %s", inname, strerror(errno));
return NULL;
}
if (nbytes == 0) {
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
"application/x-empty" : "empty") == -1)
return NULL;
} else {
buf[nbytes++] = '\0'; /* null-terminate it */
#ifdef __EMX__
switch (file_os2_apptype(ms, inname, buf, nbytes)) {
case -1:
return NULL;
case 0:
break;
default:
return ms->o.buf;
}
#endif
if (file_buffer(ms, buf, (size_t)nbytes) == -1)
return NULL;
#ifdef BUILTIN_ELF
if (nbytes > 5) {
/*
* We matched something in the file, so this *might*
* be an ELF file, and the file is at least 5 bytes
* long, so if it's an ELF file it has at least one
* byte past the ELF magic number - try extracting
* information from the ELF headers that can't easily
* be extracted with rules in the magic file.
*/
file_tryelf(ms, fd, buf, (size_t)nbytes);
}
#endif
}
return ms->haderr ? NULL : ms->o.buf;
}
public const char *
magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
{
if (file_reset(ms) == -1)
return NULL;
/*
* The main work is done here!
* We have the file name and/or the data buffer to be identified.
*/
if (file_buffer(ms, buf, nb) == -1) {
return NULL;
}
return ms->haderr ? NULL : ms->o.buf;
}
public const char *
magic_error(struct magic_set *ms)
{
return ms->haderr ? ms->o.buf : NULL;
}
public void
magic_setflags(struct magic_set *ms, int flags)
{
ms->flags = flags;
}

58
file/src/magic.h Normal file
View File

@ -0,0 +1,58 @@
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _MAGIC_H
#define _MAGIC_H
#include <sys/types.h>
#define MAGIC_NONE 0x00 /* No flags */
#define MAGIC_DEBUG 0x01 /* Turn on debugging */
#define MAGIC_SYMLINK 0x02 /* Follow symlinks */
#define MAGIC_COMPRESS 0x04 /* Check inside compressed files */
#define MAGIC_DEVICES 0x08 /* Look at the contents of devices */
#define MAGIC_MIME 0x10 /* Return a mime string */
#define MAGIC_CONTINUE 0x20 /* Return all matches, not just the first */
#define MAGIC_CHECK 0x40 /* Print warnings to stderr */
typedef struct magic_set *magic_t;
magic_t magic_open(int flags);
void magic_close(magic_t);
const char *magic_file(magic_t, const char *);
const char *magic_buffer(magic_t, const void *, size_t);
const char *magic_error(magic_t);
void magic_setflags(magic_t, int);
int magic_load(magic_t, const char *);
int magic_compile(magic_t, const char *);
int magic_check(magic_t, const char *);
#endif

View File

@ -1,3 +1,35 @@
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Ian F. Darwin and others.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Names.h - names and types used by ascmagic in file(1).
* These tokens are here because they can appear anywhere in
@ -5,12 +37,7 @@
* appear at fixed offsets into the file. Don't make HOWMANY
* too high unless you have a very fast CPU.
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
*
* See LEGAL.NOTICE
*
* Id: names.h,v 1.19 2002/05/16 15:01:41 christos Exp
* Id: names.h,v 1.21 2003/03/23 21:16:26 christos Exp
*/
/*
@ -37,9 +64,9 @@
/*@unchecked@*/ /*@unused@*/ /*@observer@*/
static const struct {
/*@observer@*/ /*@null@*/
char *human;
const char *human;
/*@observer@*/ /*@null@*/
char *mime;
const char *mime;
} types[] = {
{ "C program", "text/x-c", },
{ "C++ program", "text/x-c++" },

View File

@ -731,7 +731,7 @@ exit:
}
/*@-bounds@*/ /* LCL: segfault */
int rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
{
pgpDig dig;
byte buf[8*BUFSIZ];
@ -751,27 +751,31 @@ int rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
int i;
if (hdrp) *hdrp = NULL;
#ifdef DYING
{ struct stat st;
/*@-boundswrite@*/
memset(&st, 0, sizeof(st));
/*@=boundswrite@*/
(void) fstat(Fileno(fd), &st);
/* if fd points to a socket, pipe, etc, st.st_size is *always* zero */
if (S_ISREG(st.st_mode) && st.st_size < sizeof(*l))
if (S_ISREG(st.st_mode) && st.st_size < sizeof(*l)) {
rc = RPMRC_NOTFOUND;
goto exit;
}
}
#endif
memset(l, 0, sizeof(*l));
rc = readLead(fd, l);
if (rc != RPMRC_OK) {
rc = RPMRC_NOTFOUND;
if (rc != RPMRC_OK)
goto exit;
}
switch (l->major) {
case 1:
rpmError(RPMERR_NEWPACKAGE,
_("packaging version 1 is not supported by this version of RPM\n"));
rc = RPMRC_NOTFOUND;
goto exit;
/*@notreached@*/ break;
case 2:
@ -781,6 +785,7 @@ int rpmReadPackageFile(rpmts ts, FD_t fd, const char * fn, Header * hdrp)
default:
rpmError(RPMERR_NEWPACKAGE, _("only packaging with major numbers <= 4 "
"is supported by this version of RPM\n"));
rc = RPMRC_NOTFOUND;
goto exit;
/*@notreached@*/ break;
}

View File

@ -242,14 +242,14 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
struct rpmpsm_s psmbuf;
rpmpsm psm = &psmbuf;
int isSource;
rpmRC rc;
rpmRC rpmrc;
int i;
memset(psm, 0, sizeof(*psm));
psm->ts = rpmtsLink(ts, "InstallSourcePackage");
rc = rpmReadPackageFile(ts, fd, "InstallSourcePackage", &h);
switch (rc) {
rpmrc = rpmReadPackageFile(ts, fd, "InstallSourcePackage", &h);
switch (rpmrc) {
case RPMRC_NOTTRUSTED:
case RPMRC_NOKEY:
case RPMRC_OK:
@ -261,13 +261,13 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
if (h == NULL)
goto exit;
rc = RPMRC_OK;
rpmrc = RPMRC_OK;
isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
if (!isSource) {
rpmError(RPMERR_NOTSRPM, _("source package expected, binary found\n"));
rc = RPMRC_FAIL;
rpmrc = RPMRC_FAIL;
goto exit;
}
@ -277,7 +277,7 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
h = headerFree(h);
if (fi == NULL) { /* XXX can't happen */
rc = RPMRC_FAIL;
rpmrc = RPMRC_FAIL;
goto exit;
}
@ -285,7 +285,7 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
fi->te = rpmtsElement(ts, 0);
/*@=onlytrans@*/
if (fi->te == NULL) { /* XXX can't happen */
rc = RPMRC_FAIL;
rpmrc = RPMRC_FAIL;
goto exit;
}
@ -351,16 +351,16 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
}
_sourcedir = rpmGenPath(rpmtsRootDir(ts), "%{_sourcedir}", "");
rc = rpmMkdirPath(_sourcedir, "sourcedir");
if (rc) {
rc = RPMRC_FAIL;
rpmrc = rpmMkdirPath(_sourcedir, "sourcedir");
if (rpmrc) {
rpmrc = RPMRC_FAIL;
goto exit;
}
_specdir = rpmGenPath(rpmtsRootDir(ts), "%{_specdir}", "");
rc = rpmMkdirPath(_specdir, "specdir");
if (rc) {
rc = RPMRC_FAIL;
rpmrc = rpmMkdirPath(_specdir, "specdir");
if (rpmrc) {
rpmrc = RPMRC_FAIL;
goto exit;
}
@ -392,22 +392,22 @@ rpmRC rpmInstallSourcePackage(rpmts ts, FD_t fd,
specFile = t;
} else {
rpmError(RPMERR_NOSPEC, _("source package contains no .spec file\n"));
rc = RPMRC_FAIL;
rpmrc = RPMRC_FAIL;
goto exit;
}
psm->goal = PSM_PKGINSTALL;
/*@-compmempass@*/ /* FIX: psm->fi->dnl should be owned. */
rc = rpmpsmStage(psm, PSM_PROCESS);
rpmrc = rpmpsmStage(psm, PSM_PROCESS);
(void) rpmpsmStage(psm, PSM_FINI);
/*@=compmempass@*/
if (rc) rc = RPMRC_FAIL;
if (rpmrc) rpmrc = RPMRC_FAIL;
exit:
if (specFilePtr && specFile && rc == RPMRC_OK)
if (specFilePtr && specFile && rpmrc == RPMRC_OK)
*specFilePtr = specFile;
else
specFile = _free(specFile);
@ -436,7 +436,7 @@ exit:
psm->ts = rpmtsFree(psm->ts);
return rc;
return rpmrc;
}
/*@observer@*/ /*@unchecked@*/

View File

@ -52,20 +52,23 @@ rpmRC readLead(FD_t fd, struct rpmlead *lead)
/*@=boundswrite@*/
/*@-type@*/ /* FIX: remove timed read */
if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
rpmError(RPMERR_READ, _("read failed: %s (%d)\n"), Fstrerror(fd),
errno);
return RPMRC_FAIL;
if (Ferror(fd)) {
rpmError(RPMERR_READ, _("read failed: %s (%d)\n"),
Fstrerror(fd), errno);
return RPMRC_FAIL;
}
return RPMRC_NOTFOUND;
}
/*@=type@*/
if (memcmp(lead->magic, lead_magic, sizeof(lead_magic)))
return RPMRC_FAIL;
return RPMRC_NOTFOUND;
lead->type = ntohs(lead->type);
lead->archnum = ntohs(lead->archnum);
lead->osnum = ntohs(lead->osnum);
lead->signature_type = ntohs(lead->signature_type);
if (lead->signature_type != RPMSIGTYPE_HEADERSIG)
return RPMRC_FAIL;
return RPMRC_NOTFOUND;
return RPMRC_OK;
}

View File

@ -12,8 +12,8 @@ extern "C" {
/** \ingroup lead
* Write lead to file handle.
* @param fd file handle
* @param lead data address
* @return 0 on success
* @param lead package lead
* @return RPMRC_OK on success, RPMRC_FAIL on error
*/
rpmRC writeLead(FD_t fd, const struct rpmlead *lead)
/*@globals fileSystem @*/
@ -22,8 +22,8 @@ rpmRC writeLead(FD_t fd, const struct rpmlead *lead)
/** \ingroup lead
* Read lead from file handle.
* @param fd file handle
* @retval lead data address
* @return 0 on success
* @retval lead package lead
* @return RPMRC_OK on success, RPMRC_FAIL/RPMRC_NOTFOUND on error
*/
rpmRC readLead(FD_t fd, /*@out@*/ struct rpmlead *lead)
/*@modifies fd, *lead @*/;

View File

@ -893,9 +893,9 @@ rpmRC rpmReadHeader(rpmts ts, FD_t fd, /*@out@*/ Header *hdrp,
* @param fd file handle
* @param fn file name
* @retval hdrp address of header (or NULL)
* @return 0 on success
* @return RPMRC_OK on success
*/
int rpmReadPackageFile(rpmts ts, FD_t fd,
rpmRC rpmReadPackageFile(rpmts ts, FD_t fd,
const char * fn, /*@null@*/ /*@out@*/ Header * hdrp)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies ts, fd, *hdrp, rpmGlobalMacroContext,

View File

@ -752,11 +752,6 @@ fprintf(stderr, "*** rpmts_HdrFromFdno(%p) ts %p rc %d\n", s, s->ts, rpmrc);
h = headerFree(h); /* XXX ref held by result */
break;
case RPMRC_NOTFOUND:
Py_INCREF(Py_None);
result = Py_None;
break;
case RPMRC_NOKEY:
PyErr_SetString(pyrpmError, "public key not available");
break;
@ -765,6 +760,7 @@ fprintf(stderr, "*** rpmts_HdrFromFdno(%p) ts %p rc %d\n", s, s->ts, rpmrc);
PyErr_SetString(pyrpmError, "public key not trusted");
break;
case RPMRC_NOTFOUND:
case RPMRC_FAIL:
default:
PyErr_SetString(pyrpmError, "error reading package header");

View File

@ -31,7 +31,7 @@ librpmio_la_SOURCES = \
rpmio.c rpmlog.c rpmmalloc.c \
rpmpgp.c rpmrpc.c rpmsq.c rpmsw.c strcasecmp.c stubs.c url.c ugid.c
librpmio_la_LDFLAGS = -release @VERSION@ $(LDFLAGS) \
$(top_builddir)/file/libfmagic.la \
$(top_builddir)/file/src/libfmagic.la \
@WITH_ZLIB_LIB@ \
-lrt -lpthread
librpmio_la_LIBADD = $(BEECRYPTLOBJS)

View File

@ -11,7 +11,7 @@ INCLUDES = -I. \
-I$(top_srcdir)/popt \
@WITH_LIBELF_INCLUDE@ \
@WITH_LIBDWARF_INCLUDE@ \
-I$(top_srcdir)/file \
-I$(top_srcdir)/file/src \
@INCPATH@ \
-I$(top_srcdir)/misc
@ -48,7 +48,7 @@ rpmdeps_SOURCES = rpmdeps.c
rpmdeps_LDADD = $(top_builddir)/build/librpmbuild.la
#rpmdeps_LDFLAGS = $(staticLDFLAGS)
rpmfile.c: $(top_builddir)/file/file.c
rpmfile.c: $(top_builddir)/file/src/file.c
rm -f $@
ln -s $< $@

View File

@ -192,7 +192,7 @@ static int ftsStashLatest(FTSENT * fts, rpmts ts)
/* Read header from file. */
{ FD_t fd = Fopen(fts->fts_accpath, "r");
rpmRC rc;
rpmRC rpmrc;
int xx;
if (fd == NULL || Ferror(fd)) {
@ -200,9 +200,9 @@ static int ftsStashLatest(FTSENT * fts, rpmts ts)
goto exit;
}
rc = rpmReadPackageFile(ts, fd, fts->fts_path, &h);
rpmrc = rpmReadPackageFile(ts, fd, fts->fts_path, &h);
xx = Fclose(fd);
if (rc != RPMRC_OK || h == NULL)
if (rpmrc != RPMRC_OK || h == NULL)
goto exit;
}

View File

@ -163,18 +163,13 @@ restart:
rc = rpmReadPackageFile(ts, fd, *fnp, &h);
Fclose(fd);
if (rc == 2) {
numFailed++; *fnp = NULL;
continue;
}
if (rc == 0) {
if (rc == RPMRC_OK) {
rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName, 0, NULL);
h = headerFree(h);
continue;
}
if (rc != 1) {
if (rc != RPMRC_NOTFOUND) {
rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *fnp);
numFailed++; *fnp = NULL;
break;