From 6e90bceab4a3a6e4b9d4496b810324867d533ce1 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Mon, 24 Jun 2019 16:02:40 +0200 Subject: include unix pid in socket name --- p11p-daemon/README.md | 5 +++-- p11p-daemon/src/p11p_server_sup.erl | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'p11p-daemon') diff --git a/p11p-daemon/README.md b/p11p-daemon/README.md index d228faf..ab199d9 100644 --- a/p11p-daemon/README.md +++ b/p11p-daemon/README.md @@ -20,7 +20,8 @@ To start an Erlang shell running the p11p application: $ make shell -A socket file per configured token can now be found in /run/user/$UID/p11p/. +A socket file per configured token /run/user/$EUID/p11p/$TOKEN-$PID +can now be used by a client. Example during debug phase: - $ echo foo | socat - UNIX-CONNECT:/run/user/1000/p11p/vtoken0 + $ echo foo | socat - UNIX-CONNECT:/run/user/1000/p11p/vtoken1-23484 ok, thanks: foo diff --git a/p11p-daemon/src/p11p_server_sup.erl b/p11p-daemon/src/p11p_server_sup.erl index 15398bc..924123b 100644 --- a/p11p-daemon/src/p11p_server_sup.erl +++ b/p11p-daemon/src/p11p_server_sup.erl @@ -26,7 +26,9 @@ start_server() -> %% Private functions. mkdir_socket_basepath() -> - Path = "/run/user/1000/p11p", + %%"/run/user/$UNIXUID/p11p/$TokenCfg-$UNIXPID" + EUID = "1000", % FIXME: get euid + Path = "/run/user/" ++ EUID ++ "/p11p/", ok = case file:make_dir(Path) of ok -> ok; {error, eexist} -> ok; @@ -38,5 +40,4 @@ mkdir_socket_basepath() -> -spec socket_path(string(), string()) -> string(). socket_path(BasePath, Name) -> - %%"/run/user/$UID/p11p/$TokenCfg-$UNIXPID" - BasePath ++ "/" ++ Name. + BasePath ++ Name ++ "-" ++ os:getpid(). % FIXME: filename(3erl) -- cgit v1.1