summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nordberg <linus@sunet.se>2019-07-02 19:40:45 +0200
committerLinus Nordberg <linus@sunet.se>2019-07-02 19:40:45 +0200
commitc576175a46e64a9bb0980cdfde2e376ccdcc5ebf (patch)
treed8ff87cd05c08c4352fe9341f34343b0a256f05c
parent74bf309efefb091dfeedc9c8a452f74e0385e984 (diff)
move path to p11-kit-remote to config
-rw-r--r--p11p-daemon/README.md11
-rw-r--r--p11p-daemon/config/sys.config1
-rw-r--r--p11p-daemon/src/p11p_config.erl10
-rw-r--r--p11p-daemon/src/p11p_remote.erl2
4 files changed, 22 insertions, 2 deletions
diff --git a/p11p-daemon/README.md b/p11p-daemon/README.md
index 0dc38aa..a5e4cea 100644
--- a/p11p-daemon/README.md
+++ b/p11p-daemon/README.md
@@ -1,5 +1,16 @@
# p11p is a PKCS #11 proxy
+## Install dependencies
+
+### p11-kit
+
+ $ git clone https://github.com/p11-glue/p11-kit && cd p11-kit
+ $ sh autogen.sh && ./configure
+ $ make
+ $ sudo make install
+
+Tested with commit 787888e1 (2019-06-19).
+
## Compile
If you don't have rebar3 installed, install it. See
diff --git a/p11p-daemon/config/sys.config b/p11p-daemon/config/sys.config
index bf7a93d..fe5922f 100644
--- a/p11p-daemon/config/sys.config
+++ b/p11p-daemon/config/sys.config
@@ -3,6 +3,7 @@
{p11p,
[
{loglevel, 3},
+ {remotebin_path, "/usr/local/libexec/p11-kit/p11-kit-remote"},
{groups,
[{"vtoken0",
[
diff --git a/p11p-daemon/src/p11p_config.erl b/p11p-daemon/src/p11p_config.erl
index 23b79bb..6c4cfb6 100644
--- a/p11p-daemon/src/p11p_config.erl
+++ b/p11p-daemon/src/p11p_config.erl
@@ -6,7 +6,7 @@
%%-export([config/0]).
-export([nameof/1]).
-export([tokens/0]).
--export([modules_for_token/1, module_path/1, token_mode/1]).
+-export([remotebin_path/0, modules_for_token/1, module_path/1, token_mode/1]).
-export_type([token_mode_t/0]).
%% Genserver callbacks.
@@ -31,6 +31,7 @@
%% Genserver state.
-record(state, {
+ remotebin_path :: string(),
tokens :: #{string() => token()}
}).
@@ -42,6 +43,9 @@ start_link() ->
%% config() ->
%% gen_server:call(?MODULE, config).
+remotebin_path() ->
+ gen_server:call(?MODULE, remotebin_path).
+
-spec tokens() -> [token()].
tokens() ->
gen_server:call(?MODULE, tokens).
@@ -73,6 +77,8 @@ init(_Args) ->
%% handle_call(config, _From, State) ->
%% {reply, State, State};
+handle_call(remotebin_path, _From, #state{remotebin_path = Path} = State) ->
+ {reply, Path, State};
handle_call(tokens, _From, #state{tokens = Tokens} = State) ->
{reply, maps:values(Tokens), State};
handle_call({modules_for_token, TokName}, _, #state{tokens = Tokens} = S) ->
@@ -104,6 +110,8 @@ code_change(_OldVersion, State, _Extra) ->
init_state() ->
#state {
+ remotebin_path = application:get_env(p11p, remotebin_path,
+ "/usr/local/libexec/p11-kit/p11-kit-remote"),
tokens = conf_tokens(application:get_env(p11p, groups, []))
}.
diff --git a/p11p-daemon/src/p11p_remote.erl b/p11p-daemon/src/p11p_remote.erl
index 158b427..86e3471 100644
--- a/p11p-daemon/src/p11p_remote.erl
+++ b/p11p-daemon/src/p11p_remote.erl
@@ -59,7 +59,7 @@ stop(Pid, Reason) ->
%% Genserver callbacks.
init([TokName, ModPath]) ->
- Port = open_port({spawn_executable, ?P11KITREMOTE_PATH},
+ Port = open_port({spawn_executable, p11p_config:remotebin_path()},
[stream, exit_status, {args, [ModPath, "-v"]}]),
lager:debug("~p: ~s: new remote port: ~p", [self(), ?P11KITREMOTE_PATH, Port]),
{ok, #state{port = Port, token = TokName}}.