* Restconf internal start: fail early if clixon_restconf binary is not found

* If CLICON_BACKEND_RESTCONF_PROCESS is true
This commit is contained in:
Olof hagsand 2021-08-17 10:08:04 +02:00
parent 980718178a
commit 8352e25860
5 changed files with 31 additions and 8 deletions

View file

@ -45,6 +45,7 @@
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <sys/stat.h>
/* cligen */
#include <cligen/cligen.h>
@ -240,12 +241,14 @@ restconf_rpc_wrapper(clicon_handle h,
static int
restconf_pseudo_process_control(clicon_handle h)
{
int retval = -1;
char **argv = NULL;
int i;
int nr;
cbuf *cb = NULL;
char *dir = NULL;
int retval = -1;
char **argv = NULL;
int i;
int nr;
cbuf *cb = NULL;
char *dir = NULL;
char *pgm;
struct stat fstat;
nr = 10;
if ((argv = calloc(nr, sizeof(char *))) == NULL){
@ -269,7 +272,15 @@ restconf_pseudo_process_control(clicon_handle h)
}
}
cprintf(cb, "%s/clixon_restconf", dir);
argv[i++] = cbuf_get(cb);
pgm = cbuf_get(cb);
/* Sanity check: program exists */
if (stat(pgm, &fstat) < 0) {
clicon_err(OE_FATAL, errno, "%s, you may have set CLICON_BACKEND_RESTCONF_PROCESS but clixon_restconf is not found in %s. Try overriding with CLICON_RESTCONF_INSTALLDIR",
pgm,
CLIXON_CONFIG_SBINDIR);
goto done;
}
argv[i++] = pgm;
argv[i++] = "-f";
argv[i++] = clicon_option_str(h, "CLICON_CONFIGFILE");
/* Add debug if backend has debug.