@@ -1041,40 +1041,110 @@ np2srv_ssh_algs_oper_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), cons
10411041 const char * UNUSED (request_xpath ), uint32_t UNUSED (request_id ), struct lyd_node * * parent ,
10421042 void * UNUSED (private_data ))
10431043{
1044- int ret = 0 ;
10451044 const struct ly_ctx * ly_ctx ;
10461045
1047- (void ) path ;
1048-
10491046 /* context is locked by the callback anyway */
10501047 ly_ctx = sr_session_acquire_context (session );
10511048 sr_session_release_context (session );
10521049
10531050 /* get oper data based on the module */
1054- if (!strcmp (module_name , "iana-ssh-public-key-algs" )) {
1055- assert (!strcmp (path , "/iana-ssh-public-key-algs:supported-algorithms" ));
1056- ret = nc_server_config_oper_get_hostkey_algs (ly_ctx , parent );
1057- } else if (!strcmp (module_name , "iana-ssh-key-exchange-algs" )) {
1058- assert (!strcmp (path , "/iana-ssh-key-exchange-algs:supported-algorithms" ));
1059- ret = nc_server_config_oper_get_kex_algs (ly_ctx , parent );
1060- } else if (!strcmp (module_name , "iana-ssh-encryption-algs" )) {
1061- assert (!strcmp (path , "/iana-ssh-encryption-algs:supported-algorithms" ));
1062- ret = nc_server_config_oper_get_encryption_algs (ly_ctx , parent );
1063- } else if (!strcmp (module_name , "iana-ssh-mac-algs" )) {
1064- assert (!strcmp (path , "/iana-ssh-mac-algs:supported-algorithms" ));
1065- ret = nc_server_config_oper_get_mac_algs (ly_ctx , parent );
1051+ if (!strcmp (module_name , "ietf-ssh-common" ) && !strcmp (path , "/ietf-ssh-common:supported-algorithms" )) {
1052+ if (nc_server_config_oper_get_supported_ssh_algs (ly_ctx , parent )) {
1053+ return SR_ERR_INTERNAL ;
1054+ }
10661055 } else {
1067- ERR ("Unable to get supported SSH algorithms ( module %s not supported) ." , module_name );
1056+ ERR ("Unable to get supported SSH algorithms for unknown module \"%s\" and path \"%s\" ." , module_name , path );
10681057 return SR_ERR_INTERNAL ;
10691058 }
1070- if (ret ) {
1071- ERR ("Getting supported SSH algorithms failed." );
1059+
1060+ return SR_ERR_OK ;
1061+ }
1062+
1063+ /**
1064+ * @brief Callback for providing TLS cipher suites operational data.
1065+ */
1066+ static int
1067+ np2srv_tls_algs_oper_cb (sr_session_ctx_t * session , uint32_t UNUSED (sub_id ), const char * module_name , const char * path ,
1068+ const char * UNUSED (request_xpath ), uint32_t UNUSED (request_id ), struct lyd_node * * parent ,
1069+ void * UNUSED (private_data ))
1070+ {
1071+ const struct ly_ctx * ly_ctx ;
1072+
1073+ /* context is locked by the callback anyway */
1074+ ly_ctx = sr_session_acquire_context (session );
1075+ sr_session_release_context (session );
1076+
1077+ /* get oper data based on the module */
1078+ if (!strcmp (module_name , "ietf-tls-common" ) && !strcmp (path , "/ietf-tls-common:supported-algorithms" )) {
1079+ if (nc_server_config_oper_get_supported_tls_algs (ly_ctx , parent )) {
1080+ return SR_ERR_INTERNAL ;
1081+ }
1082+ } else {
1083+ ERR ("Unable to get supported TLS cipher suites for unknown module \"%s\" and path \"%s\"." , module_name , path );
10721084 return SR_ERR_INTERNAL ;
10731085 }
10741086
10751087 return SR_ERR_OK ;
10761088}
10771089
1090+ /**
1091+ * @brief Callback for providing password last-modified operational data.
1092+ */
1093+ static int
1094+ np2srv_password_last_modified_oper_cb (sr_session_ctx_t * UNUSED (session ), uint32_t UNUSED (sub_id ),
1095+ const char * module_name , const char * UNUSED (path ), const char * UNUSED (request_xpath ),
1096+ uint32_t UNUSED (request_id ), struct lyd_node * * parent , void * UNUSED (private_data ))
1097+ {
1098+ int rc = SR_ERR_OK ;
1099+ char * time_str = NULL ;
1100+ const char * ch_client = NULL , * endpoint = NULL , * username = NULL ;
1101+ struct lyd_node * tree ;
1102+ time_t last_modified ;
1103+
1104+ if (strcmp (module_name , "ietf-netconf-server" )) {
1105+ ERR ("Unable to get password last-modified for unknown module \"%s\"." , module_name );
1106+ return SR_ERR_INTERNAL ;
1107+ }
1108+
1109+ /* extract keys from the parent */
1110+ tree = * parent ;
1111+ while (tree -> parent ) {
1112+ if (!strcmp (LYD_NAME (tree ), "call-home" )) {
1113+ ch_client = lyd_get_value (lyd_child (tree ));
1114+ } else if (!strcmp (LYD_NAME (tree ), "endpoint" )) {
1115+ endpoint = lyd_get_value (lyd_child (tree ));
1116+ } else if (!strcmp (LYD_NAME (tree ), "user" )) {
1117+ username = lyd_get_value (lyd_child (tree ));
1118+ }
1119+ tree = lyd_parent (tree );
1120+ }
1121+
1122+ if (!endpoint || !username ) {
1123+ ERR ("Not enough information to get password last-modified." );
1124+ return SR_ERR_INTERNAL ;
1125+ }
1126+
1127+ /* get the last modified time */
1128+ if (nc_server_config_oper_get_user_password_last_modified (ch_client , endpoint , username , & last_modified )) {
1129+ return SR_ERR_INTERNAL ;
1130+ }
1131+
1132+ /* format the time */
1133+ if (ly_time_time2str (last_modified , NULL , & time_str )) {
1134+ return SR_ERR_INTERNAL ;
1135+ }
1136+
1137+ /* add a new child to parent */
1138+ if (lyd_new_term (* parent , NULL , "last-modified" , time_str , 0 , NULL )) {
1139+ rc = SR_ERR_INTERNAL ;
1140+ goto cleanup ;
1141+ }
1142+
1143+ cleanup :
1144+ free (time_str );
1145+ return rc ;
1146+ }
1147+
10781148#endif /* NC_ENABLED_SSH_TLS */
10791149
10801150/**
@@ -1126,18 +1196,19 @@ server_data_subscribe(void)
11261196 }
11271197
11281198#ifdef NC_ENABLED_SSH_TLS
1129- /* set callbacks for supported algorithms oper data */
1130- mod_name = "iana-ssh-public-key-algs" ;
1131- SR_OPER_SUBSCR (mod_name , "/iana-ssh-public-key-algs:supported-algorithms" , np2srv_ssh_algs_oper_cb );
1132-
1133- mod_name = "iana-ssh-key-exchange-algs" ;
1134- SR_OPER_SUBSCR (mod_name , "/iana-ssh-key-exchange-algs:supported-algorithms" , np2srv_ssh_algs_oper_cb );
1199+ /* set callbacks for supported SSH algorithms and TLS cipher suites oper data */
1200+ mod_name = "ietf-ssh-common" ;
1201+ SR_OPER_SUBSCR (mod_name , "/ietf-ssh-common:supported-algorithms" , np2srv_ssh_algs_oper_cb );
11351202
1136- mod_name = "iana-ssh-encryption-algs " ;
1137- SR_OPER_SUBSCR (mod_name , "/iana-ssh-encryption-algs :supported-algorithms" , np2srv_ssh_algs_oper_cb );
1203+ mod_name = "ietf-tls-common " ;
1204+ SR_OPER_SUBSCR (mod_name , "/ietf-tls-common :supported-algorithms" , np2srv_tls_algs_oper_cb );
11381205
1139- mod_name = "iana-ssh-mac-algs" ;
1140- SR_OPER_SUBSCR (mod_name , "/iana-ssh-mac-algs:supported-algorithms" , np2srv_ssh_algs_oper_cb );
1206+ /* password last modified oper data for both listen + call-home SSH users */
1207+ mod_name = "ietf-netconf-server" ;
1208+ SR_OPER_SUBSCR (mod_name , "/ietf-netconf-server:netconf-server/listen/endpoints/endpoint/ssh/"
1209+ "ssh-server-parameters/client-authentication/users/user/password/last-modified" , np2srv_password_last_modified_oper_cb );
1210+ SR_OPER_SUBSCR (mod_name , "/ietf-netconf-server:netconf-server/call-home/netconf-client/endpoints/endpoint/ssh/"
1211+ "ssh-server-parameters/client-authentication/users/user/password/last-modified" , np2srv_password_last_modified_oper_cb );
11411212#endif /* NC_ENABLED_SSH_TLS */
11421213
11431214 /* subscriptions to running DS */
0 commit comments