deprecated readdir_r with readdir
This commit is contained in:
parent
7564bcd9b2
commit
bb6d043d6c
6 changed files with 23 additions and 30 deletions
|
|
@ -103,10 +103,10 @@ You can change where CLixon looks for the configuration FILE as follows:
|
||||||
## Can I run Clixon as docker containers?
|
## Can I run Clixon as docker containers?
|
||||||
|
|
||||||
Yes, the example works as docker containers as well. There should be a
|
Yes, the example works as docker containers as well. There should be a
|
||||||
prepared container in docker hib for the example where the backend and
|
prepared container in docker hub for the example where the backend and
|
||||||
CLI is bundled.
|
CLI is bundled.
|
||||||
```
|
```
|
||||||
sudo docker run -ti --rm olofhagsand/clixon_example
|
sudo docker run -td olofhagsand/clixon_example
|
||||||
```
|
```
|
||||||
Look in the example documentation for more info.
|
Look in the example documentation for more info.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,6 @@ RUN apt-get update && apt-get install -y \
|
||||||
libfcgi-dev \
|
libfcgi-dev \
|
||||||
libcurl4-openssl-dev
|
libcurl4-openssl-dev
|
||||||
|
|
||||||
RUN groupadd clicon
|
|
||||||
|
|
||||||
# Create a directory to hold source-code, dependencies etc
|
# Create a directory to hold source-code, dependencies etc
|
||||||
RUN mkdir /clixon
|
RUN mkdir /clixon
|
||||||
WORKDIR /clixon
|
WORKDIR /clixon
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ distclean: clean
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
sudo docker build -t $(IMAGE) .
|
sudo docker build -t $(IMAGE) .
|
||||||
|
@echo "cd ../example; make docker to build example application"
|
||||||
|
|
||||||
push:
|
push:
|
||||||
sudo docker push $(IMAGE)
|
sudo docker push $(IMAGE)
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,11 @@
|
||||||
FROM olofhagsand/clixon
|
FROM olofhagsand/clixon
|
||||||
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
MAINTAINER Olof Hagsand <olof@hagsand.se>
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
#RUN apt-get update && apt-get install -y procps # ps for debugging
|
||||||
procps # ps for debugging
|
|
||||||
|
# The example uses "clicon" group
|
||||||
|
RUN groupadd clicon
|
||||||
|
|
||||||
# Create a directory to hold source-code, dependencies etc
|
# Create a directory to hold source-code, dependencies etc
|
||||||
RUN mkdir /example
|
RUN mkdir /example
|
||||||
WORKDIR /example
|
WORKDIR /example
|
||||||
|
|
@ -53,7 +56,8 @@ RUN make
|
||||||
RUN make install
|
RUN make install
|
||||||
RUN install example.xml /usr/local/etc/clixon.xml
|
RUN install example.xml /usr/local/etc/clixon.xml
|
||||||
|
|
||||||
CMD /usr/local/sbin/clixon_backend && /usr/local/bin/clixon_cli
|
# Log to stderr. Add -D 1 for debug
|
||||||
|
CMD /usr/local/sbin/clixon_backend -F -a IPv4 -u 0.0.0.0 -s init -l e
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,19 +198,13 @@ The example contains some stubs for authorization according to [RFC8341(NACM)](h
|
||||||
|
|
||||||
Example systemd files for backend and restconf daemons are found under the systemd directory. Install them under /etc/systemd/system for example.
|
Example systemd files for backend and restconf daemons are found under the systemd directory. Install them under /etc/systemd/system for example.
|
||||||
|
|
||||||
## Run as docker container
|
|
||||||
|
|
||||||
(Note not updated)
|
|
||||||
```
|
|
||||||
cd docker
|
|
||||||
# look in README
|
|
||||||
```
|
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
Run the example as a docker container as follows:
|
Run the example as a docker container and access it from a host CLI as follows:
|
||||||
```
|
```
|
||||||
sudo docker run -ti --rm olofhagsand/clixon_example
|
ID=$(sudo docker run -td olofhagsand/clixon_example)
|
||||||
|
IP=$(sudo docker inspect -f '{{.NetworkSettings.IPAddress }}' $ID)
|
||||||
|
clixon_cli -a IPv4 -u $IP -f ./example.xml
|
||||||
```
|
```
|
||||||
|
|
||||||
Build the container and push yourself: First change the IMAGE variable in Makefile (eg to "you/clixon_example). Then build and push:
|
Build the container and push yourself: First change the IMAGE variable in Makefile (eg to "you/clixon_example). Then build and push:
|
||||||
|
|
@ -220,5 +214,9 @@ make push
|
||||||
sudo docker run -ti --rm you/clixon_example
|
sudo docker run -ti --rm you/clixon_example
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that the configuration database is internal in the container, so
|
||||||
|
it is deleted if the container is restarted. To make the configuration
|
||||||
|
database persistent, you need to mount running_db using `-v`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,7 @@ clicon_file_dirent(const char *dir,
|
||||||
char errbuf[128];
|
char errbuf[128];
|
||||||
char filename[MAXPATHLEN];
|
char filename[MAXPATHLEN];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct dirent dent;
|
struct dirent *dent;
|
||||||
struct dirent *dresp;
|
|
||||||
struct dirent *tmp;
|
struct dirent *tmp;
|
||||||
struct dirent *new = NULL;
|
struct dirent *new = NULL;
|
||||||
struct dirent *dvecp = NULL;
|
struct dirent *dvecp = NULL;
|
||||||
|
|
@ -132,22 +131,15 @@ clicon_file_dirent(const char *dir,
|
||||||
clicon_err(OE_UNIX, errno, "opendir(%s)", dir);
|
clicon_err(OE_UNIX, errno, "opendir(%s)", dir);
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
for (res = readdir_r(dirp, &dent, &dresp);
|
while((dent = readdir(dirp)) != NULL) {
|
||||||
dresp;
|
|
||||||
res = readdir_r(dirp, &dent, &dresp)) {
|
|
||||||
if (res != 0) {
|
|
||||||
clicon_err(OE_UNIX, 0, "readdir: %s", strerror(errno));
|
|
||||||
goto quit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Filename matching */
|
/* Filename matching */
|
||||||
if (regexp) {
|
if (regexp) {
|
||||||
if (regexec(&re, dent.d_name, (size_t) 0, NULL, 0) != 0)
|
if (regexec(&re, dent->d_name, (size_t) 0, NULL, 0) != 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* File type matching */
|
/* File type matching */
|
||||||
if (type) {
|
if (type) {
|
||||||
snprintf(filename, MAXPATHLEN-1, "%s/%s", dir, dent.d_name);
|
snprintf(filename, MAXPATHLEN-1, "%s/%s", dir, dent->d_name);
|
||||||
res = lstat(filename, &st);
|
res = lstat(filename, &st);
|
||||||
if (res != 0) {
|
if (res != 0) {
|
||||||
clicon_err(OE_UNIX, 0, "lstat: %s", strerror(errno));
|
clicon_err(OE_UNIX, 0, "lstat: %s", strerror(errno));
|
||||||
|
|
@ -161,7 +153,7 @@ clicon_file_dirent(const char *dir,
|
||||||
goto quit;
|
goto quit;
|
||||||
}
|
}
|
||||||
new = tmp;
|
new = tmp;
|
||||||
memcpy(&new[nent], &dent, sizeof(dent));
|
memcpy(&new[nent], dent, sizeof(*dent));
|
||||||
nent++;
|
nent++;
|
||||||
|
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue