diff --git a/src/systemd.erl b/src/systemd.erl index d07747d..b1c4afd 100644 --- a/src/systemd.erl +++ b/src/systemd.erl @@ -59,7 +59,8 @@ store_fds/1, clear_fds/1, booted/0, - is_journal/1 + is_journal/1, + credentials/1 ]). -export([notify_spawn/2]). @@ -403,6 +404,25 @@ file_info(_) -> %% ---------------------------------------------------------------------------- +%% @doc +%% Returns path for credentials file. +%% +%% Returns `error' when there is no `$CREDENTIALS_DIRECTORY' environment +%% variable, `{ok, Path}' otherwise. +%% +%% For details see [https://systemd.io/CREDENTIALS/] +%% +%% @since 0.7.0 +%% @end +credentials(Name) -> + case os:getenv("CREDENTIALS_DIRECTORY") of + false -> error; + Dir -> + {ok, filename:join(Dir, Name)} + end. + +%% ---------------------------------------------------------------------------- + %% @doc %% Returns list of file descriptors passed to the application by systemd. %%