From aa20f29b3634c00b91abcc2e5d5325d9220a36ea Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 9 May 2024 18:23:20 +0200 Subject: [PATCH] confd: fix missing /etc/resolv.conf after 'no system' When a CLI user performs the following command, the DNS resolver was left in an undefined state. admin@infix-00-00-00:/config/> no system admin@infix-00-00-00:/config/> leave admin@infix:/> The avahi-daemon reported the missing /etc/resolv.conf and the fix is to ensure `resolvconf -u` runs on every major change ot ietf-system, even if there is no new resolv.conf to roll in. At bootstrap this has been handled by another mechanism so has not been seen by most users. Signed-off-by: Joachim Wiberg --- src/confd/src/ietf-system.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/confd/src/ietf-system.c b/src/confd/src/ietf-system.c index 619b732b..f7a20e93 100644 --- a/src/confd/src/ietf-system.c +++ b/src/confd/src/ietf-system.c @@ -544,12 +544,11 @@ static int change_dns(sr_session_ctx_t *session, uint32_t sub_id, const char *mo case SR_EV_DONE: /* Check if passed validation in previous event */ - if (access(RESOLV_NEXT, F_OK)) - return SR_ERR_OK; - - (void)remove(RESOLV_PREV); - (void)rename(RESOLV_CONF, RESOLV_PREV); - (void)rename(RESOLV_NEXT, RESOLV_CONF); + if (!access(RESOLV_NEXT, F_OK)) { + (void)remove(RESOLV_PREV); + (void)rename(RESOLV_CONF, RESOLV_PREV); + (void)rename(RESOLV_NEXT, RESOLV_CONF); + } /* in bootstrap, another resolvconf will soon take your call */ if (systemf("initctl -bq cond get hook/sys/up"))