Fixed: SEGV when starting FCGI restconf program

- Reverted removal of CLICON_RESTCONF_PATH since it was used there
Misc fixes: initialized variables, docs, removed obsolete --enable-optyang
This commit is contained in:
Olof hagsand 2021-12-30 15:57:43 +01:00
parent 3117332ddd
commit 1808015cf6
8 changed files with 36 additions and 12 deletions

View file

@ -61,7 +61,6 @@ Users may have to change how they access the system
* Imported (as a sub-spec): clixon-clispec.yang * Imported (as a sub-spec): clixon-clispec.yang
* Removed obsolete options: * Removed obsolete options:
* `CLICON_YANG_LIST_CHECK` * `CLICON_YANG_LIST_CHECK`
* `CLICON_RESTCONF_PATH` (moved to restconf/fcgi-path)
* Fixed: Configure option `CLICON_RESTCONF_PRETTY` was marked as obsolete but was still used. * Fixed: Configure option `CLICON_RESTCONF_PRETTY` was marked as obsolete but was still used.
* `CLICON_RESTCONF_PRETTY` is now obsolete for sure * `CLICON_RESTCONF_PRETTY` is now obsolete for sure
* Instead restconf/pretty is used with API function restconf_pretty_get() * Instead restconf/pretty is used with API function restconf_pretty_get()

View file

@ -211,7 +211,7 @@ main(int argc,
FCGX_Request request; FCGX_Request request;
FCGX_Request *req = &request; FCGX_Request *req = &request;
int c; int c;
char *sockpath; char *sockpath = NULL;
char *path; char *path;
clicon_handle h; clicon_handle h;
char *dir; char *dir;
@ -523,6 +523,17 @@ main(int argc,
clicon_err(OE_DAEMON, EFAULT, "Restconf daemon config not found or disabled"); clicon_err(OE_DAEMON, EFAULT, "Restconf daemon config not found or disabled");
goto done; goto done;
} }
/* XXX see restconf_config_init access directly */
if ((sockpath = clicon_option_str(h, "CLICON_RESTCONF_PATH")) == NULL){
clicon_err(OE_CFG, errno, "No CLICON_RESTCONF_PATH in clixon configure file");
goto done;
}
/* XXX CLICON_RESTCONF_PATH is marked as obsolete and should use
* fcgi-socket in clixon-restconf.yang instead */
if ((sockpath = clicon_option_str(h, "CLICON_RESTCONF_PATH")) == NULL){
clicon_err(OE_CFG, errno, "No CLICON_RESTCONF_PATH in clixon configure file");
goto done;
}
if (FCGX_Init() != 0){ /* How to cleanup memory after this? */ if (FCGX_Init() != 0){ /* How to cleanup memory after this? */
clicon_err(OE_CFG, errno, "FCGX_Init"); clicon_err(OE_CFG, errno, "FCGX_Init");
goto done; goto done;

View file

@ -106,6 +106,13 @@ Use `/* */`. Use `//` only for temporal comments.
Do not use "======", ">>>>>" or "<<<<<<" in comments since git merge conflict uses that. Do not use "======", ">>>>>" or "<<<<<<" in comments since git merge conflict uses that.
### Format ints
Use:
- %zu for size_t
- PRIu64 for uint64
- %p for pointers
## How to work in git ## How to work in git
Clixon uses semantic versioning (https://semver.org). Clixon uses semantic versioning (https://semver.org).

View file

@ -53,11 +53,8 @@ typedef void *clicon_handle;
typedef void *plghndl_t; typedef void *plghndl_t;
/*! Indirect output functions to print with something else than fprintf /*! Indirect output functions to print with something else than fprintf
* @param[in] h Clicon handle *
* @param[in] xn Request: <rpc><xn></rpc> * @see man fprintf
* @param[out] cbret Return xml tree, eg <rpc-reply>..., <rpc-error..
* @param[in] arg Domain specific arg, ec client-entry or FCGX_Request
* @param[in] regarg User argument given at rpc_callback_register()
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
*/ */

View file

@ -10,7 +10,7 @@ fi
restconf=$1 restconf=$1
if [ $(uname) = "FreeBSD" ]; then if [ $(uname) = "FreeBSD" ]; then
./configure --with-cligen=/usr/local --enable-optyangs --with-restconf=$restconf ./configure --with-cligen=/usr/local --with-restconf=$restconf
else else
./configure --enable-optyangs --with-restconf=$restconf ./configure --with-restconf=$restconf
fi fi

View file

@ -63,10 +63,10 @@ cd src/clixon
git pull origin master git pull origin master
if [ $release = "freebsd" ]; then if [ $release = "freebsd" ]; then
LDFLAGS=-L/usr/local/lib ./configure --with-cligen=/usr/local --enable-optyangs --with-restconf=${with_restconf} LDFLAGS=-L/usr/local/lib ./configure --with-cligen=/usr/local --with-restconf=${with_restconf}
else else
# Problems with su not having "sbin" in path on centos when when we run tests later # Problems with su not having "sbin" in path on centos when when we run tests later
./configure --sbindir=/usr/sbin --libdir=/usr/lib --enable-optyangs --with-restconf=${with_restconf} ./configure --sbindir=/usr/sbin --libdir=/usr/lib --with-restconf=${with_restconf}
fi fi
$MAKE clean $MAKE clean
$MAKE -j10 $MAKE -j10

View file

@ -116,6 +116,7 @@ regex_posix(char *regexp,
fprintf(stderr, "pattern too long\n"); fprintf(stderr, "pattern too long\n");
return -1; return -1;
} }
/* note following two lines trigger [-Wstringop-truncation] warnings, but see no actual error */
strncpy(pattern, "^(", 2); strncpy(pattern, "^(", 2);
strncpy(pattern+2, posix, sizeof(pattern)-2); strncpy(pattern+2, posix, sizeof(pattern)-2);
strncat(pattern, ")$", sizeof(pattern)-len0-1); strncat(pattern, ")$", sizeof(pattern)-len0-1);

View file

@ -53,7 +53,6 @@ module clixon-config {
clixon-clispec.yang clixon-clispec.yang
Removed obsolete options: Removed obsolete options:
CLICON_YANG_LIST_CHECK CLICON_YANG_LIST_CHECK
CLICON_RESTCONF_PATH
Released in Clixon 5.5"; Released in Clixon 5.5";
} }
revision 2021-11-11 { revision 2021-11-11 {
@ -472,6 +471,16 @@ module clixon-config {
only loading from startup but may occur in other circumstances as well. This only loading from startup but may occur in other circumstances as well. This
means that sanity checks of erroneous XML/JSON may not be properly signalled."; means that sanity checks of erroneous XML/JSON may not be properly signalled.";
} }
leaf CLICON_RESTCONF_PATH {
type string;
default "/www-data/fastcgi_restconf.sock";
description
"FastCGI unix socket. Should be specified in webserver
Eg in nginx: fastcgi_pass unix:/www-data/clicon_restconf.sock
Only if with-restconf=fcgi, NOT native
Note: Obsolete, use fcgi-socket in clixon-restconf.yang instead";
status obsolete;
}
leaf CLICON_BACKEND_DIR { leaf CLICON_BACKEND_DIR {
type string; type string;
description description