scepclient uses the optionsfrom parser from libstrongswan

This commit is contained in:
Andreas Steffen 2009-04-18 17:43:28 +00:00
parent a6e3ec1389
commit 54c4de63c0
2 changed files with 21 additions and 9 deletions

View File

@ -59,12 +59,14 @@ libstrongswan_la_LIBADD = -lpthread -ldl
libstrongswan_lite_la_SOURCES = \ libstrongswan_lite_la_SOURCES = \
chunk.c chunk.h \ chunk.c chunk.h \
debug.c debug.h \ debug.c debug.h \
asn1/oid.c asn1/oid.h \
printf_hook.c printf_hook.h \ printf_hook.c printf_hook.h \
settings.c settings.h \ settings.c settings.h \
utils.c utils.h \ utils.c utils.h \
asn1/oid.c asn1/oid.h \
utils/enumerator.c utils/enumerator.h \ utils/enumerator.c utils/enumerator.h \
utils/linked_list.c utils/linked_list.h utils/lexparser.c utils/lexparser.h \
utils/linked_list.c utils/linked_list.h \
utils/optionsfrom.c utils/optionsfrom.h
INCLUDES = -I$(top_srcdir)/src/libstrongswan INCLUDES = -I$(top_srcdir)/src/libstrongswan
AM_CFLAGS = -DIPSEC_DIR=\"${ipsecdir}\" \ AM_CFLAGS = -DIPSEC_DIR=\"${ipsecdir}\" \

View File

@ -39,6 +39,7 @@
#include <library.h> #include <library.h>
#include <debug.h> #include <debug.h>
#include <asn1/oid.h> #include <asn1/oid.h>
#include <utils/optionsfrom.h>
#include "../pluto/constants.h" #include "../pluto/constants.h"
#include "../pluto/defs.h" #include "../pluto/defs.h"
@ -113,6 +114,8 @@ long crl_check_interval = 0;
/* by default pluto logs out after every smartcard use */ /* by default pluto logs out after every smartcard use */
bool pkcs11_keep_state = FALSE; bool pkcs11_keep_state = FALSE;
/* options read by optionsfrom */
options_t *options;
/* /*
* Global variables * Global variables
@ -146,6 +149,8 @@ pkcs10_t *pkcs10 = NULL;
static void static void
exit_scepclient(err_t message, ...) exit_scepclient(err_t message, ...)
{ {
int status = 0;
if (private_key != NULL) if (private_key != NULL)
{ {
free_RSA_private_content(private_key); free_RSA_private_content(private_key);
@ -170,8 +175,7 @@ exit_scepclient(err_t message, ...)
free_x509cert(x509_ca_enc); free_x509cert(x509_ca_enc);
free_x509cert(x509_ca_sig); free_x509cert(x509_ca_sig);
pkcs10_free(pkcs10); pkcs10_free(pkcs10);
library_deinit(); options->destroy(options);
close_log();
/* print any error message to stderr */ /* print any error message to stderr */
if (message != NULL && *message != '\0') if (message != NULL && *message != '\0')
@ -184,9 +188,11 @@ exit_scepclient(err_t message, ...)
va_end(args); va_end(args);
fprintf(stderr, "error: %s\n", m); fprintf(stderr, "error: %s\n", m);
exit(-1); status = -1;
} }
exit(0); library_deinit();
close_log();
exit(status);
} }
/** /**
@ -404,7 +410,9 @@ int main(int argc, char **argv)
scep_response = chunk_empty; scep_response = chunk_empty;
log_to_stderr = TRUE; log_to_stderr = TRUE;
/* initialize library and optionsfrom */
library_init(STRONGSWAN_CONF); library_init(STRONGSWAN_CONF);
options = options_create();
for (;;) for (;;)
{ {
@ -553,8 +561,10 @@ int main(int argc, char **argv)
continue; continue;
case '+': /* --optionsfrom <filename> */ case '+': /* --optionsfrom <filename> */
optionsfrom(optarg, &argc, &argv, optind, stderr); if (!options->from(options, optarg, &argc, &argv, optind))
/* does not return on error */ {
exit_scepclient("optionsfrom failed");
}
continue; continue;
case 'k': /* --keylength <length> */ case 'k': /* --keylength <length> */