summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/radattr
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2014-03-11 20:48:48 +0100
committerYves-Alexis Perez <corsac@debian.org>2014-03-11 20:48:48 +0100
commit15fb7904f4431a6e7c305fd08732458f7f885e7e (patch)
treec93b60ee813af70509f00f34e29ebec311762427 /src/libcharon/plugins/radattr
parent5313d2d78ca150515f7f5eb39801c100690b6b29 (diff)
downloadvyos-strongswan-15fb7904f4431a6e7c305fd08732458f7f885e7e.tar.gz
vyos-strongswan-15fb7904f4431a6e7c305fd08732458f7f885e7e.zip
Imported Upstream version 5.1.2
Diffstat (limited to 'src/libcharon/plugins/radattr')
-rw-r--r--src/libcharon/plugins/radattr/Makefile.in12
-rw-r--r--src/libcharon/plugins/radattr/radattr_listener.c52
2 files changed, 20 insertions, 44 deletions
diff --git a/src/libcharon/plugins/radattr/Makefile.in b/src/libcharon/plugins/radattr/Makefile.in
index c8d8fae1c..bf85d5713 100644
--- a/src/libcharon/plugins/radattr/Makefile.in
+++ b/src/libcharon/plugins/radattr/Makefile.in
@@ -219,8 +219,6 @@ BTLIB = @BTLIB@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
-CHECK_CFLAGS = @CHECK_CFLAGS@
-CHECK_LIBS = @CHECK_LIBS@
COVERAGE_CFLAGS = @COVERAGE_CFLAGS@
COVERAGE_LDFLAGS = @COVERAGE_LDFLAGS@
CPP = @CPP@
@@ -288,6 +286,11 @@ PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PTHREADLIB = @PTHREADLIB@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
RANLIB = @RANLIB@
RTLIB = @RTLIB@
RUBY = @RUBY@
@@ -376,12 +379,16 @@ pcsclite_CFLAGS = @pcsclite_CFLAGS@
pcsclite_LIBS = @pcsclite_LIBS@
pdfdir = @pdfdir@
piddir = @piddir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
pki_plugins = @pki_plugins@
plugindir = @plugindir@
pool_plugins = @pool_plugins@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
random_device = @random_device@
resolv_conf = @resolv_conf@
routing_table = @routing_table@
@@ -396,6 +403,7 @@ soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
starter_plugins = @starter_plugins@
strongswan_conf = @strongswan_conf@
+strongswan_options = @strongswan_options@
sysconfdir = @sysconfdir@
systemdsystemunitdir = @systemdsystemunitdir@
t_plugins = @t_plugins@
diff --git a/src/libcharon/plugins/radattr/radattr_listener.c b/src/libcharon/plugins/radattr/radattr_listener.c
index 5443800e5..aca83aafc 100644
--- a/src/libcharon/plugins/radattr/radattr_listener.c
+++ b/src/libcharon/plugins/radattr/radattr_listener.c
@@ -19,7 +19,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
-#include <sys/mman.h>
#include <errno.h>
#include <daemon.h>
@@ -110,10 +109,7 @@ static void add_radius_attribute(private_radattr_listener_t *this,
identification_t *id;
auth_cfg_t *auth;
char path[PATH_MAX];
- chunk_t data;
- struct stat sb;
- void *addr;
- int fd;
+ chunk_t *data;
auth = ike_sa->get_auth_cfg(ike_sa, TRUE);
id = auth->get(auth, AUTH_RULE_EAP_IDENTITY);
@@ -123,44 +119,16 @@ static void add_radius_attribute(private_radattr_listener_t *this,
}
snprintf(path, sizeof(path), "%s/%Y", this->dir, id);
- fd = open(path, O_RDONLY);
- if (fd != -1)
+ data = chunk_map(path, FALSE);
+ if (data)
{
- if (fstat(fd, &sb) != -1)
+ if (data->len >= 2)
{
- if (sb.st_size <= MAX_ATTR_SIZE)
- {
- addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (addr != MAP_FAILED)
- {
- data = chunk_create(addr, sb.st_size);
- if (data.len >= 2)
- {
- DBG1(DBG_CFG, "adding RADIUS %N attribute",
- radius_attribute_type_names, data.ptr[0]);
- message->add_notify(message, FALSE,
- RADIUS_ATTRIBUTE, data);
- }
- munmap(addr, sb.st_size);
- }
- else
- {
- DBG1(DBG_CFG, "mapping RADIUS attribute '%s' failed: %s",
- path, strerror(errno));
- }
- }
- else
- {
- DBG1(DBG_CFG, "RADIUS attribute '%s' exceeds size limit",
- path);
- }
- }
- else
- {
- DBG1(DBG_CFG, "fstat RADIUS attribute '%s' failed: %s",
- path, strerror(errno));
+ DBG1(DBG_CFG, "adding RADIUS %N attribute",
+ radius_attribute_type_names, data->ptr[0]);
+ message->add_notify(message, FALSE, RADIUS_ATTRIBUTE, *data);
}
- close(fd);
+ chunk_unmap(data);
}
else
{
@@ -212,9 +180,9 @@ radattr_listener_t *radattr_listener_create()
.destroy = _destroy,
},
.dir = lib->settings->get_str(lib->settings,
- "%s.plugins.radattr.dir", NULL, charon->name),
+ "%s.plugins.radattr.dir", NULL, lib->ns),
.mid = lib->settings->get_int(lib->settings,
- "%s.plugins.radattr.message_id", -1, charon->name),
+ "%s.plugins.radattr.message_id", -1, lib->ns),
);
return &this->public;