created pluto and scepclient now use libstrongswan-lite

This commit is contained in:
Andreas Steffen
2009-04-18 14:50:31 +00:00
parent 815510e637
commit a6e3ec1389
20 changed files with 216 additions and 141 deletions
+20 -19
View File
@@ -15,17 +15,27 @@ INCLUDES = \
-I$(LIBCRYPTODIR) \
-I$(WHACKDIR)
AM_CFLAGS = -DDEBUG -DNO_PLUTO -DIPSEC_CONFDIR=\"${confdir}\"
AM_CFLAGS = \
-DIPSEC_CONFDIR=\"${confdir}\" \
-DSTRONGSWAN_CONF=\"${strongswan_conf}\" \
-DDEBUG -DNO_PLUTO
LIBFREESWANBUILDDIR=$(top_builddir)/src/libfreeswan
LIBCRYPTOBUILDDIR=$(top_builddir)/src/libcrypto
scepclient_LDADD = debug.o utils.o chunk.o \
asn1.o ca.o crl.o certs.o constants.o defs.o fetch.o id.o \
keys.o lex.o md2.o md5.o mp_defs.o ocsp.o oid.o pem.o pgp.o \
pkcs1.o pkcs7.o rnd.o sha1.o smartcard.o x509.o \
$(LIBFREESWANBUILDDIR)/libfreeswan.a $(LIBCRYPTOBUILDDIR)/libcrypto.a \
-lgmp
scepclient_LDADD = \
asn1.o ca.o crl.o certs.o constants.o defs.o fetch.o id.o keys.o \
lex.o library.o md2.o md5.o mp_defs.o ocsp.o pem.o pgp.o pkcs1.o \
pkcs7.o rnd.o sha1.o smartcard.o x509.o \
$(LIBSTRONGSWANDIR)/libstrongswan-lite.la \
$(LIBFREESWANBUILDDIR)/libfreeswan.a \
$(LIBCRYPTOBUILDDIR)/libcrypto.a \
-lgmp
# This compile option activates the memory leak detective
if USE_LEAK_DETECTIVE
AM_CFLAGS += -DLEAK_DETECTIVE
endif
# This compile option activates smartcard support
if USE_SMARTCARD
@@ -41,15 +51,6 @@ endif
dist_man_MANS = scepclient.8
debug.o : $(LIBSTRONGSWANDIR)/debug.c $(LIBSTRONGSWANDIR)/debug.h
$(COMPILE) -c -o $@ $<
utils.o : $(LIBSTRONGSWANDIR)/utils.c $(LIBSTRONGSWANDIR)/utils.h
$(COMPILE) -c -o $@ $<
chunk.o : $(LIBSTRONGSWANDIR)/chunk.c $(LIBSTRONGSWANDIR)/chunk.h
$(COMPILE) -c -o $@ $<
asn1.o : $(PLUTODIR)/asn1.c $(PLUTODIR)/asn1.h
$(COMPILE) $(INCLUDES) -c -o $@ $<
@@ -83,6 +84,9 @@ keys.o : $(PLUTODIR)/keys.c $(PLUTODIR)/keys.h
lex.o : $(PLUTODIR)/lex.c $(PLUTODIR)/lex.h
$(COMPILE) $(INCLUDES) -c -o $@ $<
library.o : $(PLUTODIR)/library.c $(PLUTODIR)/library.h
$(COMPILE) $(INCLUDES) -c -o $@ $<
md2.o : $(PLUTODIR)/md2.c $(PLUTODIR)/md2.h
$(COMPILE) $(INCLUDES) -c -o $@ $<
@@ -92,9 +96,6 @@ md5.o : $(PLUTODIR)/md5.c $(PLUTODIR)/md5.h
ocsp.o : $(PLUTODIR)/ocsp.c $(PLUTODIR)/ocsp.h
$(COMPILE) $(INCLUDES) -c -o $@ $<
oid.o : $(LIBSTRONGSWANDIR)/asn1/oid.c $(LIBSTRONGSWANDIR)/asn1/oid.h
$(COMPILE) -c -o $@ $<
pem.o : $(PLUTODIR)/pem.c $(PLUTODIR)/pem.h
$(COMPILE) $(INCLUDES) -c -o $@ $<
+50
View File
@@ -27,6 +27,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <string.h>
#include <getopt.h>
#include <ctype.h>
@@ -35,6 +36,8 @@
#include <gmp.h>
#include <freeswan.h>
#include <library.h>
#include <debug.h>
#include <asn1/oid.h>
#include "../pluto/constants.h"
@@ -167,6 +170,7 @@ exit_scepclient(err_t message, ...)
free_x509cert(x509_ca_enc);
free_x509cert(x509_ca_sig);
pkcs10_free(pkcs10);
library_deinit();
close_log();
/* print any error message to stderr */
@@ -262,6 +266,47 @@ usage(const char *message)
exit_scepclient(message);
}
static int debug_level = 1;
/**
* @brief scepclient dbg function
*/
static void scepclient_dbg(int level, char *fmt, ...)
{
int priority = LOG_INFO;
char buffer[8192];
char *current = buffer, *next;
va_list args;
if (level <= debug_level)
{
va_start(args, fmt);
if (log_to_stderr)
{
vfprintf(stderr, fmt, args);
fprintf(stderr, "\n");
}
if (log_to_syslog)
{
/* write in memory buffer first */
vsnprintf(buffer, sizeof(buffer), fmt, args);
/* do a syslog with every line */
while (current)
{
next = strchr(current, '\n');
if (next)
{
*(next++) = '\0';
}
syslog(priority, "%s\n", current);
current = next;
}
}
va_end(args);
}
}
/**
* @brief main of scepclient
*
@@ -359,6 +404,8 @@ int main(int argc, char **argv)
scep_response = chunk_empty;
log_to_stderr = TRUE;
library_init(STRONGSWAN_CONF);
for (;;)
{
static const struct option long_opts[] = {
@@ -706,6 +753,9 @@ int main(int argc, char **argv)
break;
}
/* enable scepclient bugging hook */
dbg = scepclient_dbg;
init_log("scepclient");
cur_debugging = base_debugging;
init_rnd_pool();