From 8bc389987c0f12ebb616e0fa8cb7506876a56874 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 19 Jan 2025 23:44:39 +0100 Subject: [PATCH] confd: skip password node in operational data if locked/empty pwd Skip the password node in operational data for entries that have locked or empty password, otherwise the YANG validation (regexp) will fail. Signed-off-by: Joachim Wiberg --- src/confd/src/ietf-system.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/confd/src/ietf-system.c b/src/confd/src/ietf-system.c index ecbf84cc..9a616e56 100644 --- a/src/confd/src/ietf-system.c +++ b/src/confd/src/ietf-system.c @@ -1399,23 +1399,23 @@ static int auth_cb(sr_session_ctx_t *session, uint32_t sub_id, const char *modul const char *path, const char *request_path, uint32_t request_id, struct lyd_node **parent, void *priv) { + const char *fmt = "/ietf-system:system/authentication/user[name='%s']/password"; struct spwd *spwd; - ERROR("%s() path %s reqeust_path %s", __func__, path, request_path); - setspent(); while ((spwd = getspent())) { - const char *fmt = "/ietf-system:system/authentication/user[name='%s']/password"; char xpath[256]; - if (!spwd->sp_pwdp || spwd->sp_pwdp[0] == '*' || spwd->sp_pwdp[0] == '!') + /* Skip any records that do not pass YANG validation */ + if (!spwd->sp_pwdp || spwd->sp_pwdp[0] == '0' || + spwd->sp_pwdp[0] == '*' || spwd->sp_pwdp[0] == '!') continue; snprintf(xpath, sizeof(xpath), fmt, spwd->sp_namp); lyd_new_path(*parent, NULL, xpath, spwd->sp_pwdp, 0, 0); } - endspent(); + return SR_ERR_OK; }