Commit 6f135bbd authored by Bernhard Link's avatar Bernhard Link

allow .asc signatures in source packages

parent 7936450a
......@@ -201,6 +201,7 @@ retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_t
} else {
enum compression c;
const char *eoi;
bool issignature = false;
/* without those, it gets more complicated.
* It's not .deb or .udeb, so most likely a
......@@ -209,6 +210,10 @@ retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_t
/* if it uses a known compression, things are easy,
* so try this first: */
if (l > 4 && memcmp(versionstart + l - 4, ".asc", 4) == 0 ) {
issignature = true;
l -= 4;
}
c = compression_by_suffix(versionstart, &l);
p = versionstart + l;
......@@ -220,6 +225,9 @@ retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_t
} else if (l > 4 && strncmp(p-4, ".tar", 4) == 0) {
type = fe_TAR;
eoi = p - 4;
} else if (issignature) {
/* only .tar.* files are allowed to have .asc files: */
issignature = false;
} else if (l > 5 && strncmp(p-5, ".diff", 5) == 0) {
type = fe_DIFF;
eoi = p - 5;
......@@ -275,6 +283,8 @@ retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_t
return RET_ERROR;
}
if (issignature)
type = fe_SIG;
} else {
/* everything else is assumed to be source */
checkfilename = true;
......
......@@ -9,6 +9,7 @@ typedef enum {
fe_UNKNOWN=0,
fe_DEB, fe_UDEB,
fe_DSC, fe_DIFF, fe_ORIG, fe_TAR,
fe_SIG,
fe_ALTSRC,
fe_BYHAND, fe_LOG, fe_CHANGES,
fe_BUILDINFO
......@@ -16,7 +17,7 @@ typedef enum {
#define FE_PACKAGE(ft) ((ft) == fe_DEB || (ft) == fe_UDEB || (ft) == fe_DSC)
#define FE_BINARY(ft) ((ft) == fe_DEB || (ft) == fe_UDEB)
#define FE_SOURCE(ft) ((ft) == fe_DIFF || (ft) == fe_ORIG || (ft) == fe_TAR || (ft) == fe_DSC || (ft) == fe_UNKNOWN || (ft) == fe_ALTSRC)
#define FE_SOURCE(ft) ((ft) == fe_DIFF || (ft) == fe_ORIG || (ft) == fe_TAR || (ft) == fe_DSC || (ft) == fe_UNKNOWN || (ft) == fe_ALTSRC || (ft) == fe_SIG)
struct hash_data;
retvalue changes_parsefileline(const char * /*fileline*/, /*@out@*/filetype *, /*@out@*/char ** /*result_basename*/, /*@out@*/struct hash_data *, /*@out@*/struct hash_data *, /*@out@*/char ** /*result_section*/, /*@out@*/char ** /*result_priority*/, /*@out@*/architecture_t *, /*@out@*/char ** /*result_name*/);
......
......@@ -883,7 +883,6 @@ static retvalue changes_check(const struct distribution *distribution, const cha
havealtsrc = true;
}
}
if (havetar && !haveorig && havediff) {
fprintf(stderr,
"I don't know what to do having a .tar.gz not being a .orig.tar.gz and a .diff.gz in '%s'!\n",
......@@ -905,6 +904,36 @@ static retvalue changes_check(const struct distribution *distribution, const cha
return RET_ERROR;
}
/* check if signatures match files signed: */
for (e = changes->files ; e != NULL ; e = e->next) {
size_t el;
struct fileentry *f;
if (e->type != fe_SIG)
continue;
el = strlen(e->basename);
if (el <= 4 || memcmp(e->basename + el - 4, ".asc", 4) != 0)
continue;
for (f = changes->files ; f != NULL ; f = f->next) {
size_t fl = strlen(f->basename);
if (el != fl + 4)
continue;
if (memcmp(e->basename, f->basename, fl) != 0)
continue;
break;
}
if (f == NULL) {
fprintf(stderr,
"Signature file without file to be signed: '%s'!\n",
e->basename);
return RET_ERROR;
}
}
return r;
}
......
......@@ -1443,6 +1443,35 @@ static retvalue prepare_dsc(const struct incoming *i, const struct candidate *c,
r = properfilenames(&file->dsc.files.names);
if (RET_WAS_ERROR(r))
return r;
/* check if signatures match files signed: */
for (j = 0 ; j < file->dsc.files.names.count ; j++) {
int jj;
const char *afn = file->dsc.files.names.values[j];
size_t al = strlen(afn);
bool found = false;
if (al <= 4 || memcmp(afn + al - 4, ".asc", 4) != 0)
continue;
for (jj = 0 ; jj < file->dsc.files.names.count ; jj++) {
const char *fn = file->dsc.files.names.values[jj];
size_t l = strlen(fn);
if (l + 4 != al)
continue;
if (memcmp(afn, fn, l) != 0)
continue;
found = true;
break;
}
if (!found) {
fprintf(stderr,
"Signature file without file to be signed: '%s'!\n", afn);
return RET_ERROR;
}
}
oinfo = override_search(into->overrides.dsc, file->dsc.name);
r = getsectionprioritycomponent(i, c, into, file,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment