initialize library in openac
This commit is contained in:
@@ -3,6 +3,8 @@ openac_SOURCES = openac.c
|
|||||||
dist_man_MANS = openac.8
|
dist_man_MANS = openac.8
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/src/libstrongswan
|
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
|
openac_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la -lgmp
|
||||||
|
|
||||||
|
|||||||
+21
-4
@@ -33,6 +33,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <gmp.h>
|
#include <gmp.h>
|
||||||
|
|
||||||
|
#include <library.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <asn1/asn1.h>
|
#include <asn1/asn1.h>
|
||||||
#include <asn1/ttodata.h>
|
#include <asn1/ttodata.h>
|
||||||
@@ -297,14 +298,12 @@ int main(int argc, char **argv)
|
|||||||
char *groups = "";
|
char *groups = "";
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
|
|
||||||
chunk_t serial;
|
|
||||||
chunk_t passphrase = { buf, 0 };
|
chunk_t passphrase = { buf, 0 };
|
||||||
|
chunk_t serial = chunk_empty;
|
||||||
chunk_t attr_chunk = chunk_empty;
|
chunk_t attr_chunk = chunk_empty;
|
||||||
|
|
||||||
int status = 1;
|
int status = 1;
|
||||||
|
|
||||||
options_t *options = options_create();
|
|
||||||
|
|
||||||
/* enable openac debugging hook */
|
/* enable openac debugging hook */
|
||||||
dbg = openac_dbg;
|
dbg = openac_dbg;
|
||||||
|
|
||||||
@@ -312,6 +311,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
openlog("openac", 0, LOG_AUTHPRIV);
|
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 */
|
/* handle arguments */
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -568,15 +574,25 @@ int main(int argc, char **argv)
|
|||||||
BUILD_SIGNING_CERT, signer_cert,
|
BUILD_SIGNING_CERT, signer_cert,
|
||||||
BUILD_SIGNING_KEY, signer_key,
|
BUILD_SIGNING_KEY, signer_key,
|
||||||
BUILD_END);
|
BUILD_END);
|
||||||
attr_chunk = attr_cert->get_encoding(attr_cert);
|
if (!attr_cert)
|
||||||
|
{
|
||||||
|
status = 1;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
/* write the attribute certificate to file */
|
/* write the attribute certificate to file */
|
||||||
|
attr_chunk = attr_cert->get_encoding(attr_cert);
|
||||||
if (chunk_write(attr_chunk, outfile, "attribute cert", 0022, TRUE))
|
if (chunk_write(attr_chunk, outfile, "attribute cert", 0022, TRUE))
|
||||||
{
|
{
|
||||||
write_serial(serial);
|
write_serial(serial);
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
usage("some of the mandatory parameters --usercert --cert --key "
|
||||||
|
"are missing");
|
||||||
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
/* delete all dynamically allocated objects */
|
/* delete all dynamically allocated objects */
|
||||||
@@ -589,5 +605,6 @@ end:
|
|||||||
closelog();
|
closelog();
|
||||||
dbg = dbg_default;
|
dbg = dbg_default;
|
||||||
options->destroy(options);
|
options->destroy(options);
|
||||||
|
library_deinit();
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user