summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2018-03-01 11:54:24 +0100
committerFabian Groffen <grobian@gentoo.org>2018-03-01 11:54:24 +0100
commitc7d6ecd8600f5a69f95427176e2f23a0b84e7e75 (patch)
tree1d6c631303d8067ffa38ec2359d994f149898ef9
parentscripts/rsync-generation/update-rsync-master: ensure mtime always moves forwards (diff)
downloadprefix-c7d6ecd8600f5a69f95427176e2f23a0b84e7e75.zip
prefix-c7d6ecd8600f5a69f95427176e2f23a0b84e7e75.tar.gz
prefix-c7d6ecd8600f5a69f95427176e2f23a0b84e7e75.tar.bz2
scripts/rsync-generation/hashgen: return when write_hashes would produce garbage
If we can't stat the file we're writing hashes for, we're not going to produce anything useful and something up in the stack went wrong already.
-rw-r--r--scripts/rsync-generation/hashgen.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/rsync-generation/hashgen.c b/scripts/rsync-generation/hashgen.c
index 833c8e7..534d278 100644
--- a/scripts/rsync-generation/hashgen.c
+++ b/scripts/rsync-generation/hashgen.c
@@ -224,8 +224,10 @@ write_hashes(
snprintf(fname, sizeof(fname), "%s/%s", root, name);
- if (stat(fname, &s) == 0)
- update_times(tv, &s);
+ if (stat(fname, &s) != 0)
+ return;
+
+ update_times(tv, &s);
get_hashes(fname, sha256, sha512, whrlpl, blak2b, &flen);
@@ -1275,6 +1277,7 @@ process_dir_vrfy(const char *dir)
{
char buf[8192];
int newhashes;
+ char *ret = NULL;
fprintf(stdout, "verifying %s...\n", dir);
snprintf(buf, sizeof(buf), "%s/metadata/layout.conf", dir);
@@ -1290,7 +1293,7 @@ process_dir_vrfy(const char *dir)
}
if (verify_gpg_sig(str_manifest) != 0)
- return "gpg signature invalid";
+ ret = "gpg signature invalid";
/* verification goes like this:
* - verify the signature of the top-level Manifest file (done
@@ -1301,9 +1304,9 @@ process_dir_vrfy(const char *dir)
* - recurse into directories for which Manifest files are defined
*/
if (verify_manifest(".\0", str_manifest) != 0)
- return "manifest verification failed";
+ ret = "manifest verification failed";
- return NULL;
+ return ret;
}
int
@@ -1339,14 +1342,14 @@ main(int argc, char *argv[])
if (argc > 1) {
for (; arg < argc; arg++) {
rsn = runfunc(argv[arg]);
- if (rsn != NULL) {
+ if (runfunc == &process_dir_vrfy && rsn != NULL) {
printf("%s\n", rsn);
ret |= 1;
}
}
} else {
rsn = runfunc(".");
- if (rsn != NULL) {
+ if (runfunc == &process_dir_vrfy && rsn != NULL) {
printf("%s\n", rsn);
ret |= 1;
}