From dacd2fe3a03a4866ab0bbe2d8c422678af3439b3 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Fri, 8 Jun 2018 15:54:43 +0200 Subject: [PATCH] replace obsolete cvec_find_var with cvec_find --- apps/cli/cli_common.c | 16 ++++++++-------- apps/cli/cli_show.c | 4 ++-- example/example_cli.c | 2 +- test/test_auth_ext.sh | 12 ++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/cli/cli_common.c b/apps/cli/cli_common.c index c0a18f4c..a3fb9ad6 100644 --- a/apps/cli/cli_common.c +++ b/apps/cli/cli_common.c @@ -394,7 +394,7 @@ cli_debug_cli(clicon_handle h, cg_var *cv; int level; - if ((cv = cvec_find_var(vars, "level")) == NULL){ + if ((cv = cvec_find(vars, "level")) == NULL){ if (cvec_len(argv) != 1){ clicon_err(OE_PLUGIN, 0, "%s: Requires either label var or single arg: 0|1", __FUNCTION__); goto done; @@ -425,7 +425,7 @@ cli_debug_backend(clicon_handle h, cg_var *cv; int level; - if ((cv = cvec_find_var(vars, "level")) == NULL){ + if ((cv = cvec_find(vars, "level")) == NULL){ if (cvec_len(argv) != 1){ clicon_err(OE_PLUGIN, 0, "%s: Requires either label var or single arg: 0|1", __FUNCTION__); goto done; @@ -455,7 +455,7 @@ cli_debug_restconf(clicon_handle h, cg_var *cv; int level; - if ((cv = cvec_find_var(vars, "level")) == NULL){ + if ((cv = cvec_find(vars, "level")) == NULL){ if (cvec_len(argv) != 1){ clicon_err(OE_PLUGIN, 0, "%s: Requires either label var or single arg: 0|1", __FUNCTION__); goto done; @@ -750,7 +750,7 @@ load_config_file(clicon_handle h, clicon_err(OE_PLUGIN, 0, "No such op: %s, expected merge or replace", opstr); goto done; } - if ((cv = cvec_find_var(cvv, varstr)) == NULL){ + if ((cv = cvec_find(cvv, varstr)) == NULL){ clicon_err(OE_PLUGIN, 0, "No such var name: %s", varstr); goto done; } @@ -838,7 +838,7 @@ save_config_file(clicon_handle h, clicon_err(OE_PLUGIN, 0, "No such db name: %s", dbstr); goto done; } - if ((cv = cvec_find_var(cvv, varstr)) == NULL){ + if ((cv = cvec_find(cvv, varstr)) == NULL){ clicon_err(OE_PLUGIN, 0, "No such var name: %s", varstr); goto done; } @@ -1230,7 +1230,7 @@ cli_copy_config(clicon_handle h, tovar = cv_string_get(cvec_i(argv, 4)); /* Get from variable -> cv -> from name */ - if ((fromcv = cvec_find_var(cvv, fromvar)) == NULL){ + if ((fromcv = cvec_find(cvv, fromvar)) == NULL){ clicon_err(OE_PLUGIN, 0, "fromvar '%s' not found in cligen var list", fromvar); goto done; } @@ -1261,7 +1261,7 @@ cli_copy_config(clicon_handle h, } /* Get to variable -> cv -> to name */ - if ((tocv = cvec_find_var(cvv, tovar)) == NULL){ + if ((tocv = cvec_find(cvv, tovar)) == NULL){ clicon_err(OE_PLUGIN, 0, "tovar '%s' not found in cligen var list", tovar); goto done; } @@ -1310,7 +1310,7 @@ cli_debug(clicon_handle h, cg_var *cv; int level; - if ((cv = cvec_find_var(vars, "level")) == NULL) + if ((cv = cvec_find(vars, "level")) == NULL) cv = arg; level = cv_int32_get(cv); /* cli */ diff --git a/apps/cli/cli_show.c b/apps/cli/cli_show.c index 52821f7a..e7a855f1 100644 --- a/apps/cli/cli_show.c +++ b/apps/cli/cli_show.c @@ -477,7 +477,7 @@ cli_show_config(clicon_handle h, clicon_err(OE_PLUGIN, 0, "xpath '%s' does not have a single '%%'"); goto done; } - if ((cvattr = cvec_find_var(cvv, attr)) == NULL){ + if ((cvattr = cvec_find(cvv, attr)) == NULL){ clicon_err(OE_PLUGIN, 0, "attr '%s' not found in cligen var list", attr); goto done; } @@ -572,7 +572,7 @@ show_conf_xpath(clicon_handle h, clicon_err(OE_PLUGIN, 0, "No such db name: %s", str); goto done; } - cv = cvec_find_var(cvv, "xpath"); + cv = cvec_find(cvv, "xpath"); xpath = cv_string_get(cv); if (clicon_rpc_get_config(h, str, xpath, &xt) < 0) goto done; diff --git a/example/example_cli.c b/example/example_cli.c index ed5ebb20..35aa6b25 100644 --- a/example/example_cli.c +++ b/example/example_cli.c @@ -104,7 +104,7 @@ fib_route_rpc(clicon_handle h, /* Send to backend */ if (clicon_rpc_netconf_xml(h, xrpc, &xret, NULL) < 0) goto done; - if ((xerr = xpath_first(xret, "/rpc-error")) != NULL){ + if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){ clicon_rpc_generate_error("Get configuration", xerr); goto done; } diff --git a/test/test_auth_ext.sh b/test/test_auth_ext.sh index a6162fe1..43c0aa88 100755 --- a/test/test_auth_ext.sh +++ b/test/test_auth_ext.sh @@ -226,22 +226,22 @@ new2 "guest edit nacm" expecteq "$(curl -u guest:bar -sS -X PUT -d '{"x": 3}' http://localhost/restconf/data/x)" '{"ietf-restconf:errors" : {"error": {"error-tag": "access-denied","error-type": "protocol","error-severity": "error","error-message": "The requested URL was unauthorized"}}} ' new "cli show conf as admin" -expectfn "$clixon_cli -1 -U adm1 -f $cfg -y $fyang show conf" 0 "^x 1;$" +expectfn "$clixon_cli -1 -U adm1 -l o -f $cfg -y $fyang show conf" 0 "^x 1;$" new "cli show conf as limited" -expectfn "$clixon_cli -1 -U wilma -f $cfg -y $fyang show conf" 0 "^x 1;$" +expectfn "$clixon_cli -1 -U wilma -l o -f $cfg -y $fyang show conf" 0 "^x 1;$" new "cli show conf as guest" -expectfn "$clixon_cli -1 -U guest -f $cfg -y $fyang show conf" 255 "CLI command error" +expectfn "$clixon_cli -1 -U guest -l o -f $cfg -y $fyang show conf" 255 "protocol access-denied" new "cli rpc as admin" -expectfn "$clixon_cli -1 -U adm1 -f $cfg -y $fyang rpc ipv4" 0 "2.3.4.5" +expectfn "$clixon_cli -1 -U adm1 -l o -f $cfg -y $fyang rpc ipv4" 0 "2.3.4.5" new "cli rpc as limited" -expectfn "$clixon_cli -1 -U wilma -f $cfg -y $fyang rpc ipv4" 0 "access-denied" +expectfn "$clixon_cli -1 -U wilma -l o -f $cfg -y $fyang rpc ipv4" 255 "protocol access-denied default deny" new "cli rpc as guest" -expectfn "$clixon_cli -1 -U guest -f $cfg -y $fyang rpc ipv4" 0 "access-denied" +expectfn "$clixon_cli -1 -U guest -l o -f $cfg -y $fyang rpc ipv4" 255 "protocol access-denied access denied" new "Kill restconf daemon" sudo pkill -u www-data clixon_restconf