release of netcf-0.2.3
by Laine Stump
I've just release netcf-0.2.2. There are a few fixes in this release, but the main impetus for releasing was to eliminate a potential segfault in libnl when netcf called a non-threadsafe libnl function:
- eliminate calls to nl_cache_mngt_provide(), to avoid
non-threadsafe code in libnl (and because it isn't needed
anyway) (This non-threadsafe code could lead to a segfault)
(Thomas Graf)
- portability fixes for FreeBSD (Ed Maste)
- fix bug when a config file has two config parameters with
identical names (Hendrik Schwartke)
- add HACKING document (Guido Günther)
- Ignore backup files created by dpkg (Guido Günther)
- always bail immediately if get_augeas fails (doing otherwise
could lead to a segfault) (Laine Stump)
Thanks to everyone for their contributions!
The tarball is available in the usual place:
Tarball:https://fedorahosted.org/released/netcf/netcf-0.2.3.tar.gz
GPG signature[1]:
https://fedorahosted.org/released/netcf/netcf-0.2.3.tar.gz.sig
Laine
[1] To verify the signature, first download both the .sig file and the
corresponding tarball. Then, run a command like this:
gpg --verify netcf-0.2.2.tar.gz.sig
If that command fails because you don't have the required public key,
then run this command to import it:
gpg --keyserver keys.gnupg.net --recv-keys 62D11E4C
and rerun the `gpg --verify' command.
11 years, 4 months
[PATCH] Use POSIX strerror_r for portability.
by emaste@adaranet.com
From: Ed Maste <emaste(a)adaranet.com>
Signed-off-by: Ed Maste <emaste(a)adaranet.com>
---
bootstrap.conf | 1 +
src/dutil_posix.c | 36 +++++++++++++++++++-----------------
src/internal.h | 9 +++++++++
3 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 95a84aa..fd1c8f7 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -37,6 +37,7 @@ sigprocmask
socket
spawn
stddef
+strerror_r-posix
string
sys_ioctl
sys_socket
diff --git a/src/dutil_posix.c b/src/dutil_posix.c
index 609d7bd..115b2bd 100644
--- a/src/dutil_posix.c
+++ b/src/dutil_posix.c
@@ -76,9 +76,10 @@ exec_program(struct netcf *ncf,
/* create a pipe to receive stdout+stderr from child */
if (outfd) {
if (pipe(pipeout) < 0) {
+ strerror_r(errno, errbuf, sizeof(errbuf));
report_error(ncf, NETCF_EEXEC,
"failed to create pipe while forking for '%s': %s",
- commandline, strerror_r(errno, errbuf, sizeof(errbuf)));
+ commandline, errbuf);
goto error;
}
*outfd = pipeout[0];
@@ -90,24 +91,25 @@ exec_program(struct netcf *ncf,
*/
sigfillset(&newmask);
if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) {
+ strerror_r(errno, errbuf, sizeof(errbuf));
report_error(ncf, NETCF_EEXEC,
"failed to set signal mask while forking for '%s': %s",
- commandline, strerror_r(errno, errbuf, sizeof(errbuf)));
+ commandline, errbuf);
goto error;
}
*pid = fork();
- ERR_THROW(*pid < 0, ncf, EEXEC, "failed to fork for '%s': %s",
- commandline, strerror_r(errno, errbuf, sizeof(errbuf)));
+ ERR_THROW_STRERROR(*pid < 0, ncf, EEXEC, "failed to fork for '%s': %s",
+ commandline, errbuf);
if (*pid) { /* parent */
/* Restore our original signal mask now that the child is
safely running */
- ERR_THROW(pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0,
- ncf, EEXEC,
- "failed to restore signal mask while forking for '%s': %s",
- commandline, strerror_r(errno, errbuf, sizeof(errbuf)));
+ ERR_THROW_STRERROR(pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0,
+ ncf, EEXEC,
+ "failed to restore signal mask while forking for '%s': %s",
+ commandline, errbuf);
/* parent doesn't use write side of the pipe */
if (pipeout[1] >= 0)
@@ -208,14 +210,14 @@ int run_program(struct netcf *ncf, const char *const *argv, char **output)
ERR_BAIL(ncf);
outfile = fdopen(outfd, "r");
- ERR_THROW(outfile == NULL, ncf, EEXEC,
- "Failed to create file stream for output while executing '%s': %s",
- argv_str, strerror_r(errno, errbuf, sizeof(errbuf)));
+ ERR_THROW_STRERROR(outfile == NULL, ncf, EEXEC,
+ "Failed to create file stream for output while executing '%s': %s",
+ argv_str, errbuf);
*output = fread_file(outfile, &outlen);
- ERR_THROW(*output == NULL, ncf, EEXEC,
- "Error while reading output from execution of '%s': %s",
- argv_str, strerror_r(errno, errbuf, sizeof(errbuf)));
+ ERR_THROW_STRERROR(*output == NULL, ncf, EEXEC,
+ "Error while reading output from execution of '%s': %s",
+ argv_str, errbuf);
/* finished with the stream. Close it so the child can exit. */
fclose(outfile);
@@ -226,9 +228,9 @@ int run_program(struct netcf *ncf, const char *const *argv, char **output)
/* empty loop */
}
- ERR_THROW(waitret == -1, ncf, EEXEC,
- "Failed waiting for completion of '%s': %s",
- argv_str, strerror_r(errno, errbuf, sizeof(errbuf)));
+ ERR_THROW_STRERROR(waitret == -1, ncf, EEXEC,
+ "Failed waiting for completion of '%s': %s",
+ argv_str, errbuf);
ERR_THROW(!WIFEXITED(exitstatus) && WIFSIGNALED(exitstatus), ncf, EEXEC,
"'%s' terminated by signal: %d",
argv_str, WTERMSIG(exitstatus));
diff --git a/src/internal.h b/src/internal.h
index cca7a46..0354fb7 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -133,6 +133,15 @@
} \
} while(0)
+#define ERR_THROW_STRERROR(cond, ncf, err, fmt ...) \
+ do { \
+ if (cond) { \
+ strerror_r(errno, errbuf, sizeof(errbuf)); \
+ report_error(ncf, NETCF_##err, ## fmt); \
+ goto error; \
+ } \
+ } while(0)
+
/* Clear error code and details */
#define API_ENTRY(ncf) \
do { \
--
1.7.11.5
11 years, 4 months
[PATCH] Remove unnecessary #include
by emaste@adaranet.com
augeas.h is not needed for these functions, and isn't used on FreeBSD.
---
src/dutil_posix.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/dutil_posix.c b/src/dutil_posix.c
index 609d7bd..d2b1889 100644
--- a/src/dutil_posix.c
+++ b/src/dutil_posix.c
@@ -22,7 +22,6 @@
#include <config.h>
#include <internal.h>
-#include <augeas.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
--
1.7.11.5
11 years, 4 months
[PATCH] netlink: Do not provide caches, not needed and only complicates thread safety
by Laine Stump
From: Thomas Graf <tgraf(a)redhat.com>
netcf does not utilize any of the functionality that would require
providing the caches. Doing so only exposes the cache to possibly
unwanted users.
Signed-off-by: Thomas Graf <tgraf(a)redhat.com>
---
src/dutil_linux.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index 1fe9b26..271c515 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -611,12 +611,10 @@ int netlink_init(struct netcf *ncf) {
ncf->driver->link_cache = __rtnl_link_alloc_cache(ncf->driver->nl_sock);
if (ncf->driver->link_cache == NULL)
goto error;
- nl_cache_mngt_provide(ncf->driver->link_cache);
ncf->driver->addr_cache = __rtnl_addr_alloc_cache(ncf->driver->nl_sock);
if (ncf->driver->addr_cache == NULL)
goto error;
- nl_cache_mngt_provide(ncf->driver->addr_cache);
int netlink_fd = nl_socket_get_fd(ncf->driver->nl_sock);
if (netlink_fd >= 0)
--
1.7.11.7
11 years, 4 months