From c64878fd4a11cc974f1d363c307cba630c67641b Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 11 Feb 2021 13:46:34 +0100 Subject: [PATCH] * RESTCONF configuration is unified and moved from clixon-config.yang to clixon-restconf.yang * Except `CLICON_RESTCONF_DIR` which remains in clixon-config.yang due to bootstrapping * -d option removed * This applies to both evhtp and fcgi RESTCONF * Both can also read config from backend, and be started from backend * You may need to move config as follows (from clixon-config.yang to clixon-restconf.yang) * CLICON_RESTCONF_PRETTY -> restconf/pretty * CLICON_RESTCONF_PATH -> restconf/fcgi-path --- CHANGELOG.md | 51 +++++--- apps/restconf/restconf_lib.c | 11 +- apps/restconf/restconf_main_evhtp.c | 41 +++--- apps/restconf/restconf_main_fcgi.c | 136 ++++++++++++-------- apps/restconf/restconf_root.c | 1 + apps/restconf/restconf_stream_fcgi.c | 1 + lib/clixon/clixon_data.h | 2 + lib/src/clixon_data.c | 18 +++ lib/src/clixon_options.c | 13 ++ lib/src/clixon_yang.c | 5 +- test/lib.sh | 9 +- test/long.sh | 26 ++-- test/plot_perf.sh | 1 - test/test_api.sh | 3 +- test/test_augment.sh | 3 +- test/test_augment_state.sh | 1 - test/test_augment_trans.sh | 1 - test/test_c++.sh | 2 - test/test_choice.sh | 3 +- test/test_client.sh | 3 +- test/test_copy_config.sh | 2 +- test/test_identity.sh | 3 +- test/test_nacm.sh | 3 +- test/test_nacm_datanode.sh | 3 +- test/test_nacm_datanode_paths.sh | 3 +- test/test_nacm_datanode_read.sh | 3 +- test/test_nacm_datanode_write.sh | 3 +- test/test_nacm_default.sh | 3 +- test/test_nacm_ext.sh | 3 +- test/test_nacm_module_read.sh | 3 +- test/test_nacm_module_write.sh | 3 +- test/test_nacm_protocol.sh | 3 +- test/test_nacm_recovery.sh | 3 +- test/test_netconf_notifications.sh | 1 - test/test_perf_cli.sh | 1 - test/test_perf_mem.sh | 1 - test/test_perf_netconf.sh | 1 - test/test_perf_restconf.sh | 3 +- test/test_perf_startup.sh | 1 - test/test_perf_state.sh | 3 +- test/test_perf_state_only.sh | 3 +- test/test_restconf.sh | 6 +- test/test_restconf2.sh | 3 +- test/test_restconf_err.sh | 3 +- test/test_restconf_jukebox.sh | 3 +- test/test_restconf_listkey.sh | 3 +- test/test_restconf_netns.sh | 3 +- test/test_restconf_notifications.sh | 3 +- test/test_restconf_patch.sh | 3 +- test/test_restconf_rpc.sh | 3 +- test/test_restconf_ssl_certs.sh | 4 +- test/test_restconf_startup.sh | 2 +- test/test_rpc.sh | 3 +- test/test_submodule.sh | 3 +- test/test_yang_anydata.sh | 3 +- test/test_yang_namespace.sh | 3 +- yang/clixon/clixon-config@2020-12-30.yang | 28 ++-- yang/clixon/clixon-restconf@2020-12-30.yang | 33 +++++ 58 files changed, 293 insertions(+), 199 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 481fc5c9..f7dc63a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,16 +31,44 @@ Expected: February 2021 ### New features -* RESTCONF failed authentication changed error return code from 403 Forbiden to 401 Unauthorized following RFC 8040 - * Authentication OK but failed on access, remains as 403 Forbidden * NETCONF Call Home Call Home RFC 8071 * See [Netconf/ssh callhome](https://clixon-docs.readthedocs.io/en/latest/netconf.html#callhome) * Solution description using openssh and utility functions, no changes to core clixon * Example: test/test_netconf_ssh_callhome.sh - * RESTCONF Call home not done + * RESTCONF Call home not yet implemented * New clixon_client API for external access * See [client api docs](https://clixon-docs.readthedocs.io/en/latest/client.html) +### API changes on existing protocol/config features + +Users may have to change how they access the system + +* RESTCONF configuration is unified and moved from clixon-config.yang to clixon-restconf.yang + * Except `CLICON_RESTCONF_DIR` which remains in clixon-config.yang due to bootstrapping + * -d option removed + * This applies to both evhtp and fcgi RESTCONF + * Both can also read config from backend, and be started from backend + * You may need to move config as follows (from clixon-config.yang to clixon-restconf.yang) + * CLICON_RESTCONF_PRETTY -> restconf/pretty + * CLICON_RESTCONF_PATH -> restconf/fcgi-path + * For more info see [clixon-docs](https://clixon-docs.readthedocs.io/en/latest/restconf.html) +* RESTCONF failed authentication changed error return code from 403 Forbiden to 401 Unauthorized following RFC 8040 + * Authentication OK but failed on access, remains as 403 Forbidden +* Handling empty netconf XML messages "]]>]]>" is changed from being accepted to return an error. +* New clixon-restconf@2020-12-30.yang revision + * Added: debug field + * Added 'none' as default value for auth-type + * Changed http-auth-type enum from 'password' to 'user' +* New clixon-lib@2020-12-30.yang revision + * Changed: RPC process-control output parameter status to pid +* New clixon-config@2020-12-30.yang revision + * Removed obsolete RESTCONF and SSL options (CLICON_SSL_* and CLICON_RESTCONF_IP*/HTTP*) + * Removed obsolete: CLICON_TRANSACTION_MOD option + * Marked as obsolete: CLICON_RESTCONF_PATH CLICON_RESTCONF_PRETTY +* Changed namespace of clixon-restconf@2020-10-30.yang from https://clicon.org/restconf ->http://clicon.org/restconf -> +* CLIspec dbxml API: Ability to specify deletion of _any_ vs _specific_ entry. + * In a cli_del() call, the cvv arg list either exactly matches the api-format-path in which case _any_ deletion is specified, otherwise, if there is an extra element in the cvv list, that is used for a specific delete. + ### C/CLI-API changes on existing features Developers may need to change their code @@ -56,23 +84,6 @@ Developers may need to change their code * rpc msg C API rearranged to separate socket/connect from connect * Added `cvv_i` output parameter to `api_path_fmt2api_path()` to see how many cvv entries were used. -### API changes on existing protocol/config features - -Users may have to change how they access the system - -* Handling empty netconf XML messages "]]>]]>" is changed from being accepted to return an error. -* New clixon-restconf@2020-12-30.yang revision - * Added: debug field - * Added 'none' as default value for auth-type - * Changed http-auth-type enum from 'password' to 'user' -* New clixon-lib@2020-12-30.yang revision - * Changed: RPC process-control output parameter status to pid -* New clixon-config@2020-12-30.yang revision - * Removed obsolete RESTCONF and SSL options -* Changed namespace of clixon-restconf@2020-10-30.yang from https://clicon.org/restconf ->http://clicon.org/restconf -> -* CLIspec dbxml API: Ability to specify deletion of _any_ vs _specific_ entry. - * In a cli_del() call, the cvv arg list either exactly matches the api-format-path in which case _any_ deletion is specified, otherwise, if there is an extra element in the cvv list, that is used for a specific delete. - ### Minor changes * Add ca_reset plugin also when backend starts as `-s none` diff --git a/apps/restconf/restconf_lib.c b/apps/restconf/restconf_lib.c index 6a5fcce0..32b0b83d 100644 --- a/apps/restconf/restconf_lib.c +++ b/apps/restconf/restconf_lib.c @@ -599,7 +599,6 @@ restconf_config_init(clicon_handle h, goto disable; } } - /* get common fields */ if ((x = xpath_first(xrestconf, nsc, "auth-type")) != NULL && (bstr = xml_body(x)) != NULL){ @@ -609,6 +608,16 @@ restconf_config_init(clicon_handle h, } restconf_auth_type_set(h, auth_type); } + if ((x = xpath_first(xrestconf, nsc, "pretty")) != NULL && + (bstr = xml_body(x)) != NULL){ + /* XXX redirection to (obsolete) option, fix by replacing its accesses */ + clicon_option_str_set(h, "CLICON_RESTCONF_PRETTY", bstr); + } + if ((x = xpath_first(xrestconf, nsc, "fcgi-socket")) != NULL && + (bstr = xml_body(x)) != NULL){ + /* XXX redirection to (obsolete) option, fix by replacing its accesses */ + clicon_option_str_set(h, "CLICON_RESTCONF_PATH", bstr); + } retval = 1; done: return retval; diff --git a/apps/restconf/restconf_main_evhtp.c b/apps/restconf/restconf_main_evhtp.c index bb994fa0..f921f374 100644 --- a/apps/restconf/restconf_main_evhtp.c +++ b/apps/restconf/restconf_main_evhtp.c @@ -84,7 +84,7 @@ #include "restconf_root.h" /* Command line options to be passed to getopt(3) */ -#define RESTCONF_OPTS "hD:f:E:l:p:d:y:a:u:ro:" +#define RESTCONF_OPTS "hD:f:E:l:p:y:a:u:ro:" /* See see listen(5) */ #define SOCKET_LISTEN_BACKLOG 16 @@ -700,15 +700,13 @@ usage(clicon_handle h, "\t-E \t Extra configuration file directory\n" "\t-l > \t Log on (s)yslog, (f)ile (syslog is default)\n" "\t-p \t Yang directory path (see CLICON_YANG_DIR)\n" - "\t-d \t Specify restconf plugin directory dir (default: %s)\n" "\t-y \t Load yang spec file (override yang main module)\n" "\t-a UNIX|IPv4|IPv6 Internal backend socket family\n" "\t-u \t Internal socket domain path or IP addr (see -a)\n" "\t-r \t\t Do not drop privileges if run as root\n" "\t-o