#include "stroke_socket.h"
+#define _GNU_SOURCE /* for asprintf() */
+#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
{
private_stroke_socket_t *this;
int max_concurrent;
- char *uri;
+ char *uri, *uri_default, *piddir;
INIT(this,
.public = {
max_concurrent = lib->settings->get_int(lib->settings,
"%s.plugins.stroke.max_concurrent", MAX_CONCURRENT_DEFAULT,
lib->ns);
- uri = lib->settings->get_str(lib->settings,
- "%s.plugins.stroke.socket", "unix://" STROKE_SOCKET, lib->ns);
+
+ piddir = lib->settings->get_str(lib->settings, "%s.piddir", IPSEC_PIDDIR,
+ lib->ns);
+ if (asprintf(&uri_default, "unix://%s/" STROKE_SOCKET_NAME, piddir) < 0)
+ {
+ uri_default = strdup("unix://" STROKE_SOCKET);
+ }
+ uri = lib->settings->get_str(lib->settings, "%s.plugins.stroke.socket",
+ uri_default, lib->ns);
this->service = lib->streams->create_service(lib->streams, uri, 10);
+ free(uri_default);
if (!this->service)
{
DBG1(DBG_CFG, "creating stroke socket failed");
/* starter is not called from commandline, and therefore absolutely silent */
msg->output_verbosity = -1;
- if (asprintf(&uri_default, "unix://%s/charon.ctl", piddir) < 0)
+ if (asprintf(&uri_default, "unix://%s/" STROKE_SOCKET_NAME, piddir) < 0)
{
- uri_default = strdup("unix://" IPSEC_PIDDIR "/charon.ctl");
+ uri_default = strdup("unix://" STROKE_SOCKET);
}
uri = lib->settings->get_str(lib->settings, "%s.plugins.stroke.socket",
uri_default, daemon_name);
* for more details.
*/
+#define _GNU_SOURCE /* for asprintf() */
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
static int send_stroke_msg(stroke_msg_t *msg)
{
stream_t *stream;
- char *uri, buffer[512], *pass;
+ char *uri, *uri_default, *piddir, buffer[512], *pass;
int count;
if (msg->length == UINT16_MAX)
msg->output_verbosity = output_verbosity;
+ piddir = lib->settings->get_str(lib->settings, "%s.piddir", IPSEC_PIDDIR,
+ daemon_name);
+ if (asprintf(&uri_default, "unix://%s/" STROKE_SOCKET_NAME, piddir) < 0)
+ {
+ uri_default = strdup("unix://" STROKE_SOCKET);
+ }
uri = lib->settings->get_str(lib->settings, "%s.plugins.stroke.socket",
- "unix://" STROKE_SOCKET, daemon_name);
+ uri_default, daemon_name);
stream = lib->streams->connect(lib->streams, uri);
if (!stream)
{
fprintf(stderr, "failed to connect to stroke socket '%s'\n", uri);
+ free(uri_default);
free(msg);
return -1;
}
+ free(uri_default);
if (!stream->write_all(stream, msg, msg->length))
{
#include <library.h>
/**
- * Socket which is used to communicate between charon and stroke
+ * Socket file which is used to communicate between charon and stroke
*/
-#define STROKE_SOCKET IPSEC_PIDDIR "/charon.ctl"
+#define STROKE_SOCKET_NAME "charon.ctl"
+#define STROKE_SOCKET IPSEC_PIDDIR "/" STROKE_SOCKET_NAME
/**
* Number of bytes by which the buffer is increased as needed