initialize library in openac

This commit is contained in:
Andreas Steffen
2008-03-21 10:42:05 +00:00
parent 754c1c0ef7
commit 3d48f3301a
2 changed files with 24 additions and 5 deletions
+3 -1
View File
@@ -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
+21 -4
View File
@@ -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);
}