Commit c62d902a authored by Philipp Huebner's avatar Philipp Huebner

Updated version 1.0.3 from 'upstream/1.0.3'

with Debian dir 800576be1b392849dc93533161b9cf65495c75fc
parents 915cc909 5b8bf7ba
......@@ -59,7 +59,7 @@ static int misc_conv(int num_msg,
return PAM_SUCCESS;
}
static int auth(char *service, char *user, char *password)
static int auth(char *service, char *user, char *password, char *rhost)
{
struct pam_conv conv = {misc_conv, password};
int retval;
......@@ -67,6 +67,8 @@ static int auth(char *service, char *user, char *password)
retval = pam_start(service, user, &conv, &pamh);
if (retval == PAM_SUCCESS)
retval = pam_set_item(pamh, PAM_RUSER, user);
if (retval == PAM_SUCCESS)
retval = pam_set_item(pamh, PAM_RHOST, rhost);
#ifdef PAM_FAIL_DELAY
if (retval == PAM_SUCCESS)
retval = pam_set_item(pamh, PAM_FAIL_DELAY, (void *)delay_fn);
......@@ -198,9 +200,9 @@ static int process_acct(ETERM *pid, ETERM *data)
static int process_auth(ETERM *pid, ETERM *data)
{
int retval = 0;
ETERM *pattern, *srv, *user, *pass;
char *service, *username, *password;
pattern = erl_format("{Srv, User, Pass}");
ETERM *pattern, *srv, *user, *pass, *rhost;
char *service, *username, *password, *remote_host;
pattern = erl_format("{Srv, User, Pass, Rhost}");
if (erl_match(pattern, data))
{
srv = erl_var_content(pattern, "Srv");
......@@ -209,7 +211,9 @@ static int process_auth(ETERM *pid, ETERM *data)
username = erl_iolist_to_string(user);
pass = erl_var_content(pattern, "Pass");
password = erl_iolist_to_string(pass);
retval = process_reply(pid, CMD_AUTH, auth(service, username, password));
rhost = erl_var_content(pattern, "Rhost");
remote_host = erl_iolist_to_string(rhost);
retval = process_reply(pid, CMD_AUTH, auth(service, username, password, remote_host));
erl_free_term(srv);
erl_free_term(user);
erl_free_term(pass);
......
......@@ -23,7 +23,7 @@
{application, epam,
[{description, "epam helper for PAM authentication support"},
{vsn, "1.0.2"},
{vsn, "1.0.3"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib]},
......@@ -31,7 +31,7 @@
{mod, {epam_app,[]}},
%% hex.pm packaging:
{files, ["src/", "c_src/epam.c", "rebar.config", "rebar.config.script", "README.md", "LICENSE.txt"]},
{files, ["src/", "c_src/epam.c", "configure", "rebar.config", "rebar.config.script", "README.md", "LICENSE.txt"]},
{licenses, ["Apache 2.0"]},
{maintainers, ["ProcessOne"]},
{links, [{"Github", "https://github.com/processone/epam"}]}
......
......@@ -32,7 +32,7 @@
%% API
-export([start_link/0, start/0, stop/0]).
-export([authenticate/3, acct_mgmt/2]).
-export([authenticate/3, authenticate/4, acct_mgmt/2]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2,
......@@ -49,7 +49,6 @@
-define(PROCNAME, ?MODULE).
-define(CMD_AUTH, 0).
-define(CMD_ACCT, 1).
-record(state, {port}).
......@@ -71,7 +70,12 @@ start_link() ->
authenticate(Srv, User, Pass)
when is_binary(Srv), is_binary(User), is_binary(Pass) ->
gen_server:call(?PROCNAME,
{authenticate, Srv, User, Pass}).
{authenticate, Srv, User, Pass, <<"">>}).
authenticate(Srv, User, Pass, Rhost)
when is_binary(Srv), is_binary(User), is_binary(Pass), is_binary(Rhost) ->
gen_server:call(?PROCNAME,
{authenticate, Srv, User, Pass, Rhost}).
acct_mgmt(Srv, User)
when is_binary(Srv), is_binary(User) ->
......@@ -98,11 +102,11 @@ init([]) ->
terminate(_Reason, #state{port = Port}) ->
catch port_close(Port), ok.
handle_call({authenticate, Srv, User, Pass}, From,
handle_call({authenticate, Srv, User, Pass, Rhost}, From,
State) ->
Port = State#state.port,
Data = term_to_binary({?CMD_AUTH, From,
{Srv, User, Pass}}),
{Srv, User, Pass, Rhost}}),
port_command(Port, Data),
{noreply, State};
handle_call({acct_mgmt, Srv, User}, From, State) ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment