summaryrefslogtreecommitdiff
path: root/src/checksum
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-11-28 11:42:20 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-11-28 11:42:20 +0000
commitf73fba54dc8b30c6482e1e8abf15bbf455592fcd (patch)
treea449515607c5e51a5c703d7a9b1149c9e4a11560 /src/checksum
parentb8064f4099997a9e2179f3ad4ace605f5ccac3a1 (diff)
downloadvyos-strongswan-f73fba54dc8b30c6482e1e8abf15bbf455592fcd.tar.gz
vyos-strongswan-f73fba54dc8b30c6482e1e8abf15bbf455592fcd.zip
[svn-upgrade] new version strongswan (4.5.0)
Diffstat (limited to 'src/checksum')
-rw-r--r--src/checksum/Makefile.am12
-rw-r--r--src/checksum/Makefile.in31
-rw-r--r--src/checksum/checksum_builder.c205
3 files changed, 137 insertions, 111 deletions
diff --git a/src/checksum/Makefile.am b/src/checksum/Makefile.am
index ad2923799..3aded1d9e 100644
--- a/src/checksum/Makefile.am
+++ b/src/checksum/Makefile.am
@@ -14,13 +14,13 @@ checksum_builder_LDADD = \
BUILT_SOURCES = checksum.c
CLEANFILES = checksum.c
INCLUDES = -I$(top_srcdir)/src/libstrongswan
-AM_CFLAGS = -rdynamic
+AM_CFLAGS = -rdynamic \
+ -DS_PLUGINS=\""${s_plugins}\"" -DS_PATH=\""${top_builddir}/src/libstrongswan/plugins\"" \
+ -DH_PLUGINS=\""${h_plugins}\"" -DH_PATH=\""${top_builddir}/src/libhydra/plugins\"" \
+ -DP_PLUGINS=\""${p_plugins}\"" -DP_PATH=\""${top_builddir}/src/pluto/plugins\"" \
+ -DC_PLUGINS=\""${c_plugins}\"" -DC_PATH=\""${top_builddir}/src/libcharon/plugins\""
-libs = $(shell find $(top_builddir)/src/libstrongswan \
- $(top_builddir)/src/libcharon \
- $(top_builddir)/src/libhydra \
- $(top_builddir)/src/pluto \
- -name 'libstrongswan*.so')
+libs = $(top_builddir)/src/libstrongswan/.libs/libstrongswan.so
if USE_LIBHYDRA
libs += $(top_builddir)/src/libhydra/.libs/libhydra.so
diff --git a/src/checksum/Makefile.in b/src/checksum/Makefile.in
index 05e90a9a1..61bfc1a9d 100644
--- a/src/checksum/Makefile.in
+++ b/src/checksum/Makefile.in
@@ -55,6 +55,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/config/libtool.m4 \
$(top_srcdir)/m4/config/lt~obsolete.m4 \
$(top_srcdir)/m4/macros/with.m4 \
$(top_srcdir)/m4/macros/enable-disable.m4 \
+ $(top_srcdir)/m4/macros/add-plugin.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@@ -182,6 +183,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PTHREADLIB = @PTHREADLIB@
RANLIB = @RANLIB@
RTLIB = @RTLIB@
@@ -213,14 +216,17 @@ build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
+c_plugins = @c_plugins@
datadir = @datadir@
datarootdir = @datarootdir@
+dbusservicedir = @dbusservicedir@
default_pkcs11 = @default_pkcs11@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
gtk_CFLAGS = @gtk_CFLAGS@
gtk_LIBS = @gtk_LIBS@
+h_plugins = @h_plugins@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -235,24 +241,31 @@ ipsecgid = @ipsecgid@
ipsecgroup = @ipsecgroup@
ipsecuid = @ipsecuid@
ipsecuser = @ipsecuser@
+libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
libexecdir = @libexecdir@
-libhydra_plugins = @libhydra_plugins@
-libstrongswan_plugins = @libstrongswan_plugins@
linux_headers = @linux_headers@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
+maemo_CFLAGS = @maemo_CFLAGS@
+maemo_LIBS = @maemo_LIBS@
+manager_plugins = @manager_plugins@
mandir = @mandir@
+medsrv_plugins = @medsrv_plugins@
mkdir_p = @mkdir_p@
nm_CFLAGS = @nm_CFLAGS@
nm_LIBS = @nm_LIBS@
nm_ca_dir = @nm_ca_dir@
oldincludedir = @oldincludedir@
+openac_plugins = @openac_plugins@
+p_plugins = @p_plugins@
pdfdir = @pdfdir@
piddir = @piddir@
+pki_plugins = @pki_plugins@
plugindir = @plugindir@
pluto_plugins = @pluto_plugins@
+pool_plugins = @pool_plugins@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
@@ -260,7 +273,10 @@ random_device = @random_device@
resolv_conf = @resolv_conf@
routing_table = @routing_table@
routing_table_prio = @routing_table_prio@
+s_plugins = @s_plugins@
sbindir = @sbindir@
+scepclient_plugins = @scepclient_plugins@
+scripts_plugins = @scripts_plugins@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
strongswan_conf = @strongswan_conf@
@@ -285,10 +301,13 @@ checksum_builder_LDADD = \
BUILT_SOURCES = checksum.c
CLEANFILES = checksum.c
INCLUDES = -I$(top_srcdir)/src/libstrongswan
-AM_CFLAGS = -rdynamic
-libs = $(shell find $(top_builddir)/src/libstrongswan \
- $(top_builddir)/src/libcharon $(top_builddir)/src/libhydra \
- $(top_builddir)/src/pluto -name 'libstrongswan*.so') \
+AM_CFLAGS = -rdynamic \
+ -DS_PLUGINS=\""${s_plugins}\"" -DS_PATH=\""${top_builddir}/src/libstrongswan/plugins\"" \
+ -DH_PLUGINS=\""${h_plugins}\"" -DH_PATH=\""${top_builddir}/src/libhydra/plugins\"" \
+ -DP_PLUGINS=\""${p_plugins}\"" -DP_PATH=\""${top_builddir}/src/pluto/plugins\"" \
+ -DC_PLUGINS=\""${c_plugins}\"" -DC_PATH=\""${top_builddir}/src/libcharon/plugins\""
+
+libs = $(top_builddir)/src/libstrongswan/.libs/libstrongswan.so \
$(am__append_1) $(am__append_2) $(am__append_3) \
$(am__append_4) $(am__append_5)
all: $(BUILT_SOURCES)
diff --git a/src/checksum/checksum_builder.c b/src/checksum/checksum_builder.c
index 2db68054e..dc1de99c3 100644
--- a/src/checksum/checksum_builder.c
+++ b/src/checksum/checksum_builder.c
@@ -19,14 +19,113 @@
#include <dlfcn.h>
#include <library.h>
+#include <utils/enumerator.h>
/* we need to fake the pluto symbol to dlopen() the xauth plugin */
void *pluto;
+/**
+ * Integrity checker
+ */
+integrity_checker_t *integrity;
+
+/**
+ * Create the checksum of a binary, using name and a symbol name
+ */
+static void build_checksum(char *path, char *name, char *sname)
+{
+ void *handle, *symbol;
+ u_int32_t fsum, ssum;
+ size_t fsize = 0;
+ size_t ssize = 0;
+
+ fsum = integrity->build_file(integrity, path, &fsize);
+ ssum = 0;
+ if (sname)
+ {
+ handle = dlopen(path, RTLD_LAZY);
+ if (handle)
+ {
+ symbol = dlsym(handle, sname);
+ if (symbol)
+ {
+ ssum = integrity->build_segment(integrity, symbol, &ssize);
+ }
+ else
+ {
+ fprintf(stderr, "symbol lookup failed: %s\n", dlerror());
+ }
+ dlclose(handle);
+ }
+ else
+ {
+ fprintf(stderr, "dlopen failed: %s\n", dlerror());
+ }
+ }
+ printf("\t{\"%-20s%7u, 0x%08x, %6u, 0x%08x},\n",
+ name, fsize, fsum, ssize, ssum);
+ fprintf(stderr, "\"%-20s%7u / 0x%08x %6u / 0x%08x\n",
+ name, fsize, fsum, ssize, ssum);
+}
+
+/**
+ * Build checksums for a set of plugins in a given path prefix
+ */
+static void build_plugin_checksums(char *plugins, char *prefix)
+{
+ enumerator_t *enumerator;
+ char *plugin, path[256], under[128], sname[128], name[128];
+
+ enumerator = enumerator_create_token(plugins, " ", " ");
+ while (enumerator->enumerate(enumerator, &plugin))
+ {
+ snprintf(under, sizeof(under), "%s", plugin);
+ translate(under, "-", "_");
+ snprintf(path, sizeof(path), "%s/%s/.libs/libstrongswan-%s.so",
+ prefix, under, plugin);
+ snprintf(sname, sizeof(sname), "%s_plugin_create", under);
+ snprintf(name, sizeof(name), "%s\",", plugin);
+ build_checksum(path, name, sname);
+ }
+ enumerator->destroy(enumerator);
+}
+
+/**
+ * Build checksums for a binary/library found at path
+ */
+static void build_binary_checksum(char *path)
+{
+ char *binary, *pos, name[128], sname[128];
+
+ binary = strrchr(path, '/');
+ if (binary)
+ {
+ binary++;
+ pos = strrchr(binary, '.');
+ if (pos && streq(pos, ".so"))
+ {
+ snprintf(name, sizeof(name), "%.*s\",", pos - binary, binary);
+ if (streq(name, "libstrongswan\","))
+ {
+ snprintf(sname, sizeof(sname), "%s", "library_init");
+ }
+ else
+ {
+ snprintf(sname, sizeof(sname), "%.*s_init", pos - binary, binary);
+ }
+ build_checksum(path, name, sname);
+ }
+ else
+ {
+ snprintf(name, sizeof(name), "%s\",", binary);
+ build_checksum(path, name, NULL);
+ }
+ }
+}
+
int main(int argc, char* argv[])
{
int i;
- integrity_checker_t *integrity;
/* avoid confusing leak reports in build process */
setenv("LEAK_DETECTIVE_DISABLE", "1", 0);
@@ -47,105 +146,13 @@ int main(int argc, char* argv[])
fprintf(stderr, "module name, file size / checksum segment size / checksum\n");
for (i = 1; i < argc; i++)
{
- char *name, *path, *sname = NULL;
- void *handle, *symbol;
- u_int32_t fsum, ssum;
- size_t fsize = 0;
- size_t ssize = 0;
-
- path = argv[i];
-
- if ((name = strstr(path, "libstrongswan-")))
- {
- name = strdup(name + strlen("libstrongswan-"));
- name[strlen(name) - 3] = '"';
- name[strlen(name) - 2] = ',';
- name[strlen(name) - 1] = '\0';
- if (asprintf(&sname, "%.*s_plugin_create", strlen(name) - 2,
- name) < 0)
- {
- fprintf(stderr, "failed to format plugin constructor "
- "for '%s', ignored", path);
- free(name);
- continue;
- }
- translate(sname, "-", "_");
- }
- else if (strstr(path, "libstrongswan.so"))
- {
- name = strdup("libstrongswan\",");
- sname = strdup("library_init");
- }
- else if (strstr(path, "libhydra.so"))
- {
- name = strdup("libhydra\",");
- sname = strdup("libhydra_init");
- }
- else if (strstr(path, "libcharon.so"))
- {
- name = strdup("libcharon\",");
- sname = strdup("libcharon_init");
- }
- else if (strstr(path, "pool"))
- {
- name = strdup("pool\",");
- }
- else if (strstr(path, "charon"))
- {
- name = strdup("charon\",");
- }
- else if (strstr(path, "pluto"))
- {
- name = strdup("pluto\",");
- }
- else if (strstr(path, "openac"))
- {
- name = strdup("openac\",");
- }
- else if (strstr(path, "scepclient"))
- {
- name = strdup("scepclient\",");
- }
- else if (strstr(path, "pki"))
- {
- name = strdup("pki\",");
- }
- else
- {
- fprintf(stderr, "don't know how to handle '%s', ignored", path);
- continue;
- }
-
- fsum = integrity->build_file(integrity, path, &fsize);
- ssum = 0;
- if (sname)
- {
- handle = dlopen(path, RTLD_LAZY);
- if (handle)
- {
- symbol = dlsym(handle, sname);
- if (symbol)
- {
- ssum = integrity->build_segment(integrity, symbol, &ssize);
- }
- else
- {
- fprintf(stderr, "symbol lookup failed: %s\n", dlerror());
- }
- dlclose(handle);
- }
- else
- {
- fprintf(stderr, "dlopen failed: %s\n", dlerror());
- }
- }
- printf("\t{\"%-20s%7u, 0x%08x, %6u, 0x%08x},\n",
- name, fsize, fsum, ssize, ssum);
- fprintf(stderr, "\"%-20s%7u / 0x%08x %6u / 0x%08x\n",
- name, fsize, fsum, ssize, ssum);
- free(sname);
- free(name);
+ build_binary_checksum(argv[i]);
}
+ build_plugin_checksums(S_PLUGINS, S_PATH);
+ build_plugin_checksums(H_PLUGINS, H_PATH);
+ build_plugin_checksums(P_PLUGINS, P_PATH);
+ build_plugin_checksums(C_PLUGINS, C_PATH);
+
printf("};\n");
printf("\n");
printf("int checksum_count = countof(checksums);\n");