diff options
author | jbj <devnull@localhost> | 2001-07-03 19:26:58 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-07-03 19:26:58 +0000 |
commit | 20c2a42d4f18fe324c3bc06cc106136130f44c9b (patch) | |
tree | b91052527d2dca54bd52748d36880e6475f58f6a /build | |
parent | c33e408649c342e000edce34ca122058a9050cdd (diff) | |
download | rpm-20c2a42d4f18fe324c3bc06cc106136130f44c9b.tar.gz rpm-20c2a42d4f18fe324c3bc06cc106136130f44c9b.tar.bz2 rpm-20c2a42d4f18fe324c3bc06cc106136130f44c9b.zip |
- fix: redundant entries in file manifests handled correctly (#46914).
- map uid/gid from metadata into payload headers.
CVS patchset: 4915
CVS date: 2001/07/03 19:26:58
Diffstat (limited to 'build')
-rw-r--r-- | build/files.c | 27 | ||||
-rw-r--r-- | build/names.c | 42 | ||||
-rw-r--r-- | build/rpmbuild.h | 16 |
3 files changed, 72 insertions, 13 deletions
diff --git a/build/files.c b/build/files.c index 4831c895f..d3e371b99 100644 --- a/build/files.c +++ b/build/files.c @@ -1017,22 +1017,15 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, for (i = 0, flp = fl->fileList; i < fl->fileListRecsUsed; i++, flp++) { char *s; -#ifdef DYING - if (i < (fl->fileListRecsUsed - 1) && - !strcmp(flp->fileURL, flp[1].fileURL)) - { - rpmError(RPMERR_BADSPEC, _("File listed twice: %s\n"), - flp->fileURL); - fl->processingFailed = 1; - } -#endif - /* Merge duplicate entries. */ while (i < (fl->fileListRecsUsed - 1) && !strcmp(flp->fileURL, flp[1].fileURL)) { /* Two entries for the same file found, merge the entries. */ + rpmMessage(RPMMESS_WARNING, _("File listed twice: %s\n"), + flp->fileURL); + /* file flags */ flp[1].flags |= flp->flags; @@ -1247,6 +1240,11 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, for (i = 0, flp = fl->fileList; i < fi->fc; i++, flp++) { char * b; + /* Skip (possible) duplicate file entries, use last entry info. */ + while (((flp - fl->fileList) < (fl->fileListRecsUsed - 1)) && + !strcmp(flp->fileURL, flp[1].fileURL)) + flp++; + /* Create disk directory and base name. */ fi->dil[i] = i; fi->dnl[fi->dil[i]] = d; @@ -1273,8 +1271,10 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl, continue; } fi->actions[i] = FA_COPYOUT; - fi->fuids[i] = flp->fl_uid; - fi->fgids[i] = flp->fl_gid; + fi->fuids[i] = getUidS(flp->uname); + fi->fgids[i] = getGidS(flp->gname); + if (fi->fuids[i] == (uid_t)-1) fi->fuids[i] = 0; + if (fi->fgids[i] == (gid_t)-1) fi->fgids[i] = 0; fi->fmapflags[i] = CPIO_MAP_PATH | CPIO_MAP_MODE | CPIO_MAP_UID | CPIO_MAP_GID; if (isSrc) @@ -1905,11 +1905,12 @@ int processSourceFiles(Spec spec) spec->sourceCpioList = NULL; - fl.fileList = xmalloc((spec->numSources + 1) * sizeof(*fl.fileList)); + fl.fileList = xcalloc((spec->numSources + 1), sizeof(*fl.fileList)); fl.processingFailed = 0; fl.fileListRecsUsed = 0; fl.totalFileSize = 0; fl.prefix = NULL; + fl.buildRootURL = NULL; s = getStringBuf(sourceFiles); files = splitString(s, strlen(s), '\n'); diff --git a/build/names.c b/build/names.c index 84470f705..4c517a3a7 100644 --- a/build/names.c +++ b/build/names.c @@ -69,6 +69,27 @@ const char *getUnameS(const char *uname) return unames[x]; } +uid_t getUidS(const char *uname) +{ + struct passwd *pw; + int x; + + for (x = 0; x < uid_used; x++) { + if (!strcmp(unames[x],uname)) + return uids[x]; + } + + /* XXX - This is the other hard coded limit */ + if (x == 1024) + rpmlog(RPMLOG_CRIT, _("getUidS: too many uid's\n")); + uid_used++; + + pw = getpwnam(uname); + uids[x] = (pw ? pw->pw_uid : -1); + unames[x] = (pw ? xstrdup(pw->pw_name) : xstrdup(uname)); + return uids[x]; +} + const char *getGname(gid_t gid) { struct group *gr; @@ -110,6 +131,27 @@ const char *getGnameS(const char *gname) gnames[x] = (gr ? xstrdup(gr->gr_name) : xstrdup(gname)); return gnames[x]; } + +gid_t getGidS(const char *gname) +{ + struct group *gr; + int x; + + for (x = 0; x < gid_used; x++) { + if (!strcmp(gnames[x], gname)) + return gids[x]; + } + + /* XXX - This is the other hard coded limit */ + if (x == 1024) + rpmlog(RPMLOG_CRIT, _("getGidS: too many gid's\n")); + gid_used++; + + gr = getgrnam(gname); + gids[x] = (gr ? gr->gr_gid : -1); + gnames[x] = (gr ? xstrdup(gr->gr_name) : xstrdup(gname)); + return gids[x]; +} /*@=nullderef@*/ int_32 *const getBuildTime(void) diff --git a/build/rpmbuild.h b/build/rpmbuild.h index 9b55c6458..476812405 100644 --- a/build/rpmbuild.h +++ b/build/rpmbuild.h @@ -101,6 +101,14 @@ void freeNames(void) /*@observer@*/ const char * getUnameS(const char * uname) /*@*/; /** \ingroup rpmbuild + * Return cached user id. + * @todo Implement using hash. + * @param user name + * @return cached uid + */ +uid_t getUidS(const char * uname) /*@*/; + +/** \ingroup rpmbuild * Return cached group name from group id. * @todo Implement using hash. * @param group id @@ -117,6 +125,14 @@ void freeNames(void) /*@observer@*/ const char * getGnameS(const char * gname) /*@*/; /** \ingroup rpmbuild + * Return cached group id. + * @todo Implement using hash. + * @param group name + * @return cached gid + */ +gid_t getGidS(const char * gname) /*@*/; + +/** \ingroup rpmbuild * Return build hostname. * @return build hostname */ |