From: claudio Date: Thu, 25 May 2023 12:49:39 +0000 (+0000) Subject: Fix repo_cleanup_entry() state machine so that the repository lookups X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=71f6c49a06c1ab99184d1bf697ce537a68014d68;p=openbsd Fix repo_cleanup_entry() state machine so that the repository lookups are done when the full repo path is available. Without this all repo lookups returned NULL and the code did not work as intended. OK tb@ --- diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index dd7b4815e91..ee79b1e3195 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.45 2023/05/16 17:01:31 claudio Exp $ */ +/* $OpenBSD: repo.c,v 1.46 2023/05/25 12:49:39 claudio Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -1640,7 +1640,7 @@ repo_cleanup_entry(FTSENT *e, struct filepath_tree *tree, int cachefd) } else if (fts_state.type == RSYNC_DIR) { /* no need to keep rsync files */ if (verbose > 1) - logx("superfluous %s", path); + logx("deleted superfluous %s", path); if (fts_state.rp != NULL) fts_state.rp->repostats.del_extra_files++; else @@ -1659,28 +1659,32 @@ repo_cleanup_entry(FTSENT *e, struct filepath_tree *tree, int cachefd) if (e->fts_level == FTS_ROOTLEVEL) fts_state.type = BASE_DIR; if (e->fts_level == 1) { + /* rpki.example.org or .rrdp / .rsync */ if (strcmp(".rsync", e->fts_name) == 0) { fts_state.type = RSYNC_DIR; fts_state.rp = NULL; } else if (strcmp(".rrdp", e->fts_name) == 0) { fts_state.type = RRDP_DIR; fts_state.rp = NULL; - } else { - fts_state.type = BASE_DIR; - fts_state.rp = repo_bypath(path); } } if (e->fts_level == 2) { - if (fts_state.type == RSYNC_DIR) + /* rpki.example.org/repository or .rrdp/hashdir */ + if (fts_state.type == BASE_DIR) fts_state.rp = repo_bypath(path); /* * special handling for rrdp directories, * clear them if they are not used anymore but * only if rrdp is active. + * Look them up just using the hash. */ if (fts_state.type == RRDP_DIR) fts_state.rp = repo_rrdp_bypath(path); } + if (e->fts_level == 3 && fts_state.type == RSYNC_DIR) { + /* .rsync/rpki.example.org/repository */ + fts_state.rp = repo_bypath(path + strlen(".rsync/")); + } break; case FTS_DP: if (e->fts_level == FTS_ROOTLEVEL)