diff options
author | Badlop <badlop@process-one.net> | 2010-05-07 22:34:59 +0200 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2010-05-10 15:14:49 +0200 |
commit | 39119192a1eb9c92e00212cbbc9f52f57f7b59a7 (patch) | |
tree | 5fb5be28fb2ca1a90a1226e6440dfb54ef6f1b3c /src | |
parent | Recompile the guide (diff) |
New option pam_userinfotype to provide username or JID (EJAB-652)
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_auth_pam.erl | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ejabberd_auth_pam.erl b/src/ejabberd_auth_pam.erl index aff0a226..b99c7cbd 100644 --- a/src/ejabberd_auth_pam.erl +++ b/src/ejabberd_auth_pam.erl @@ -60,7 +60,11 @@ check_password(User, Server, Password, _Digest, _DigestGen) -> check_password(User, Host, Password) -> Service = get_pam_service(Host), - case catch epam:authenticate(Service, User, Password) of + UserInfo = case get_pam_userinfotype(Host) of + username -> User; + jid -> User++"@"++Host + end, + case catch epam:authenticate(Service, UserInfo, Password) of true -> true; _ -> false end. @@ -84,7 +88,11 @@ get_password_s(_User, _Server) -> %% TODO: Improve this function to return an error instead of 'false' when connection to PAM failed is_user_exists(User, Host) -> Service = get_pam_service(Host), - case catch epam:acct_mgmt(Service, User) of + UserInfo = case get_pam_userinfotype(Host) of + username -> User; + jid -> User++"@"++Host + end, + case catch epam:acct_mgmt(Service, UserInfo) of true -> true; _ -> false end. @@ -106,3 +114,8 @@ get_pam_service(Host) -> undefined -> "ejabberd"; Service -> Service end. +get_pam_userinfotype(Host) -> + case ejabberd_config:get_local_option({pam_userinfotype, Host}) of + undefined -> username; + Type -> Type + end. |