From 05a19cc6f2a278228e0d433d4826cba1da805e12 Mon Sep 17 00:00:00 2001 From: job Date: Thu, 19 Dec 2024 13:23:38 +0000 Subject: [PATCH] Improve cleanup process In some cases, following a fallback from RRDP to RSYNC, files are moved to the wrong place. With this change, only rsync repositories are considered when looking up where to move DIR_TEMP files. repo.c requires more study, this fix might be a bandaid for a problem not fully understood. "put it in" claudio@ OK tb@ --- usr.sbin/rpki-client/repo.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index 4c5e6ee6e1d..a88ab01b14e 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.70 2024/11/13 12:51:04 tb Exp $ */ +/* $OpenBSD: repo.c,v 1.71 2024/12/19 13:23:38 job Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -1264,6 +1264,20 @@ repo_byid(unsigned int id) return NULL; } +static struct repo * +repo_rsync_bypath(const char *path) +{ + struct repo *rp; + + SLIST_FOREACH(rp, &repos, entry) { + if (rp->rsync == NULL) + continue; + if (strcmp(rp->basedir, path) == 0) + return rp; + } + return NULL; +} + /* * Find repository by base path. */ @@ -1892,7 +1906,8 @@ repo_cleanup_entry(FTSENT *e, struct filepath_tree *tree, int cachefd) } if (e->fts_level == 3 && fts_state.type == RSYNC_DIR) { /* .rsync/rpki.example.org/repository */ - fts_state.rp = repo_bypath(path + strlen(".rsync/")); + fts_state.rp = repo_rsync_bypath(path + + strlen(".rsync/")); } break; case FTS_DP: