dont exit cli when expand gets auth denied from backend
This commit is contained in:
parent
7e4e1d6deb
commit
39538461c2
4 changed files with 25 additions and 21 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
* Previous support did no validation of values.
|
* Previous support did no validation of values.
|
||||||
* Validation of types and CLI expansion
|
* Validation of types and CLI expansion
|
||||||
* Example extended with inclusion of iana-if-type RFC 7224 interface identities
|
* Example extended with inclusion of iana-if-type RFC 7224 interface identities
|
||||||
|
* Applications which have not strictly enforced the identities may now have problems with validation and may need to be modified.
|
||||||
### Minor changes:
|
### Minor changes:
|
||||||
* Added yang identityref runtime validation
|
* Added yang identityref runtime validation
|
||||||
* Removed cli callback vector functions. Set COMPAT_COMPAT_CLIV if you need to keep these functions in clixon_custom.h.
|
* Removed cli callback vector functions. Set COMPAT_COMPAT_CLIV if you need to keep these functions in clixon_custom.h.
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ cli_interactive(clicon_handle h)
|
||||||
int res;
|
int res;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
char *new_mode;
|
char *new_mode;
|
||||||
int result;
|
int eval;
|
||||||
|
|
||||||
/* Loop through all commands */
|
/* Loop through all commands */
|
||||||
while(!cligen_exiting(cli_cligen(h))) {
|
while(!cligen_exiting(cli_cligen(h))) {
|
||||||
|
|
@ -128,7 +128,7 @@ cli_interactive(clicon_handle h)
|
||||||
cligen_exiting_set(cli_cligen(h), 1); /* EOF */
|
cligen_exiting_set(cli_cligen(h), 1); /* EOF */
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if ((res = clicon_parse(h, cmd, &new_mode, &result)) < 0)
|
if ((res = clicon_parse(h, cmd, &new_mode, &eval)) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
|
||||||
|
|
@ -444,6 +444,8 @@ cli_handler_err(FILE *f)
|
||||||
/*! Evaluate a matched command
|
/*! Evaluate a matched command
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] cmd The command string
|
* @param[in] cmd The command string
|
||||||
|
* @retval int If there is a callback, the return value of the callback is returned,
|
||||||
|
* @retval 0 otherwise
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_eval(clicon_handle h,
|
clicon_eval(clicon_handle h,
|
||||||
|
|
@ -451,10 +453,12 @@ clicon_eval(clicon_handle h,
|
||||||
cg_obj *match_obj,
|
cg_obj *match_obj,
|
||||||
cvec *cvv)
|
cvec *cvv)
|
||||||
{
|
{
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
cli_output_reset();
|
cli_output_reset();
|
||||||
if (!cligen_exiting(cli_cligen(h))) {
|
if (!cligen_exiting(cli_cligen(h))) {
|
||||||
clicon_err_reset();
|
clicon_err_reset();
|
||||||
if (cligen_eval(cli_cligen(h), match_obj, cvv) < 0) {
|
if ((retval = cligen_eval(cli_cligen(h), match_obj, cvv)) < 0) {
|
||||||
#if 0 /* This is removed since we get two error messages on failure.
|
#if 0 /* This is removed since we get two error messages on failure.
|
||||||
But maybe only sometime?
|
But maybe only sometime?
|
||||||
Both a real log when clicon_err is called, and the here again.
|
Both a real log when clicon_err is called, and the here again.
|
||||||
|
|
@ -463,11 +467,10 @@ clicon_eval(clicon_handle h,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! Given a command string, parse and if match single command, eval it.
|
||||||
/*! Given a command string, parse and evaluate.
|
|
||||||
* Parse and evaluate the string according to
|
* Parse and evaluate the string according to
|
||||||
* the syntax parse tree of the syntax mode specified by *mode.
|
* the syntax parse tree of the syntax mode specified by *mode.
|
||||||
* If there is no match in the tree for the command, the parse hook
|
* If there is no match in the tree for the command, the parse hook
|
||||||
|
|
@ -478,20 +481,25 @@ clicon_eval(clicon_handle h,
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] cmd Command string
|
* @param[in] cmd Command string
|
||||||
* @param[in,out] modenamep Pointer to the mode string pointer
|
* @param[in,out] modenamep Pointer to the mode string pointer
|
||||||
* @param[out] result -2 On eof (shouldnt happen)
|
* @param[out] evalres Evaluation result if retval=1
|
||||||
|
* -2 On eof (shouldnt happen)
|
||||||
* -1 On parse error
|
* -1 On parse error
|
||||||
* >=0 Number of matches
|
* >=0 Number of matches
|
||||||
* @retval 0 XXX How does this relate to result???
|
* @retval -2 Eof CG_EOF
|
||||||
|
* @retval -1 Error CG_ERROR
|
||||||
|
* @retval 0 No match CG_NOMATCH
|
||||||
|
* @retval 1 Exactly one match CG_MATCH
|
||||||
|
* @retval 2+ Multiple matches
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_parse(clicon_handle h,
|
clicon_parse(clicon_handle h,
|
||||||
char *cmd,
|
char *cmd,
|
||||||
char **modenamep,
|
char **modenamep,
|
||||||
int *result)
|
int *evalres)
|
||||||
{
|
{
|
||||||
|
int retval = -1;
|
||||||
char *modename;
|
char *modename;
|
||||||
char *modename0;
|
char *modename0;
|
||||||
int retval = -1;
|
|
||||||
int r;
|
int r;
|
||||||
cli_syntax_t *stx = NULL;
|
cli_syntax_t *stx = NULL;
|
||||||
cli_syntaxmode_t *smode;
|
cli_syntaxmode_t *smode;
|
||||||
|
|
@ -515,8 +523,7 @@ clicon_parse(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (smode)
|
if (smode){
|
||||||
while(1) {
|
|
||||||
modename0 = NULL;
|
modename0 = NULL;
|
||||||
if ((pt = cligen_tree_active_get(cli_cligen(h))) != NULL)
|
if ((pt = cligen_tree_active_get(cli_cligen(h))) != NULL)
|
||||||
modename0 = pt->pt_name;
|
modename0 = pt->pt_name;
|
||||||
|
|
@ -543,13 +550,12 @@ clicon_parse(clicon_handle h,
|
||||||
case CG_EOF: /* eof */
|
case CG_EOF: /* eof */
|
||||||
case CG_ERROR:
|
case CG_ERROR:
|
||||||
cli_output(f, "CLI parse error: %s\n", cmd);
|
cli_output(f, "CLI parse error: %s\n", cmd);
|
||||||
goto done;
|
break;
|
||||||
case CG_NOMATCH: /* no match */
|
case CG_NOMATCH: /* no match */
|
||||||
/* clicon_err(OE_CFG, 0, "CLI syntax error: \"%s\": %s",
|
/* clicon_err(OE_CFG, 0, "CLI syntax error: \"%s\": %s",
|
||||||
cmd, cli_nomatch(h));*/
|
cmd, cli_nomatch(h));*/
|
||||||
cli_output(f, "CLI syntax error: \"%s\": %s\n",
|
cli_output(f, "CLI syntax error: \"%s\": %s\n",
|
||||||
cmd, cli_nomatch(h));
|
cmd, cli_nomatch(h));
|
||||||
goto done;
|
|
||||||
break;
|
break;
|
||||||
case CG_MATCH:
|
case CG_MATCH:
|
||||||
if (strcmp(modename, *modenamep)){ /* Command in different mode */
|
if (strcmp(modename, *modenamep)){ /* Command in different mode */
|
||||||
|
|
@ -559,16 +565,14 @@ clicon_parse(clicon_handle h,
|
||||||
if ((r = clicon_eval(h, cmd, match_obj, cvv)) < 0)
|
if ((r = clicon_eval(h, cmd, match_obj, cvv)) < 0)
|
||||||
cli_handler_err(stdout);
|
cli_handler_err(stdout);
|
||||||
pt_expand_cleanup_1(pt); /* XXX change to pt_expand_treeref_cleanup */
|
pt_expand_cleanup_1(pt); /* XXX change to pt_expand_treeref_cleanup */
|
||||||
if (result)
|
if (evalres)
|
||||||
*result = r;
|
*evalres = r;
|
||||||
goto done;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cli_output(f, "CLI syntax error: \"%s\" is ambiguous\n", cmd);
|
cli_output(f, "CLI syntax error: \"%s\" is ambiguous\n", cmd);
|
||||||
goto done;
|
|
||||||
break;
|
break;
|
||||||
} /* switch retval */
|
} /* switch retval */
|
||||||
} /* while smode */
|
}
|
||||||
done:
|
done:
|
||||||
if (cvv)
|
if (cvv)
|
||||||
cvec_free(cvv);
|
cvec_free(cvv);
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ expand_dbvar(void *h,
|
||||||
goto done;
|
goto done;
|
||||||
if ((xerr = xpath_first(xt, "/rpc-error")) != NULL){
|
if ((xerr = xpath_first(xt, "/rpc-error")) != NULL){
|
||||||
clicon_rpc_generate_error("Get configuration", xerr);
|
clicon_rpc_generate_error("Get configuration", xerr);
|
||||||
goto done;
|
goto ok;
|
||||||
}
|
}
|
||||||
xcur = xt; /* default top-of-tree */
|
xcur = xt; /* default top-of-tree */
|
||||||
xpathcur = xpath;
|
xpathcur = xpath;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue