@@ -903,19 +903,19 @@ config_hostkey_pubkey_inline(const struct lyd_node *node, enum nc_operation pare
903903 NC_CHECK_RET (config_privkey_format (n , op , & hostkey -> key .privkey ));
904904 }
905905
906- /* config privkey data, mandatory case/choice node => only one can be present */
906+ /* config privkey data, mandatory case/choice node,
907+ * up to 2 can be present in diff, 1 with delete and 1 with create */
907908 nc_lyd_find_child_optional (node , "cleartext-private-key" , & cleartext );
908909 nc_lyd_find_child_optional (node , "hidden-private-key" , & hidden );
909910 nc_lyd_find_child_optional (node , "encrypted-private-key" , & encrypted );
910911 if (cleartext ) {
911912 NC_CHECK_RET (config_cleartext_privkey_data (cleartext , op , & hostkey -> key .privkey ));
912- } else if (hidden ) {
913+ }
914+ if (hidden ) {
913915 NC_CHECK_RET (config_hidden_privkey_data (hidden , op ));
914- } else if (encrypted ) {
916+ }
917+ if (encrypted ) {
915918 NC_CHECK_RET (config_encrypted_privkey_data (encrypted , op ));
916- } else {
917- ERRINT ;
918- return 1 ;
919919 }
920920
921921 if (op == NC_OP_DELETE ) {
@@ -961,11 +961,9 @@ config_hostkey_public_key(const struct lyd_node *node, enum nc_operation parent_
961961 nc_lyd_find_child_optional (node , "central-keystore-reference" , & keystore_ref );
962962 if (inline_def ) {
963963 NC_CHECK_RET (config_hostkey_pubkey_inline (inline_def , op , hostkey ));
964- } else if (keystore_ref ) {
964+ }
965+ if (keystore_ref ) {
965966 NC_CHECK_RET (config_hostkey_pubkey_keystore (keystore_ref , op , hostkey ));
966- } else {
967- ERRINT ;
968- return 1 ;
969967 }
970968
971969 return 0 ;
@@ -1017,12 +1015,10 @@ config_ssh_hostkey(const struct lyd_node *node, enum nc_operation parent_op, str
10171015 if (public_key ) {
10181016 /* config public key */
10191017 NC_CHECK_RET (config_hostkey_public_key (public_key , op , hostkey ));
1020- } else if (certificate ) {
1018+ }
1019+ if (certificate ) {
10211020 /* config certificate */
10221021 NC_CHECK_RET (config_hostkey_certificate (certificate , op ));
1023- } else {
1024- ERRINT ;
1025- return 1 ;
10261022 }
10271023
10281024 /* all children processed, we can now delete the hostkey */
@@ -1249,13 +1245,12 @@ config_ssh_user_public_keys(const struct lyd_node *node, enum nc_operation paren
12491245 nc_lyd_find_child_optional (node , "libnetconf2-netconf-server:use-system-keys" , & system );
12501246 if (inline_def ) {
12511247 NC_CHECK_RET (config_ssh_user_pubkey_inline (inline_def , op , user ));
1252- } else if (truststore_ref ) {
1248+ }
1249+ if (truststore_ref ) {
12531250 NC_CHECK_RET (config_ssh_user_pubkey_truststore (truststore_ref , op , user ));
1254- } else if (system ) {
1251+ }
1252+ if (system ) {
12551253 NC_CHECK_RET (config_ssh_user_pubkey_system (system , op , user ));
1256- } else {
1257- ERRINT ;
1258- return 1 ;
12591254 }
12601255
12611256 return 0 ;
@@ -1998,13 +1993,12 @@ config_tls_server_ident_cert_inline(const struct lyd_node *node, enum nc_operati
19981993 nc_lyd_find_child_optional (node , "encrypted-private-key" , & encrypted );
19991994 if (cleartext ) {
20001995 NC_CHECK_RET (config_cleartext_privkey_data (cleartext , op , & opts -> local .key .privkey ), 1 );
2001- } else if (hidden ) {
1996+ }
1997+ if (hidden ) {
20021998 NC_CHECK_RET (config_hidden_privkey_data (hidden , op ), 1 );
2003- } else if (encrypted ) {
1999+ }
2000+ if (encrypted ) {
20042001 NC_CHECK_RET (config_encrypted_privkey_data (encrypted , op ), 1 );
2005- } else {
2006- ERRINT ;
2007- return 1 ;
20082002 }
20092003
20102004 /* config certificate data */
@@ -2115,11 +2109,9 @@ config_tls_server_ident_certificate(const struct lyd_node *node, enum nc_operati
21152109 nc_lyd_find_child_optional (node , "central-keystore-reference" , & keystore_ref );
21162110 if (inline_def ) {
21172111 NC_CHECK_RET (config_tls_server_ident_cert_inline (inline_def , op , tls ));
2118- } else if (keystore_ref ) {
2112+ }
2113+ if (keystore_ref ) {
21192114 NC_CHECK_RET (config_tls_server_ident_cert_keystore (keystore_ref , op , tls ));
2120- } else {
2121- ERRINT ;
2122- return 1 ;
21232115 }
21242116
21252117 return 0 ;
@@ -2161,15 +2153,15 @@ config_tls_server_identity(const struct lyd_node *node, enum nc_operation parent
21612153 nc_lyd_find_child_optional (node , "tls13-epsk" , & tls13_epsk );
21622154 if (certificate ) {
21632155 NC_CHECK_RET (config_tls_server_ident_certificate (certificate , op , tls ));
2164- } else if (raw_private_key ) {
2156+ }
2157+ if (raw_private_key ) {
21652158 NC_CHECK_RET (config_tls_server_ident_raw_key (raw_private_key , op ));
2166- } else if (tls12_psk ) {
2159+ }
2160+ if (tls12_psk ) {
21672161 NC_CHECK_RET (config_tls_server_ident_tls12_psk (tls12_psk , op ));
2168- } else if (tls13_epsk ) {
2162+ }
2163+ if (tls13_epsk ) {
21692164 NC_CHECK_RET (config_tls_server_ident_tls13_epsk (tls13_epsk , op ));
2170- } else {
2171- ERRINT ;
2172- return 1 ;
21732165 }
21742166
21752167 return 0 ;
@@ -2309,11 +2301,9 @@ config_tls_client_auth_ca_certs(const struct lyd_node *node, enum nc_operation p
23092301 nc_lyd_find_child_optional (node , "central-truststore-reference" , & truststore_ref );
23102302 if (inline_def ) {
23112303 NC_CHECK_RET (config_tls_client_auth_ca_certs_inline (inline_def , op , client_auth ));
2312- } else if (truststore_ref ) {
2304+ }
2305+ if (truststore_ref ) {
23132306 NC_CHECK_RET (config_tls_client_auth_ca_certs_truststore (truststore_ref , op , client_auth ));
2314- } else {
2315- ERRINT ;
2316- return 1 ;
23172307 }
23182308
23192309 return 0 ;
@@ -2435,11 +2425,9 @@ config_tls_client_auth_ee_certs(const struct lyd_node *node,
24352425 nc_lyd_find_child_optional (node , "central-truststore-reference" , & truststore_ref );
24362426 if (inline_def ) {
24372427 NC_CHECK_RET (config_tls_client_auth_ee_certs_inline (inline_def , op , client_auth ));
2438- } else if (truststore_ref ) {
2428+ }
2429+ if (truststore_ref ) {
24392430 NC_CHECK_RET (config_tls_client_auth_ee_certs_truststore (truststore_ref , op , client_auth ));
2440- } else {
2441- ERRINT ;
2442- return 1 ;
24432431 }
24442432
24452433 return 0 ;
@@ -3287,11 +3275,9 @@ config_unix(const struct lyd_node *node, enum nc_operation parent_op, struct nc_
32873275 nc_lyd_find_child_optional (node , "hidden-path" , & hidden_path );
32883276 if (socket_path ) {
32893277 NC_CHECK_RET (config_unix_socket_path (socket_path , op , endpt ));
3290- } else if (hidden_path ) {
3278+ }
3279+ if (hidden_path ) {
32913280 NC_CHECK_RET (config_unix_hidden_path (hidden_path , op , endpt ));
3292- } else {
3293- ERRINT ;
3294- return 1 ;
32953281 }
32963282
32973283 /* config socket permissions */
@@ -3379,9 +3365,10 @@ config_endpoint(const struct lyd_node *node, enum nc_operation parent_op,
33793365#ifdef NC_ENABLED_SSH_TLS
33803366 if (ssh ) {
33813367 NC_CHECK_RET (config_ssh (ssh , op , endpt ));
3382- } else if (tls ) {
3368+ }
3369+ if (tls ) {
33833370 NC_CHECK_RET (config_tls (tls , op , endpt ));
3384- } else
3371+ }
33853372#endif /* NC_ENABLED_SSH_TLS */
33863373 if (unix ) {
33873374 NC_CHECK_RET (config_unix (unix , op , endpt ));
@@ -3731,11 +3718,9 @@ config_ch_client_endpoint(const struct lyd_node *node, enum nc_operation parent_
37313718 nc_lyd_find_child_optional (node , "tls" , & tls );
37323719 if (ssh ) {
37333720 NC_CHECK_RET (config_ch_endpoint_ssh (ssh , op , endpt ));
3734- } else if (tls ) {
3721+ }
3722+ if (tls ) {
37353723 NC_CHECK_RET (config_ch_endpoint_tls (tls , op , endpt ));
3736- } else {
3737- ERRINT ;
3738- return 1 ;
37393724 }
37403725#endif /* NC_ENABLED_SSH_TLS */
37413726
@@ -3868,12 +3853,13 @@ config_ch_client_connection_type(const struct lyd_node *node, enum nc_operation
38683853 NC_NODE_GET_OP (node , parent_op , & op );
38693854
38703855 /* config persistent / periodic choice,
3871- * the choice itself is mandatory, but both containers are presence, so need to check explicitly */
3856+ * the choice itself is mandatory, but both containers are presence */
38723857 nc_lyd_find_child_optional (node , "persistent" , & persistent );
38733858 nc_lyd_find_child_optional (node , "periodic" , & periodic );
38743859 if (persistent ) {
38753860 NC_CHECK_RET (config_ch_conn_type_persistent (persistent , op , ch_client ));
3876- } else if (periodic ) {
3861+ }
3862+ if (periodic ) {
38773863 NC_CHECK_RET (config_ch_conn_type_periodic (periodic , op , ch_client ));
38783864 }
38793865
@@ -4332,9 +4318,11 @@ config_asymmetric_key(const struct lyd_node *node, enum nc_operation parent_op,
43324318 nc_lyd_find_child_optional (node , "encrypted-private-key" , & encrypted );
43334319 if (cleartext ) {
43344320 NC_CHECK_RET (config_cleartext_privkey_data (cleartext , op , & entry -> asym_key .privkey ));
4335- } else if (hidden ) {
4321+ }
4322+ if (hidden ) {
43364323 NC_CHECK_RET (config_hidden_privkey_data (hidden , op ));
4337- } else if (encrypted ) {
4324+ }
4325+ if (encrypted ) {
43384326 NC_CHECK_RET (config_encrypted_privkey_data (encrypted , op ));
43394327 }
43404328
0 commit comments