RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 15-Apr-2016 20:47:01 Branch: rpm-5_4 Handle: 2016041518470100 Modified files: (Branch: rpm-5_4) rpm/lib manifest.c Log: - WIP. Summary: Revision Changes Path 2.26.6.2 +61 -6 rpm/lib/manifest.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/lib/manifest.c ============================================================================ $ cvs diff -u -r2.26.6.1 -r2.26.6.2 manifest.c --- rpm/lib/manifest.c 15 Apr 2012 21:20:57 -0000 2.26.6.1 +++ rpm/lib/manifest.c 15 Apr 2016 18:47:01 -0000 2.26.6.2 @@ -7,6 +7,7 @@ #include <rpmio_internal.h> /* XXX fdGetFp */ #include <rpmlog.h> #include <rpmmacro.h> +#include <argv.h> #include <rpmtypes.h> #include "manifest.h" @@ -67,6 +68,8 @@ char * se; int ac = 0; const char ** av = NULL; + int nac = 0; + const char ** nav = NULL; int argc = (argcPtr ? *argcPtr : 0); const char ** argv = (argvPtr ? *argvPtr : NULL); FD_t xfd; @@ -91,10 +94,15 @@ /* Read next line. */ s = fgets(line, sizeof(line) - 1, f); + line[sizeof(line)-1] = '\0'; if (s == NULL) { - if (Ferror(xfd)) + if (Ferror(xfd)) { + rpmrc = RPMRC_FAIL; rpmlog(RPMLOG_ERR, _("reading %s manifest failed: %s\n"), fdGetOPath(xfd), Fstrerror(xfd)); + goto exit; + } + /* s == NULL on EOF */ break; } @@ -102,13 +110,15 @@ #define DOCTYPE_HTML_PUBLIC "<!DOCTYPE HTML PUBLIC" if (!strncmp(line, DOCTYPE_HTML_PUBLIC, sizeof(DOCTYPE_HTML_PUBLIC)-1)) { rpmrc = RPMRC_NOTFOUND; + rpmlog(RPMLOG_DEBUG, _("=== #%d rc(%d) adding %d args from manifest: %s\n"), + 1, rpmrc, ac, fdGetOPath(xfd)); goto exit; } /* Skip comments. */ if ((se = strchr(s, '#')) != NULL) *se = '\0'; - /* Trim white space. */ + /* Trim leading/trailing white space. */ se = s + strlen(s); while (se > s && (se[-1] == '\n' || se[-1] == '\r')) *(--se) = '\0'; @@ -118,10 +128,16 @@ /* Insure that file contains only ASCII */ if (*s < 32) { +#ifdef DYING rpmlog(RPMLOG_ERR, _("reading %s manifest, non-printable characters found\n"), fdGetOPath(xfd)); rpmrc = RPMRC_FAIL; /* XXX reject non-printable manifests. */ +#else + rpmrc = RPMRC_NOTFOUND; /* XXX RPMRC_FAIL? */ +#endif + rpmlog(RPMLOG_DEBUG, _("=== #%d rc(%d) adding %d args from manifest: %s\n"), + 2, rpmrc, ac, fdGetOPath(xfd)); goto exit; } @@ -135,15 +151,54 @@ s = rpmiobStr(iob); if (!(s && *s)) { +#ifdef DYING rpmrc = RPMRC_FAIL; /* XXX force manifests to have content. */ +#else + rpmrc = RPMRC_NOTFOUND; /* XXX skip manifests with no content. */ +#endif + rpmlog(RPMLOG_DEBUG, _("=== #%d, rc(%d) adding %d args from manifest: %s\n"), + 3, rpmrc, ac, fdGetOPath(xfd)); goto exit; } /* Glob manifest items. */ rpmrc = (rpmRC) rpmGlob(s, &ac, &av); - if (rpmrc != RPMRC_OK) goto exit; + if (rpmrc == RPMRC_FAIL) { + rpmlog(RPMLOG_DEBUG, _("=== #%d rc(%d) adding %d args from manifest: %s\n"), + 4, rpmrc, ac, fdGetOPath(xfd)); + goto exit; + } + + /* All added manifest arguments must be existing files */ + if (av != NULL) { + nav = NULL; + for (i = 0; i < ac; i++) { + struct stat sb, *st = &sb; + if (Stat(av[i], st) == 0 && S_ISREG(st->st_mode) && st->st_size > 0) { + if (nav == NULL) + rpmlog(RPMLOG_DEBUG, "=== %s\n", fdGetOPath(xfd)); + + rpmlog(RPMLOG_DEBUG, "+++\t%5d %s\n", i, av[i]); + (void) argvAdd(&nav, av[i]); + } + av[i] = _free(av[i]); + } + av = _free(av); + av = nav; + nav = NULL; + ac = argvCount(av); + } + + /* Don't bother if nothing to do. */ + if (!(ac > 0 && av && av[0] && *av[0])) { + rpmrc = RPMRC_NOTFOUND; + rpmlog(RPMLOG_DEBUG, _("=== #%d rc(%d) adding %d args from manifest: %s\n"), + 5, rpmrc, ac, fdGetOPath(xfd)); + goto exit; + } - rpmlog(RPMLOG_DEBUG, D_("adding %d args from manifest.\n"), ac); + rpmlog(RPMLOG_INFO, _("==> adding %d args from manifest: %s\n"), + ac, fdGetOPath(xfd)); /* Count non-NULL args, keeping track of 1st arg after last NULL. */ npre = 0; @@ -158,8 +213,8 @@ /* Copy old arg list, inserting manifest before argv[next]. */ if (argv != NULL) { - int nac = npre + ac; - const char ** nav = (const char **) xcalloc((nac + 1), sizeof(*nav)); + nac = npre + ac; + nav = (const char **) xcalloc((nac + 1), sizeof(*nav)); for (i = 0, j = 0; i < next; i++) { if (argv[i] != NULL) @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org