Commit 17dc95a7 authored by Michal Čihař's avatar Michal Čihař

New upstream version 4.13.0+dfsg1

parent 2b271a53
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -167,6 +167,10 @@ rpmlibexec_PROGRAMS += elfdeps
elfdeps_SOURCES = tools/elfdeps.c
elfdeps_LDADD = rpmio/librpmio.la
elfdeps_LDADD += @WITH_LIBELF_LIB@ @WITH_POPT_LIB@
rpmlibexec_PROGRAMS += sepdebugcrcfix
sepdebugcrcfix_SOURCES = tools/sepdebugcrcfix.c
sepdebugcrcfix_LDADD = @WITH_LIBELF_LIB@
endif
endif
......@@ -195,6 +199,9 @@ macros: $(top_srcdir)/macros.in
CLEANFILES += macros
EXTRA_DIST += macros.in
# Used for the testsuite to test creating debuginfo packages
EXTRA_DIST += macros.debug
noinst_DATA += platform
platform: $(top_srcdir)/platform.in
@$(SED) \
......
......@@ -106,7 +106,8 @@ bin_PROGRAMS = rpm2cpio$(EXEEXT) rpmbuild$(EXEEXT) rpmdb$(EXEEXT) \
@WITH_ARCHIVE_TRUE@am__append_6 = rpm2archive
rpmlibexec_PROGRAMS = $(am__EXEEXT_2) rpmdeps$(EXEEXT)
@LIBDWARF_TRUE@@LIBELF_TRUE@am__append_7 = scripts/find-debuginfo.sh
@LIBDWARF_TRUE@@LIBELF_TRUE@am__append_8 = debugedit elfdeps
@LIBDWARF_TRUE@@LIBELF_TRUE@am__append_8 = debugedit elfdeps \
@LIBDWARF_TRUE@@LIBELF_TRUE@ sepdebugcrcfix
@DOXYGEN_TRUE@@HACKINGDOCS_TRUE@am__append_9 = doc/hacking/html/index.html
@DOXYGEN_TRUE@am__append_10 = doc/librpm/html/index.html
@WITH_INTERNAL_DB_TRUE@am__append_11 = db.h
......@@ -146,7 +147,8 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(rpmbindir)" \
"$(DESTDIR)$(rpmconfigdir)" "$(DESTDIR)$(rpmvardir)" \
"$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"
@LIBDWARF_TRUE@@LIBELF_TRUE@am__EXEEXT_2 = debugedit$(EXEEXT) \
@LIBDWARF_TRUE@@LIBELF_TRUE@ elfdeps$(EXEEXT)
@LIBDWARF_TRUE@@LIBELF_TRUE@ elfdeps$(EXEEXT) \
@LIBDWARF_TRUE@@LIBELF_TRUE@ sepdebugcrcfix$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(rpmbin_PROGRAMS) $(rpmlibexec_PROGRAMS)
am__debugedit_SOURCES_DIST = tools/debugedit.c tools/hashtab.c \
tools/hashtab.h
......@@ -196,6 +198,11 @@ am_rpmspec_OBJECTS = rpmspec-rpmspec.$(OBJEXT)
rpmspec_OBJECTS = $(am_rpmspec_OBJECTS)
rpmspec_DEPENDENCIES = libcliutils.la build/librpmbuild.la \
lib/librpm.la rpmio/librpmio.la
am__sepdebugcrcfix_SOURCES_DIST = tools/sepdebugcrcfix.c
@LIBDWARF_TRUE@@LIBELF_TRUE@am_sepdebugcrcfix_OBJECTS = \
@LIBDWARF_TRUE@@LIBELF_TRUE@ tools/sepdebugcrcfix.$(OBJEXT)
sepdebugcrcfix_OBJECTS = $(am_sepdebugcrcfix_OBJECTS)
sepdebugcrcfix_DEPENDENCIES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
......@@ -262,12 +269,14 @@ SOURCES = $(libcliutils_la_SOURCES) $(debugedit_SOURCES) \
$(elfdeps_SOURCES) $(rpm_SOURCES) $(rpm2archive_SOURCES) \
$(rpm2cpio_SOURCES) $(rpmbuild_SOURCES) $(rpmdb_SOURCES) \
$(rpmdeps_SOURCES) $(rpmgraph_SOURCES) $(rpmkeys_SOURCES) \
$(rpmsign_SOURCES) $(rpmspec_SOURCES)
$(rpmsign_SOURCES) $(rpmspec_SOURCES) \
$(sepdebugcrcfix_SOURCES)
DIST_SOURCES = $(libcliutils_la_SOURCES) $(am__debugedit_SOURCES_DIST) \
$(am__elfdeps_SOURCES_DIST) $(rpm_SOURCES) \
$(rpm2archive_SOURCES) $(rpm2cpio_SOURCES) $(rpmbuild_SOURCES) \
$(rpmdb_SOURCES) $(rpmdeps_SOURCES) $(rpmgraph_SOURCES) \
$(rpmkeys_SOURCES) $(rpmsign_SOURCES) $(rpmspec_SOURCES)
$(rpmkeys_SOURCES) $(rpmsign_SOURCES) $(rpmspec_SOURCES) \
$(am__sepdebugcrcfix_SOURCES_DIST)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
......@@ -603,7 +612,7 @@ rpmlibexecdir = $(prefix)/lib/rpm
rpmconfigdir = $(prefix)/lib/rpm
# Libtool version (current-revision-age) for all our libraries
rpm_version_info = 6:1:3
rpm_version_info = 7:0:0
CLEANFILES = rpmrc.tmp rpmrc macros platform.tmp platform rpm.pc.tmp \
rpm.pc rpmpopt-@VERSION@.tmp rpmpopt-@VERSION@ \
include/rpm/argv.h include/rpm/rpmio.h include/rpm/rpmurl.h \
......@@ -623,10 +632,12 @@ CLEANFILES = rpmrc.tmp rpmrc macros platform.tmp platform rpm.pc.tmp \
include/rpm/rpmarchive.h include/rpm/rpmsign.h \
include/rpm/rpmbuild.h include/rpm/rpmfc.h \
include/rpm/rpmspec.h
# Used for the testsuite to test creating debuginfo packages
EXTRA_DIST = CHANGES ChangeLog CREDITS GROUPS INSTALL autogen.sh \
db3/configure installplatform platform.in rpmrc.in macros.in \
platform.in rpm.pc.in rpmpopt.in doc/hacking.doxy.in \
doc/hacking/Doxyheader doc/librpm.doxy.in \
macros.debug platform.in rpm.pc.in rpmpopt.in \
doc/hacking.doxy.in doc/hacking/Doxyheader doc/librpm.doxy.in \
doc/librpm/Doxyheader doc/librpm/html
BUILT_SOURCES = $(am__append_11) include/rpm/argv.h \
include/rpm/rpmio.h include/rpm/rpmurl.h \
......@@ -718,6 +729,8 @@ rpm2archive_LDADD = lib/librpm.la rpmio/librpmio.la @WITH_NSS_LIB@ \
@LIBDWARF_TRUE@@LIBELF_TRUE@elfdeps_LDADD = rpmio/librpmio.la \
@LIBDWARF_TRUE@@LIBELF_TRUE@ @WITH_LIBELF_LIB@ @WITH_POPT_LIB@ \
@LIBDWARF_TRUE@@LIBELF_TRUE@ $(am__empty)
@LIBDWARF_TRUE@@LIBELF_TRUE@sepdebugcrcfix_SOURCES = tools/sepdebugcrcfix.c
@LIBDWARF_TRUE@@LIBELF_TRUE@sepdebugcrcfix_LDADD = @WITH_LIBELF_LIB@
rpmdeps_SOURCES = tools/rpmdeps.c
rpmdeps_LDADD = lib/librpm.la rpmio/librpmio.la build/librpmbuild.la @WITH_POPT_LIB@
rpmgraph_SOURCES = tools/rpmgraph.c
......@@ -1010,6 +1023,12 @@ rpmsign$(EXEEXT): $(rpmsign_OBJECTS) $(rpmsign_DEPENDENCIES) $(EXTRA_rpmsign_DEP
rpmspec$(EXEEXT): $(rpmspec_OBJECTS) $(rpmspec_DEPENDENCIES) $(EXTRA_rpmspec_DEPENDENCIES)
@rm -f rpmspec$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(rpmspec_OBJECTS) $(rpmspec_LDADD) $(LIBS)
tools/sepdebugcrcfix.$(OBJEXT): tools/$(am__dirstamp) \
tools/$(DEPDIR)/$(am__dirstamp)
sepdebugcrcfix$(EXEEXT): $(sepdebugcrcfix_OBJECTS) $(sepdebugcrcfix_DEPENDENCIES) $(EXTRA_sepdebugcrcfix_DEPENDENCIES)
@rm -f sepdebugcrcfix$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(sepdebugcrcfix_OBJECTS) $(sepdebugcrcfix_LDADD) $(LIBS)
install-dist_binSCRIPTS: $(dist_bin_SCRIPTS)
@$(NORMAL_INSTALL)
@list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
......@@ -1102,6 +1121,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/hashtab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/rpmdeps.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/rpmgraph.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tools/$(DEPDIR)/sepdebugcrcfix.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
......
......@@ -23,5 +23,6 @@ librpmbuild_la_LIBADD = \
$(top_builddir)/lib/librpm.la \
$(top_builddir)/rpmio/librpmio.la \
$(top_builddir)/misc/libmisc.la \
@LTLIBICONV@ \
@WITH_POPT_LIB@ \
@WITH_MAGIC_LIB@
......@@ -457,7 +457,7 @@ rpmlibexecdir = $(prefix)/lib/rpm
rpmconfigdir = $(prefix)/lib/rpm
# Libtool version (current-revision-age) for all our libraries
rpm_version_info = 6:1:3
rpm_version_info = 7:0:0
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) \
-I$(top_builddir)/include/ @WITH_NSS_INCLUDE@ \
@WITH_MAGIC_INCLUDE@ @WITH_POPT_INCLUDE@ -I$(top_srcdir)/misc
......@@ -476,6 +476,7 @@ librpmbuild_la_LIBADD = \
$(top_builddir)/lib/librpm.la \
$(top_builddir)/rpmio/librpmio.la \
$(top_builddir)/misc/libmisc.la \
@LTLIBICONV@ \
@WITH_POPT_LIB@ \
@WITH_MAGIC_LIB@
......
This diff is collapsed.
......@@ -132,11 +132,13 @@ static rpmRC addFileToTag(rpmSpec spec, const char * file,
}
while (fgets(buf, sizeof(buf), f)) {
if (expandMacros(spec, spec->macros, buf, sizeof(buf))) {
char *expanded;
if(rpmExpandMacros(spec->macros, buf, &expanded, 0) < 0) {
rpmlog(RPMLOG_ERR, _("%s: line: %s\n"), fn, buf);
goto exit;
}
appendStringBuf(sb, buf);
appendStringBuf(sb, expanded);
free(expanded);
}
headerPutString(h, tag, getStringBuf(sb));
rc = RPMRC_OK;
......@@ -163,16 +165,25 @@ static const char * buildHost(void)
static char hostname[1024];
static int oneshot = 0;
struct hostent *hbn;
char *bhMacro;
if (! oneshot) {
(void) gethostname(hostname, sizeof(hostname));
hbn = gethostbyname(hostname);
if (hbn)
strcpy(hostname, hbn->h_name);
else
rpmlog(RPMLOG_WARNING,
_("Could not canonicalize hostname: %s\n"), hostname);
oneshot = 1;
bhMacro = rpmExpand("%{?_buildhost}", NULL);
if (strcmp(bhMacro, "") != 0 && strlen(bhMacro) < 1024) {
strcpy(hostname, bhMacro);
} else {
if (strcmp(bhMacro, "") != 0)
rpmlog(RPMLOG_WARNING, _("The _buildhost macro is too long\n"));
(void) gethostname(hostname, sizeof(hostname));
hbn = gethostbyname(hostname);
if (hbn)
strcpy(hostname, hbn->h_name);
else
rpmlog(RPMLOG_WARNING,
_("Could not canonicalize hostname: %s\n"), hostname);
}
free(bhMacro);
oneshot = 1;
}
return(hostname);
}
......@@ -183,6 +194,25 @@ static rpmRC processScriptFiles(rpmSpec spec, Package pkg)
int addflags = 0;
rpmRC rc = RPMRC_FAIL;
Header h = pkg->header;
struct TriggerFileEntry *tfa[] = {pkg->triggerFiles,
pkg->fileTriggerFiles,
pkg->transFileTriggerFiles};
rpmTagVal progTags[] = {RPMTAG_TRIGGERSCRIPTPROG,
RPMTAG_FILETRIGGERSCRIPTPROG,
RPMTAG_TRANSFILETRIGGERSCRIPTPROG};
rpmTagVal flagTags[] = {RPMTAG_TRIGGERSCRIPTFLAGS,
RPMTAG_FILETRIGGERSCRIPTFLAGS,
RPMTAG_TRANSFILETRIGGERSCRIPTFLAGS};
rpmTagVal scriptTags[] = {RPMTAG_TRIGGERSCRIPTS,
RPMTAG_FILETRIGGERSCRIPTS,
RPMTAG_TRANSFILETRIGGERSCRIPTS};
rpmTagVal priorityTags[] = {0,
RPMTAG_FILETRIGGERPRIORITIES,
RPMTAG_TRANSFILETRIGGERPRIORITIES};
int i;
if (addFileToTag(spec, pkg->preInFile, h, RPMTAG_PREIN, 1) ||
addFileToTag(spec, pkg->preUnFile, h, RPMTAG_PREUN, 1) ||
......@@ -195,30 +225,39 @@ static rpmRC processScriptFiles(rpmSpec spec, Package pkg)
goto exit;
}
/* if any trigger has flags, we need to add flags entry for all of them */
for (p = pkg->triggerFiles; p != NULL; p = p->next) {
if (p->flags) {
addflags = 1;
break;
}
}
for (p = pkg->triggerFiles; p != NULL; p = p->next) {
headerPutString(h, RPMTAG_TRIGGERSCRIPTPROG, p->prog);
if (addflags) {
headerPutUint32(h, RPMTAG_TRIGGERSCRIPTFLAGS, &p->flags, 1);
for (i = 0; i < sizeof(tfa)/sizeof(tfa[0]); i++) {
addflags = 0;
/* if any trigger has flags, we need to add flags entry for all of them */
for (p = tfa[i]; p != NULL; p = p->next) {
if (p->flags) {
addflags = 1;
break;
}
}
if (p->script) {
headerPutString(h, RPMTAG_TRIGGERSCRIPTS, p->script);
} else if (p->fileName) {
if (addFileToTag(spec, p->fileName, h, RPMTAG_TRIGGERSCRIPTS, 0)) {
goto exit;
for (p = tfa[i]; p != NULL; p = p->next) {
headerPutString(h, progTags[i], p->prog);
if (priorityTags[i]) {
headerPutUint32(h, priorityTags[i], &p->priority, 1);
}
if (addflags) {
headerPutUint32(h, flagTags[i], &p->flags, 1);
}
if (p->script) {
headerPutString(h, scriptTags[i], p->script);
} else if (p->fileName) {
if (addFileToTag(spec, p->fileName, h, scriptTags[i], 0)) {
goto exit;
}
} else {
/* This is dumb. When the header supports NULL string */
/* this will go away. */
headerPutString(h, scriptTags[i], "");
}
} else {
/* This is dumb. When the header supports NULL string */
/* this will go away. */
headerPutString(h, RPMTAG_TRIGGERSCRIPTS, "");
}
}
rc = RPMRC_OK;
......@@ -227,41 +266,30 @@ exit:
return rc;
}
static int depContainsTilde(Header h, rpmTagVal tagEVR)
static int haveTildeDep(Package pkg)
{
struct rpmtd_s evrs;
const char *evr = NULL;
if (headerGet(h, tagEVR, &evrs, HEADERGET_MINMEM)) {
while ((evr = rpmtdNextString(&evrs)) != NULL)
if (strchr(evr, '~'))
break;
rpmtdFreeData(&evrs);
for (int i = 0; i < PACKAGE_NUM_DEPS; i++) {
rpmds ds = rpmdsInit(pkg->dependencies[i]);
while (rpmdsNext(ds) >= 0) {
if (strchr(rpmdsEVR(ds), '~'))
return 1;
}
}
return evr != NULL;
return 0;
}
static rpmTagVal depevrtags[] = {
RPMTAG_PROVIDEVERSION,
RPMTAG_REQUIREVERSION,
RPMTAG_OBSOLETEVERSION,
RPMTAG_CONFLICTVERSION,
RPMTAG_ORDERVERSION,
RPMTAG_TRIGGERVERSION,
RPMTAG_SUGGESTVERSION,
RPMTAG_ENHANCEVERSION,
RPMTAG_RECOMMENDVERSION,
RPMTAG_SUPPLEMENTVERSION,
0
};
static int haveTildeDep(Header h)
static int haveRichDep(Package pkg)
{
int i;
for (i = 0; depevrtags[i] != 0; i++)
if (depContainsTilde(h, depevrtags[i]))
return 1;
for (int i = 0; i < PACKAGE_NUM_DEPS; i++) {
rpmds ds = rpmdsInit(pkg->dependencies[i]);
rpmTagVal tagN = rpmdsTagN(ds);
if (tagN != RPMTAG_REQUIRENAME && tagN != RPMTAG_CONFLICTNAME)
continue;
while (rpmdsNext(ds) >= 0) {
if (rpmdsIsRich(ds))
return 1;
}
}
return 0;
}
......@@ -279,92 +307,6 @@ static rpm_loff_t estimateCpioSize(Package pkg)
return size;
}
static rpmRC generateSignature(char *SHA1, uint8_t *MD5, rpm_loff_t size,
rpm_loff_t payloadSize, FD_t fd)
{
Header sig = NULL;
struct rpmtd_s td;
rpmRC rc = RPMRC_OK;
char *reservedSpace;
int spaceSize = 0;
/* Prepare signature */
sig = rpmNewSignature();
rpmtdReset(&td);
td.tag = RPMSIGTAG_SHA1;
td.count = 1;
td.type = RPM_STRING_TYPE;
td.data = SHA1;
headerPut(sig, &td, HEADERPUT_DEFAULT);
rpmtdReset(&td);
td.tag = RPMSIGTAG_MD5;
td.count = 16;
td.type = RPM_BIN_TYPE;
td.data = MD5;
headerPut(sig, &td, HEADERPUT_DEFAULT);
rpmtdReset(&td);
td.count = 1;
if (payloadSize < UINT32_MAX) {
rpm_off_t p = payloadSize;
rpm_off_t s = size;
td.type = RPM_INT32_TYPE;
td.tag = RPMSIGTAG_PAYLOADSIZE;
td.data = &p;
headerPut(sig, &td, HEADERPUT_DEFAULT);
td.tag = RPMSIGTAG_SIZE;
td.data = &s;
headerPut(sig, &td, HEADERPUT_DEFAULT);
} else {
rpm_loff_t p = payloadSize;
rpm_loff_t s = size;
td.type = RPM_INT64_TYPE;
td.tag = RPMSIGTAG_LONGARCHIVESIZE;
td.data = &p;
headerPut(sig, &td, HEADERPUT_DEFAULT);
td.tag = RPMSIGTAG_LONGSIZE;
td.data = &s;
headerPut(sig, &td, HEADERPUT_DEFAULT);
}
spaceSize = rpmExpandNumeric("%{__gpg_reserved_space}");
if(spaceSize > 0) {
reservedSpace = xcalloc(spaceSize, sizeof(char));
rpmtdReset(&td);
td.tag = RPMSIGTAG_RESERVEDSPACE;
td.count = spaceSize;
td.type = RPM_BIN_TYPE;
td.data = reservedSpace;
headerPut(sig, &td, HEADERPUT_DEFAULT);
free(reservedSpace);
}
/* Reallocate the signature into one contiguous region. */
sig = headerReload(sig, RPMTAG_HEADERSIGNATURES);
if (sig == NULL) { /* XXX can't happen */
rpmlog(RPMLOG_ERR, _("Unable to reload signature header.\n"));
rc = RPMRC_FAIL;
goto exit;
}
/* Write the signature section into the package. */
if (rpmWriteSignature(fd, sig)) {
rc = RPMRC_FAIL;
goto exit;
}
exit:
rpmFreeSignature(sig);
return rc;
}
static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
const char *fileName, char **cookie)
{
......@@ -436,9 +378,13 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
}
/* check if the package has a dependency with a '~' */
if (haveTildeDep(pkg->header))
if (haveTildeDep(pkg))
(void) rpmlibNeedsFeature(pkg, "TildeInVersions", "4.10.0-1");
/* check if the package has a rich dependency */
if (haveRichDep(pkg))
(void) rpmlibNeedsFeature(pkg, "RichDependencies", "4.12.0-1");
/* All dependencies added finally, write them into the header */
for (int i = 0; i < PACKAGE_NUM_DEPS; i++) {
/* Nuke any previously added dependencies from the header */
......@@ -456,6 +402,12 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
headerPutString(pkg->header, RPMTAG_COOKIE, *cookie);
}
/* Check for UTF-8 encoding of string tags, add encoding tag if all good */
if (checkForEncoding(pkg->header, 1)) {
rc = RPMRC_FAIL;
goto exit;
}
/* Reallocate the header into one contiguous region. */
pkg->header = headerReload(pkg->header, RPMTAG_HEADERIMMUTABLE);
if (pkg->header == NULL) {
......@@ -493,7 +445,7 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
sigStart = Ftell(fd);
/* Generate and write a placeholder signature header */
rc = generateSignature(zerosS, zeros, 0, estimatedCpioSize, fd);
rc = rpmGenerateSignature(zerosS, zeros, 0, estimatedCpioSize, fd);
if (rc != RPMRC_OK) {
rc = RPMRC_FAIL;
goto exit;
......@@ -549,7 +501,7 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
}
/* Generate the signature. Now with right values */
rc = generateSignature(SHA1, MD5, sigTargetSize, pkg->cpioArchiveSize, fd);
rc = rpmGenerateSignature(SHA1, MD5, sigTargetSize, pkg->cpioArchiveSize, fd);
if (rc != RPMRC_OK) {
rc = RPMRC_FAIL;
goto exit;
......
......@@ -308,7 +308,7 @@ static int addSource(rpmSpec spec, Package pkg, const char *field, rpmTagVal tag
addMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC);
free(buf);
#ifdef WITH_LUA
if (!spec->recursing) {
{
rpmlua lua = NULL; /* global state */
const char * what = (flag & RPMBUILD_ISPATCH) ? "patches" : "sources";
rpmluaPushTable(lua, what);
......@@ -428,6 +428,11 @@ static rpmRC checkForValidArchitectures(rpmSpec spec)
char *arch = rpmExpand("%{_target_cpu}", NULL);
char *os = rpmExpand("%{_target_os}", NULL);
rpmRC rc = RPMRC_FAIL; /* assume failure */
if (!strcmp(arch, "noarch")) {
free(arch);
arch = rpmExpand("%{_build_cpu}", NULL);
}
if (isMemberInEntry(spec->buildRestrictions,
arch, RPMTAG_EXCLUDEARCH) == 1) {
......@@ -600,34 +605,37 @@ if (multiToken) { \
/**
* Check for inappropriate characters. All alphanums are considered sane.
* @param spec spec
* @param spec spec (or NULL)
* @param field string to check
* @param fsize size of string to check
* @param whitelist string of permitted characters
* @return RPMRC_OK if OK
*/
rpmRC rpmCharCheck(rpmSpec spec, const char *field, size_t fsize, const char *whitelist)
rpmRC rpmCharCheck(rpmSpec spec, const char *field, const char *whitelist)
{
const char *ch, *stop = &field[fsize];
const char *ch;
char *err = NULL;
rpmRC rc = RPMRC_OK;
for (ch=field; *ch && ch < stop; ch++) {
for (ch=field; *ch; ch++) {
if (risalnum(*ch) || strchr(whitelist, *ch)) continue;
if (isprint(*ch)) {
rpmlog(RPMLOG_ERR, _("line %d: Illegal char '%c' in: %s\n"),
spec->lineNum, *ch, spec->line);
rasprintf(&err, _("Illegal char '%c' (0x%x)"),
isprint(*ch) ? *ch : '?', *ch);
}
if (err == NULL && strstr(field, "..") != NULL) {
rasprintf(&err, _("Illegal sequence \"..\""));
}
if (err) {
if (spec) {
rpmlog(RPMLOG_ERR, _("line %d: %s in: %s\n"),
spec->lineNum, err, spec->line);
} else {
rpmlog(RPMLOG_ERR, _("line %d: Illegal char in: %s\n"),
spec->lineNum, spec->line);
rpmlog(RPMLOG_ERR, _("%s in: %s\n"), err, field);
}
return RPMRC_FAIL;
free(err);
rc = RPMRC_FAIL;
}
if (strstr(field, "..") != NULL) {
rpmlog(RPMLOG_ERR, _("line %d: Illegal sequence \"..\" in: %s\n"),
spec->lineNum, spec->line);
return RPMRC_FAIL;
}
return RPMRC_OK;
return rc;
}
static int haveLangTag(Header h, rpmTagVal tag, const char *lang)
......@@ -731,7 +739,7 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
switch (tag) {
case RPMTAG_NAME:
SINGLE_TOKEN_ONLY;
if (rpmCharCheck(spec, field, strlen(field), WHITELIST_NAME))
if (rpmCharCheck(spec, field, WHITELIST_NAME))
goto exit;
headerPutString(pkg->header, tag, field);
/* Main pkg name is unknown at the start, populate as soon as we can */
......@@ -741,7 +749,7 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
case RPMTAG_VERSION:
case RPMTAG_RELEASE:
SINGLE_TOKEN_ONLY;
if (rpmCharCheck(spec, field, strlen(field), "._+%{}~"))
if (rpmCharCheck(spec, field, "._+%{}~"))
goto exit;
headerPutString(pkg->header, tag, field);
break;
......@@ -893,6 +901,9 @@ static rpmRC handlePreambleTag(rpmSpec spec, Package pkg, rpmTagVal tag,
spec->BANames = _free(spec->BANames);
break;
}
case RPMTAG_REMOVEPATHPOSTFIXES:
argvSplit(&pkg->removePostfixes, field, ":");
break;
default:
rpmlog(RPMLOG_ERR, _("Internal error: Bogus tag %d\n"), tag);
goto exit;
......@@ -933,7 +944,7 @@ static struct PreambleRec_s const preambleList[] = {
{RPMTAG_GROUP, 1, 0, LEN_AND_STR("group")},
{RPMTAG_PACKAGER, 0, 0, LEN_AND_STR("packager")},
{RPMTAG_URL, 0, 0, LEN_AND_STR("url")},
{RPMTAG_VCS, 0, 0, LEN_AND_STR("vcs")},
{RPMTAG_VCS, 0, 0, LEN_AND_STR("vcs")},
{RPMTAG_SOURCE, 0, 0, LEN_AND_STR("source")},
{RPMTAG_PATCH, 0, 0, LEN_AND_STR("patch")},
{RPMTAG_NOSOURCE, 0, 0, LEN_AND_STR("nosource")},
......@@ -967,6 +978,7 @@ static struct PreambleRec_s const preambleList[] = {
{RPMTAG_DISTTAG, 0, 0, LEN_AND_STR("disttag")},
{RPMTAG_BUGURL, 0, 0, LEN_AND_STR("bugurl")},
{RPMTAG_ORDERFLAGS, 2, 0, LEN_AND_STR("orderwithrequires")},
{RPMTAG_REMOVEPATHPOSTFIXES,0, 0, LEN_AND_STR("removepathpostfixes")},
{0, 0, 0, 0}
};
......@@ -1048,7 +1060,7 @@ int parsePreamble(rpmSpec spec, int initialPackage)
goto exit;
}
if (rpmCharCheck(spec, name, strlen(name), WHITELIST_NAME))
if (rpmCharCheck(spec, name, WHITELIST_NAME))
goto exit;
if (!lookupPackage(spec, name, flag, NULL)) {
......
......@@ -29,10 +29,6 @@ static rpmRC checkOwners(const char * urlfn)
urlfn, strerror(errno));
return RPMRC_FAIL;
}
if (!rpmugUname(sb.st_uid) || !rpmugGname(sb.st_gid)) {
rpmlog(RPMLOG_ERR, _("Bad owner/group: %s\n"), urlfn);
return RPMRC_FAIL;
}
return RPMRC_OK;
}
......@@ -62,6 +58,7 @@ static char *doPatch(rpmSpec spec, uint32_t c, int strip, const char *db,
char *arg_patch_flags = rpmExpand("%{?_default_patch_flags}", NULL);
struct Source *sp;
char *patchcmd;
rpmCompressedMagic compressed = COMPRESSED_NOT;
for (sp = spec->sources; sp != NULL; sp = sp->next) {
if ((sp->flags & RPMBUILD_ISPATCH) && (sp->num == c)) {
......@@ -80,7 +77,7 @@ static char *doPatch(rpmSpec spec, uint32_t c, int strip, const char *db,
fn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
/* On non-build parse's, file cannot be stat'd or read. */
if ((spec->flags & RPMSPEC_FORCE) || checkOwners(fn)) goto exit;
if ((spec->flags & RPMSPEC_FORCE) || rpmFileIsCompressed(fn, &compressed) || checkOwners(fn)) goto exit;