From 6e120aea60415804309a2f2b635312bb96f3212e Mon Sep 17 00:00:00 2001 From: job Date: Fri, 2 Sep 2022 15:09:19 +0000 Subject: [PATCH] Move mkpath logic after checking for 'noop' to prevent creation of directories in -n mode OK claudio@ --- usr.sbin/rpki-client/repo.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index 80d4dccb8e6..69cf849b245 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.36 2022/08/30 12:45:13 claudio Exp $ */ +/* $OpenBSD: repo.c,v 1.37 2022/09/02 15:09:19 job Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -1016,10 +1016,6 @@ ta_lookup(int id, struct tal *tal) if ((rp->repouri = strdup(tal->descr)) == NULL) err(1, NULL); - /* try to create base directory */ - if (mkpath(rp->basedir) == -1) - warn("mkpath %s", rp->basedir); - /* check if sync disabled ... */ if (noop) { logx("ta/%s: using cache", rp->repouri); @@ -1027,6 +1023,10 @@ ta_lookup(int id, struct tal *tal) return rp; } + /* try to create base directory */ + if (mkpath(rp->basedir) == -1) + warn("mkpath %s", rp->basedir); + rp->ta = ta_get(tal); /* need to check if it was already loaded */ @@ -1078,10 +1078,6 @@ repo_lookup(int talid, const char *uri, const char *notify) nofetch = 1; } - /* try to create base directory */ - if (mkpath(rp->basedir) == -1) - warn("mkpath %s", rp->basedir); - /* check if sync disabled ... */ if (noop || nofetch) { logx("%s: using cache", rp->basedir); @@ -1089,6 +1085,10 @@ repo_lookup(int talid, const char *uri, const char *notify) return rp; } + /* try to create base directory */ + if (mkpath(rp->basedir) == -1) + warn("mkpath %s", rp->basedir); + /* ... else try RRDP first if available then rsync */ if (notify != NULL) rp->rrdp = rrdp_get(notify); -- 2.20.1