@@ -602,20 +602,27 @@ nc_server_config_del_auth_client_pubkey(struct nc_auth_client *auth_client, stru
602602}
603603
604604static void
605- nc_server_config_del_auth_client ( struct nc_server_ssh_opts * opts , struct nc_auth_client * auth_client )
605+ nc_server_config_del_auth_client_pubkeys ( struct nc_auth_client * auth_client )
606606{
607607 uint16_t i , pubkey_count ;
608608
609- free (auth_client -> username );
610-
611609 if (auth_client -> store == NC_STORE_LOCAL ) {
612610 pubkey_count = auth_client -> pubkey_count ;
613611 for (i = 0 ; i < pubkey_count ; i ++ ) {
614612 nc_server_config_del_auth_client_pubkey (auth_client , & auth_client -> pubkeys [i ]);
615613 }
616614 } else if (auth_client -> store == NC_STORE_TRUSTSTORE ) {
617615 free (auth_client -> ts_ref );
616+ auth_client -> ts_ref = NULL ;
618617 }
618+ }
619+
620+ static void
621+ nc_server_config_del_auth_client (struct nc_server_ssh_opts * opts , struct nc_auth_client * auth_client )
622+ {
623+ free (auth_client -> username );
624+
625+ nc_server_config_del_auth_client_pubkeys (auth_client );
619626
620627 free (auth_client -> password );
621628
@@ -2290,6 +2297,41 @@ nc_server_config_use_system_keys(const struct lyd_node *node, NC_OPERATION op)
22902297 return ret ;
22912298}
22922299
2300+ static int
2301+ nc_server_config_public_keys (const struct lyd_node * node , NC_OPERATION op )
2302+ {
2303+ int ret = 0 ;
2304+ struct nc_auth_client * auth_client ;
2305+ struct nc_ch_client * ch_client = NULL ;
2306+
2307+ assert (!strcmp (LYD_NAME (node ), "public-keys" ));
2308+
2309+ /* only do something on delete */
2310+ if (op != NC_OP_DELETE ) {
2311+ return 0 ;
2312+ }
2313+
2314+ /* LOCK */
2315+ if (is_ch (node ) && nc_server_config_get_ch_client_with_lock (node , & ch_client )) {
2316+ /* to avoid unlock on fail */
2317+ return 1 ;
2318+ }
2319+
2320+ if (nc_server_config_get_auth_client (node , ch_client , & auth_client )) {
2321+ ret = 1 ;
2322+ goto cleanup ;
2323+ }
2324+
2325+ nc_server_config_del_auth_client_pubkeys (auth_client );
2326+
2327+ cleanup :
2328+ if (is_ch (node )) {
2329+ /* UNLOCK */
2330+ nc_ch_client_unlock (ch_client );
2331+ }
2332+ return ret ;
2333+ }
2334+
22932335/* leaf */
22942336static int
22952337nc_server_config_password (const struct lyd_node * node , NC_OPERATION op )
@@ -3729,6 +3771,8 @@ nc_server_config_parse_netconf_server(const struct lyd_node *node, NC_OPERATION
37293771 ret = nc_server_config_truststore_reference (node , op );
37303772 } else if (!strcmp (name , "use-system-keys" )) {
37313773 ret = nc_server_config_use_system_keys (node , op );
3774+ } else if (!strcmp (name , "public-keys" )) {
3775+ ret = nc_server_config_public_keys (node , op );
37323776 } else if (!strcmp (name , "password" )) {
37333777 ret = nc_server_config_password (node , op );
37343778 } else if (!strcmp (name , "use-system-auth" )) {
0 commit comments