diff --git a/src/libstrongswan/Makefile.am b/src/libstrongswan/Makefile.am index b9c6bac30..ed3a4517e 100644 --- a/src/libstrongswan/Makefile.am +++ b/src/libstrongswan/Makefile.am @@ -59,12 +59,14 @@ libstrongswan_la_LIBADD = -lpthread -ldl libstrongswan_lite_la_SOURCES = \ chunk.c chunk.h \ debug.c debug.h \ -asn1/oid.c asn1/oid.h \ printf_hook.c printf_hook.h \ settings.c settings.h \ utils.c utils.h \ +asn1/oid.c asn1/oid.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 AM_CFLAGS = -DIPSEC_DIR=\"${ipsecdir}\" \ diff --git a/src/scepclient/scepclient.c b/src/scepclient/scepclient.c index 564f1d72e..27882ad63 100644 --- a/src/scepclient/scepclient.c +++ b/src/scepclient/scepclient.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "../pluto/constants.h" #include "../pluto/defs.h" @@ -113,6 +114,8 @@ long crl_check_interval = 0; /* by default pluto logs out after every smartcard use */ bool pkcs11_keep_state = FALSE; +/* options read by optionsfrom */ +options_t *options; /* * Global variables @@ -146,6 +149,8 @@ pkcs10_t *pkcs10 = NULL; static void exit_scepclient(err_t message, ...) { + int status = 0; + if (private_key != NULL) { free_RSA_private_content(private_key); @@ -170,8 +175,7 @@ exit_scepclient(err_t message, ...) free_x509cert(x509_ca_enc); free_x509cert(x509_ca_sig); pkcs10_free(pkcs10); - library_deinit(); - close_log(); + options->destroy(options); /* print any error message to stderr */ if (message != NULL && *message != '\0') @@ -184,9 +188,11 @@ exit_scepclient(err_t message, ...) va_end(args); fprintf(stderr, "error: %s\n", m); - exit(-1); + status = -1; } - exit(0); + library_deinit(); + close_log(); + exit(status); } /** @@ -391,7 +397,7 @@ int main(int argc, char **argv) u_int max_poll_time = 0; err_t ugh = NULL; - + /* initialize global variables */ pkcs1 = chunk_empty; pkcs7 = chunk_empty; @@ -404,7 +410,9 @@ int main(int argc, char **argv) scep_response = chunk_empty; log_to_stderr = TRUE; + /* initialize library and optionsfrom */ library_init(STRONGSWAN_CONF); + options = options_create(); for (;;) { @@ -553,8 +561,10 @@ int main(int argc, char **argv) continue; case '+': /* --optionsfrom */ - optionsfrom(optarg, &argc, &argv, optind, stderr); - /* does not return on error */ + if (!options->from(options, optarg, &argc, &argv, optind)) + { + exit_scepclient("optionsfrom failed"); + } continue; case 'k': /* --keylength */