Restconf http-data server updates

Check data paths for .., ~ and soft links
Changed semantics of `CLICON_HTTP_DATA_PATH` and `_ROOT`
Change URI catch-all to 404 instead of 400
Fixed some memory leaks
This commit is contained in:
Olof hagsand 2022-04-24 09:44:27 +02:00
parent 0ed8b836b1
commit 84d88c8ad8
12 changed files with 303 additions and 106 deletions

View file

@ -78,18 +78,23 @@
int
api_path_is_restconf(clicon_handle h)
{
char *path;
int retval = 0;
char *path = NULL;
char *restconf_path = RESTCONF_API;
if ((path = restconf_uripath(h)) == NULL)
return 0;
goto done;
if (strlen(path) < 1 + strlen(restconf_path)) /* "/" + restconf */
return 0;
goto done;
if (path[0] != '/')
return 0;
goto done;
if (strncmp(path+1, restconf_path, strlen(restconf_path)) != 0)
return 0;
return 1;
goto done;
retval = 1;
done:
if (path)
free(path);
return retval;
}
/*! Determine the root of the RESTCONF API by accessing /.well-known