From d3a5114761d077ad72171998045d37cbf46bb7d0 Mon Sep 17 00:00:00 2001
From: Michal Vasko <mvasko@cesnet.cz>
Date: Thu, 4 Dec 2025 14:13:10 +0100
Subject: [PATCH 3/4] main UPDATE support having local users disabled
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Wires

Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
 src/main.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/main.c b/src/main.c
index 64ffaaa..7492b43 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1158,6 +1158,8 @@ server_data_subscribe(void)
 {
     int rc;
     const char *mod_name, *xpath;
+    const struct lys_module *mod;
+    const struct ly_ctx *ly_ctx;
 
 #define SR_OPER_SUBSCR(mod_name, xpath, cb) \
     rc = sr_oper_get_subscribe(np2srv.sr_sess, mod_name, xpath, cb, NULL, 0, &np2srv.sr_data_sub); \
@@ -1203,12 +1205,19 @@ server_data_subscribe(void)
     mod_name = "ietf-tls-common";
     SR_OPER_SUBSCR(mod_name, "/ietf-tls-common:supported-algorithms", np2srv_tls_algs_oper_cb);
 
-    /* password last modified oper data for both listen + call-home SSH users */
-    mod_name = "ietf-netconf-server";
-    SR_OPER_SUBSCR(mod_name, "/ietf-netconf-server:netconf-server/listen/endpoints/endpoint/ssh/"
-            "ssh-server-parameters/client-authentication/users/user/password/last-modified", np2srv_password_last_modified_oper_cb);
-    SR_OPER_SUBSCR(mod_name, "/ietf-netconf-server:netconf-server/call-home/netconf-client/endpoints/endpoint/ssh/"
-            "ssh-server-parameters/client-authentication/users/user/password/last-modified", np2srv_password_last_modified_oper_cb);
+    ly_ctx = sr_acquire_context(np2srv.sr_conn);
+    mod = ly_ctx_get_module_implemented(ly_ctx, "ietf-ssh-server");
+    sr_release_context(np2srv.sr_conn);
+    if (!lys_feature_value(mod, "local-users-supported")) {
+        /* password last modified oper data for both listen + call-home SSH users */
+        mod_name = "ietf-netconf-server";
+        SR_OPER_SUBSCR(mod_name, "/ietf-netconf-server:netconf-server/listen/endpoints/endpoint/ssh/"
+                "ssh-server-parameters/client-authentication/users/user/password/last-modified",
+                np2srv_password_last_modified_oper_cb);
+        SR_OPER_SUBSCR(mod_name, "/ietf-netconf-server:netconf-server/call-home/netconf-client/endpoints/endpoint/ssh/"
+                "ssh-server-parameters/client-authentication/users/user/password/last-modified",
+                np2srv_password_last_modified_oper_cb);
+    }
 #endif /* NC_ENABLED_SSH_TLS */
 
     /* subscriptions to running DS */
-- 
2.43.0

