|
|
2f13d7 |
From a2c959085250d186c54130b78af076095c3d3cd3 Mon Sep 17 00:00:00 2001
|
|
|
2f13d7 |
From: chantra <chantr4@gmail.com>
|
|
|
2f13d7 |
Date: Tue, 15 Feb 2022 09:11:33 -0800
|
|
|
2f13d7 |
Subject: [PATCH 23/30] [rpm2extents] Improve logging
|
|
|
2f13d7 |
|
|
|
2f13d7 |
```
|
|
|
2f13d7 |
$ ls -l tests/data/RPMS/hello-2.0-1.x86_64.rpm
|
|
|
2f13d7 |
-rw-r--r--. 1 chantra chantra 9915 Jan 19 09:10 tests/data/RPMS/hello-2.0-1.x86_64.rpm
|
|
|
2f13d7 |
$ cp tests/data/RPMS/hello-2.0-1.x86_64.rpm ~/trunc-hello-2.0-1.x86_64.rpm
|
|
|
2f13d7 |
$ truncate -s 9000 ~/trunc-hello-2.0-1.x86_64.rpm
|
|
|
2f13d7 |
$ ls -l ~/trunc-hello-2.0-1.x86_64.rpm
|
|
|
2f13d7 |
-rw-r--r--. 1 chantra chantra 9000 Feb 15 09:13 /home/chantra/trunc-hello-2.0-1.x86_64.rpm
|
|
|
2f13d7 |
$ cat ~/trunc-hello-2.0-1.x86_64.rpm| ./rpm2extents SHA256 > /dev/null
|
|
|
2f13d7 |
error: rpmfiArchiveReadToFile failed while extracting "/usr/bin/hello" with RC -32784: cpio: read failed - Illegal seek
|
|
|
2f13d7 |
error: Package processor failed: -32784
|
|
|
2f13d7 |
error: Unable to write input length 9000: 32, Broken pipe
|
|
|
2f13d7 |
error: Failed to write digests: 32, Broken pipe
|
|
|
2f13d7 |
error: Validator failed with RC 2
|
|
|
2f13d7 |
```
|
|
|
2f13d7 |
Before:
|
|
|
2f13d7 |
```
|
|
|
2f13d7 |
$ cat ~/trunc-hello-2.0-1.x86_64.rpm| ./rpm2extents SHA256 > /dev/null
|
|
|
2f13d7 |
rpmfiArchiveReadToFile failed with -32784
|
|
|
2f13d7 |
Validator failed
|
|
|
2f13d7 |
Unable to write input length 9000
|
|
|
2f13d7 |
Failed to write digestsValidator failed
|
|
|
2f13d7 |
```
|
|
|
2f13d7 |
---
|
|
|
2f13d7 |
rpm2extents.c | 120 ++++++++++++++++++++++++++++++--------------------
|
|
|
2f13d7 |
1 file changed, 72 insertions(+), 48 deletions(-)
|
|
|
2f13d7 |
|
|
|
2f13d7 |
diff --git a/rpm2extents.c b/rpm2extents.c
|
|
|
2f13d7 |
index a326e3857..e1a19fedb 100644
|
|
|
2f13d7 |
--- a/rpm2extents.c
|
|
|
2f13d7 |
+++ b/rpm2extents.c
|
|
|
2f13d7 |
@@ -84,13 +84,15 @@ static int FDWriteDigests(
|
|
|
2f13d7 |
|
|
|
2f13d7 |
len = sizeof(fdilength);
|
|
|
2f13d7 |
if (Fwrite(&fdilength, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write input length %zd\n"), fdilength);
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write input length %zd: %d, %s\n"),
|
|
|
2f13d7 |
+ fdilength, errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
len = sizeof(algos_len);
|
|
|
2f13d7 |
if (Fwrite(&algos_len, len, 1, fdo) != len) {
|
|
|
2f13d7 |
algo_digest_len = (uint32_t)filedigest_len;
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write number of digests\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write number of digests: %d, %s\n"),
|
|
|
2f13d7 |
+ errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
for (algo = 0; algo < algos_len; algo++) {
|
|
|
2f13d7 |
@@ -102,24 +104,28 @@ static int FDWriteDigests(
|
|
|
2f13d7 |
|
|
|
2f13d7 |
len = sizeof(algo_name_len);
|
|
|
2f13d7 |
if (Fwrite(&algo_name_len, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr,
|
|
|
2f13d7 |
- _("Unable to write digest algo name length\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Unable to write digest algo name length: %d, %s\n"),
|
|
|
2f13d7 |
+ errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
len = sizeof(algo_digest_len);
|
|
|
2f13d7 |
if (Fwrite(&algo_digest_len, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr,
|
|
|
2f13d7 |
- _("Unable to write number of bytes for digest\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Unable to write number of bytes for digest: %d, %s\n"),
|
|
|
2f13d7 |
+ errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
if (Fwrite(algo_name, algo_name_len, 1, fdo) != algo_name_len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write digest algo name\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write digest algo name: %d, %s\n"),
|
|
|
2f13d7 |
+ errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
if (Fwrite(filedigest, algo_digest_len, 1, fdo ) != algo_digest_len) {
|
|
|
2f13d7 |
- fprintf(stderr,
|
|
|
2f13d7 |
- _("Unable to write digest value %u, %zu\n"),
|
|
|
2f13d7 |
- algo_digest_len, filedigest_len);
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Unable to write digest value %u, %zu: %d, %s\n"),
|
|
|
2f13d7 |
+ algo_digest_len, filedigest_len,
|
|
|
2f13d7 |
+ errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -133,22 +139,29 @@ static rpmRC FDWriteSignaturesValidation(FD_t fdo, int rpmvsrc, char *msg) {
|
|
|
2f13d7 |
rpmRC rc = RPMRC_FAIL;
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if(rpmvsrc){
|
|
|
2f13d7 |
- fprintf(stderr, _("Error verifying package signatures\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_WARNING,
|
|
|
2f13d7 |
+ _("Error verifying package signatures:\n%s\n"), msg);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
len = sizeof(rpmvsrc);
|
|
|
2f13d7 |
if (Fwrite(&rpmvsrc, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write signature verification RC code %d\n"), rpmvsrc);
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Unable to write signature verification RC code %d: %d, %s\n"),
|
|
|
2f13d7 |
+ rpmvsrc, errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
size_t content_len = msg ? strlen(msg) : 0;
|
|
|
2f13d7 |
len = sizeof(content_len);
|
|
|
2f13d7 |
if (Fwrite(&content_len, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write signature verification output length %zd\n"), content_len);
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Unable to write signature verification output length %zd: %d, %s\n"),
|
|
|
2f13d7 |
+ content_len, errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
if (Fwrite(msg, content_len, 1, fdo) != content_len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write signature verification output %s\n"), msg);
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Unable to write signature verification output %s: %d, %s\n"),
|
|
|
2f13d7 |
+ msg, errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
@@ -174,12 +187,16 @@ static rpmRC validator(FD_t fdi, FD_t digesto, FD_t sigo,
|
|
|
2f13d7 |
|
|
|
2f13d7 |
// Write result of digest computation
|
|
|
2f13d7 |
if(FDWriteDigests(fdi, digesto, algos, algos_len) != RPMRC_OK) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Failed to write digests"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Failed to write digests: %d, %s\n"),
|
|
|
2f13d7 |
+ errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
// Write result of signature validation.
|
|
|
2f13d7 |
if(FDWriteSignaturesValidation(sigo, rpmvsrc, msg)) {
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Failed to write signature verification result: %d, %s\n"),
|
|
|
2f13d7 |
+ errno, strerror(errno));
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
rc = RPMRC_OK;
|
|
|
2f13d7 |
@@ -226,24 +243,24 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
fdo = fdDup(STDOUT_FILENO);
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (rpmReadPackageRaw(fdi, &sigh, &h)) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Error reading package\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Error reading package\n"));
|
|
|
2f13d7 |
exit(EXIT_FAILURE);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (rpmLeadWrite(fdo, h))
|
|
|
2f13d7 |
{
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write package lead: %s\n"),
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write package lead: %s\n"),
|
|
|
2f13d7 |
Fstrerror(fdo));
|
|
|
2f13d7 |
exit(EXIT_FAILURE);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (rpmWriteSignature(fdo, sigh)) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write signature: %s\n"), Fstrerror(fdo));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write signature: %s\n"), Fstrerror(fdo));
|
|
|
2f13d7 |
exit(EXIT_FAILURE);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (headerWrite(fdo, h, HEADER_MAGIC_YES)) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write headers: %s\n"), Fstrerror(fdo));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write headers: %s\n"), Fstrerror(fdo));
|
|
|
2f13d7 |
exit(EXIT_FAILURE);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
@@ -257,7 +274,7 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
free(rpmio_flags);
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (gzdi == NULL) {
|
|
|
2f13d7 |
- fprintf(stderr, _("cannot re-open payload: %s\n"), Fstrerror(gzdi));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("cannot re-open payload: %s\n"), Fstrerror(gzdi));
|
|
|
2f13d7 |
exit(EXIT_FAILURE);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
@@ -300,7 +317,7 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
pad = pad_to(pos, fundamental_block_size);
|
|
|
2f13d7 |
if (Fwrite(zeros, sizeof(char), pad, fdo) != pad) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write padding\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write padding\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -313,7 +330,12 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
size = rpmfiFSize(fi);
|
|
|
2f13d7 |
rc = rpmfiArchiveReadToFile(fi, fdo, 0);
|
|
|
2f13d7 |
if (rc != RPMRC_OK) {
|
|
|
2f13d7 |
- fprintf(stderr, _("rpmfiArchiveReadToFile failed with %d\n"), rc);
|
|
|
2f13d7 |
+ char *errstr = rpmfileStrerror(rc);
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("rpmfiArchiveReadToFile failed while extracting "\
|
|
|
2f13d7 |
+ "\"%s\" with RC %d: %s\n"),
|
|
|
2f13d7 |
+ rpmfiFN(fi), rc, errstr);
|
|
|
2f13d7 |
+ free(errstr);
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
pos += size;
|
|
|
2f13d7 |
@@ -326,7 +348,7 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
validation_pos = pos;
|
|
|
2f13d7 |
ssize_t validation_len = ufdCopy(validationi, fdo);
|
|
|
2f13d7 |
if (validation_len == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("validation output ufdCopy failed\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("validation output ufdCopy failed\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -335,25 +357,25 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
|
|
|
2f13d7 |
len = sizeof(offset_ix);
|
|
|
2f13d7 |
if (Fwrite(&offset_ix, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write length of table\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write length of table\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
len = sizeof(diglen);
|
|
|
2f13d7 |
if (Fwrite(&diglen, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write length of digest\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write length of digest\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
len = sizeof(rpm_loff_t);
|
|
|
2f13d7 |
for (int x = 0; x < offset_ix; x++) {
|
|
|
2f13d7 |
if (Fwrite(offsets[x].digest, diglen, 1, fdo) != diglen) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write digest\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write digest\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
if (Fwrite(&offsets[x].pos, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write offset\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write offset\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -365,7 +387,7 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
|
|
|
2f13d7 |
ssize_t digest_len = ufdCopy(digestori, fdo);
|
|
|
2f13d7 |
if (digest_len == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("digest table ufdCopy failed\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("digest table ufdCopy failed\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -378,30 +400,30 @@ static rpmRC process_package(FD_t fdi, FD_t digestori, FD_t validationi)
|
|
|
2f13d7 |
pad = pad_to((validation_pos + validation_len + 2 * sizeof(rpm_loff_t) +
|
|
|
2f13d7 |
sizeof(uint64_t)), fundamental_block_size);
|
|
|
2f13d7 |
if (Fwrite(zeros, sizeof(char), pad, fdo) != pad) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write final padding\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write final padding\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
zeros = _free(zeros);
|
|
|
2f13d7 |
if (Fwrite(&validation_pos, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write offset of validation output\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write offset of validation output\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
if (Fwrite(&digest_table_pos, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write offset of digest table\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write offset of digest table\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
if (Fwrite(&digest_pos, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write offset of validation table\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write offset of validation table\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
extents_magic_t magic = EXTENTS_MAGIC;
|
|
|
2f13d7 |
len = sizeof(magic);
|
|
|
2f13d7 |
if (Fwrite(&magic, len, 1, fdo) != len) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Unable to write magic\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Unable to write magic\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
goto exit;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -426,7 +448,9 @@ static off_t ufdTee(FD_t sfd, FD_t *fds, int len)
|
|
|
2f13d7 |
for(int i=0; i < len; i++) {
|
|
|
2f13d7 |
wrbytes = Fwrite(buf, sizeof(buf[0]), rdbytes, fds[i]);
|
|
|
2f13d7 |
if (wrbytes != rdbytes) {
|
|
|
2f13d7 |
- fprintf(stderr, "Error wriing to FD %d: %s\n", i, Fstrerror(fds[i]));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Error wriing to FD %d: %s\n"),
|
|
|
2f13d7 |
+ i, Fstrerror(fds[i]));
|
|
|
2f13d7 |
total = -1;
|
|
|
2f13d7 |
break;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -460,22 +484,22 @@ static rpmRC teeRpm(FD_t fdi, uint8_t algos[], uint32_t algos_len) {
|
|
|
2f13d7 |
FD_t fds[2];
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (pipe(processorpipefd) == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Processor pipe failure\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Processor pipe failure\n"));
|
|
|
2f13d7 |
return RPMRC_FAIL;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (pipe(validatorpipefd) == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Validator pipe failure\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Validator pipe failure\n"));
|
|
|
2f13d7 |
return RPMRC_FAIL;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (pipe(meta_digestpipefd) == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Meta digest pipe failure\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Meta digest pipe failure\n"));
|
|
|
2f13d7 |
return RPMRC_FAIL;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (pipe(meta_rpmsignpipefd) == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Meta rpm signature pipe failure\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Meta rpm signature pipe failure\n"));
|
|
|
2f13d7 |
return RPMRC_FAIL;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
|
|
|
2f13d7 |
@@ -494,7 +518,7 @@ static rpmRC teeRpm(FD_t fdi, uint8_t algos[], uint32_t algos_len) {
|
|
|
2f13d7 |
close(meta_rpmsignpipefd[1]);
|
|
|
2f13d7 |
rc = validator(fdi, digesto, sigo, algos, algos_len);
|
|
|
2f13d7 |
if(rc != RPMRC_OK) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Validator failed\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Validator failed with RC %d\n"), rc);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
Fclose(fdi);
|
|
|
2f13d7 |
Fclose(digesto);
|
|
|
2f13d7 |
@@ -522,7 +546,7 @@ static rpmRC teeRpm(FD_t fdi, uint8_t algos[], uint32_t algos_len) {
|
|
|
2f13d7 |
|
|
|
2f13d7 |
rc = process_package(fdi, digestori, sigi);
|
|
|
2f13d7 |
if(rc != RPMRC_OK) {
|
|
|
2f13d7 |
- fprintf(stderr, _("Validator failed\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Package processor failed: %d\n"), rc);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
Fclose(digestori);
|
|
|
2f13d7 |
Fclose(sigi);
|
|
|
2f13d7 |
@@ -552,19 +576,19 @@ static rpmRC teeRpm(FD_t fdi, uint8_t algos[], uint32_t algos_len) {
|
|
|
2f13d7 |
rc = RPMRC_OK;
|
|
|
2f13d7 |
offt = ufdTee(fdi, fds, 2);
|
|
|
2f13d7 |
if(offt == -1){
|
|
|
2f13d7 |
- fprintf(stderr, _("Failed to tee RPM\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("Failed to tee RPM\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
Fclose(fds[0]);
|
|
|
2f13d7 |
Fclose(fds[1]);
|
|
|
2f13d7 |
w = waitpid(cpids[0], &wstatus, 0);
|
|
|
2f13d7 |
if (w == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("waitpid cpids[0] failed\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("waitpid cpids[0] failed\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
w = waitpid(cpids[1], &wstatus, 0);
|
|
|
2f13d7 |
if (w == -1) {
|
|
|
2f13d7 |
- fprintf(stderr, _("waitpid cpids[1] failed\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR, _("waitpid cpids[1] failed\n"));
|
|
|
2f13d7 |
rc = RPMRC_FAIL;
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -585,8 +609,8 @@ int main(int argc, char *argv[]) {
|
|
|
2f13d7 |
poptSetOtherOptionHelp(optCon, "[OPTIONS]* <DIGESTALGO>");
|
|
|
2f13d7 |
|
|
|
2f13d7 |
if (poptPeekArg(optCon) == NULL) {
|
|
|
2f13d7 |
- fprintf(stderr,
|
|
|
2f13d7 |
- _("Need at least one DIGESTALGO parameter, e.g. 'SHA256'\n"));
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Need at least one DIGESTALGO parameter, e.g. 'SHA256'\n"));
|
|
|
2f13d7 |
poptPrintUsage(optCon, stderr, 0);
|
|
|
2f13d7 |
exit(EXIT_FAILURE);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
@@ -598,9 +622,9 @@ int main(int argc, char *argv[]) {
|
|
|
2f13d7 |
for (int x = 0; x < nb_algos; x++) {
|
|
|
2f13d7 |
if (pgpStringVal(PGPVAL_HASHALGO, args[x], &algos[x]) != 0)
|
|
|
2f13d7 |
{
|
|
|
2f13d7 |
- fprintf(stderr,
|
|
|
2f13d7 |
- _("Unable to resolve '%s' as a digest algorithm, exiting\n"),
|
|
|
2f13d7 |
- args[x]);
|
|
|
2f13d7 |
+ rpmlog(RPMLOG_ERR,
|
|
|
2f13d7 |
+ _("Unable to resolve '%s' as a digest algorithm, exiting\n"),
|
|
|
2f13d7 |
+ args[x]);
|
|
|
2f13d7 |
exit(EXIT_FAILURE);
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
}
|
|
|
2f13d7 |
--
|
|
|
2f13d7 |
2.35.1
|
|
|
2f13d7 |
|