#include "files.h"
#include "reqprov.h"
-static int writeMagic(int fd, char *name, unsigned short type,
- unsigned short sigtype);
+static int writeMagic(int fd, char *name, unsigned short type);
static int cpio_gzip(int fd, char *tempdir, char *writePtr, int *archiveSize);
static int generateRPM(char *name, /* name-version-release */
char *filename, /* output filename */
char *fileList, /* list of files for cpio */
char *passPhrase)
{
- unsigned short sigtype;
+ int_32 sigtype;
char *sigtarget, *archiveTemp;
int fd, ifd, count, archiveSize;
unsigned char buffer[8192];
-
- /* Figure out the signature type */
- if ((sigtype = sigLookupType()) == RPMSIG_BAD) {
- error(RPMERR_BADSIGTYPE, "Bad signature type in rpmrc");
- return RPMERR_BADSIGTYPE;
- }
+ Header sig;
/* Write the archive to a temp file so we can get the size */
archiveTemp = tempnam("/var/tmp", "rpmbuild");
unlink(archiveTemp);
return 1;
}
- writeHeader(fd, header);
+ writeHeader(fd, header, HEADER_MAGIC);
ifd = open(archiveTemp, O_RDONLY, 0644);
while ((count = read(ifd, buffer, sizeof(buffer))) > 0) {
if (count == -1) {
unlink(filename);
return 1;
}
- if (writeMagic(fd, name, type, sigtype)) {
+ if (writeMagic(fd, name, type)) {
close(fd);
unlink(sigtarget);
unlink(filename);
}
/* Generate the signature */
+ sigtype = sigLookupType();
message(MESS_VERBOSE, "Generating signature: %d\n", sigtype);
fflush(stdout);
- if (makeSignature(sigtarget, sigtype, fd, passPhrase)) {
+ sig = newSignature();
+ addSignature(sig, sigtarget, SIGTAG_SIZE, passPhrase);
+ addSignature(sig, sigtarget, SIGTAG_MD5, passPhrase);
+ if (sigtype>0) {
+ addSignature(sig, sigtarget, sigtype, passPhrase);
+ }
+ if (writeSignature(fd, sig)) {
close(fd);
unlink(sigtarget);
unlink(filename);
+ freeSignature(sig);
return 1;
}
+ freeSignature(sig);
/* Append the header and archive */
ifd = open(sigtarget, O_RDONLY);
}
static int writeMagic(int fd, char *name,
- unsigned short type,
- unsigned short sigtype)
+ unsigned short type)
{
struct rpmlead lead;
lead.type = type;
lead.archnum = getArchNum();
lead.osnum = getOsNum();
- lead.signature_type = sigtype;
+ lead.signature_type = RPMSIG_HEADERSIG; /* New-style signature */
strncpy(lead.name, name, sizeof(lead.name));
writeLead(fd, &lead);
if (signIt) {
if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD ||
bigMode == MODE_RESIGN) {
- if ((optind != argc) && (sigLookupType() == RPMSIG_MD5_PGP)) {
- if (!(passPhrase = getPassPhrase("Enter pass phrase: "))) {
- fprintf(stderr, _("Pass phrase check failed\n"));
+ if (optind != argc) {
+ switch (sigLookupType()) {
+ case SIGTAG_PGP:
+ if (!(passPhrase = getPassPhrase("Enter pass phrase: "))) {
+ fprintf(stderr, _("Pass phrase check failed\n"));
+ exit(1);
+ } else {
+ fprintf(stderr, _("Pass phrase is good.\n"));
+ passPhrase = strdup(passPhrase);
+ }
+ break;
+ case 0:
+ break;
+ default:
+ fprintf(stderr, "Invalid signature spec in rc file\n");
exit(1);
- } else {
- fprintf(stderr, _("Pass phrase is good.\n"));
- passPhrase = strdup(passPhrase);
}
}
} else {