aboutsummaryrefslogtreecommitdiffstats
path: root/src/openac
diff options
context:
space:
mode:
Diffstat (limited to 'src/openac')
-rw-r--r--src/openac/Makefile.am4
-rwxr-xr-xsrc/openac/openac.c25
2 files changed, 24 insertions, 5 deletions
diff --git a/src/openac/Makefile.am b/src/openac/Makefile.am
index 1d8c8de9a..433fe51bf 100644
--- a/src/openac/Makefile.am
+++ b/src/openac/Makefile.am
@@ -3,6 +3,8 @@ openac_SOURCES = openac.c
dist_man_MANS = openac.8
INCLUDES = -I$(top_srcdir)/src/libstrongswan
-AM_CFLAGS = -DIPSEC_CONFDIR=\"${confdir}\"
+AM_CFLAGS = -DIPSEC_CONFDIR=\"${confdir}\" \
+ -DIPSEC_DIR=\"${ipsecdir}\" \
+ -DIPSEC_PLUGINDIR=\"${plugindir}\"
openac_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lgmp
diff --git a/src/openac/openac.c b/src/openac/openac.c
index 0b70726e3..1cbda679a 100755
--- a/src/openac/openac.c
+++ b/src/openac/openac.c
@@ -33,6 +33,7 @@
#include <time.h>
#include <gmp.h>
+#include <library.h>
#include <debug.h>
#include <asn1/asn1.h>
#include <asn1/ttodata.h>
@@ -297,14 +298,12 @@ int main(int argc, char **argv)
char *groups = "";
char buf[BUF_LEN];
- chunk_t serial;
chunk_t passphrase = { buf, 0 };
+ chunk_t serial = chunk_empty;
chunk_t attr_chunk = chunk_empty;
int status = 1;
- options_t *options = options_create();
-
/* enable openac debugging hook */
dbg = openac_dbg;
@@ -312,6 +311,13 @@ int main(int argc, char **argv)
openlog("openac", 0, LOG_AUTHPRIV);
+ /* initialize library */
+ library_init(IPSEC_DIR "/strongswan.conf");
+ lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR, "libstrongswan-");
+
+ /* initialize optionsfrom */
+ options_t *options = options_create();
+
/* handle arguments */
for (;;)
{
@@ -568,15 +574,25 @@ int main(int argc, char **argv)
BUILD_SIGNING_CERT, signer_cert,
BUILD_SIGNING_KEY, signer_key,
BUILD_END);
- attr_chunk = attr_cert->get_encoding(attr_cert);
+ if (!attr_cert)
+ {
+ status = 1;
+ goto end;
+ }
/* write the attribute certificate to file */
+ attr_chunk = attr_cert->get_encoding(attr_cert);
if (chunk_write(attr_chunk, outfile, "attribute cert", 0022, TRUE))
{
write_serial(serial);
status = 0;
}
}
+ else
+ {
+ usage("some of the mandatory parameters --usercert --cert --key "
+ "are missing");
+ }
end:
/* delete all dynamically allocated objects */
@@ -589,5 +605,6 @@ end:
closelog();
dbg = dbg_default;
options->destroy(options);
+ library_deinit();
exit(status);
}