(1) Typo in redirect router; (2) Update version number; (3) Update
[exim.git] / src / src / auths / call_pwcheck.c
... / ...
CommitLineData
1/* $Cambridge: exim/src/src/auths/call_pwcheck.c,v 1.2 2005/01/04 10:00:43 ph10 Exp $ */
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
7/* Copyright (c) University of Cambridge 1995 - 2005 */
8/* See the file NOTICE for conditions of use and distribution. */
9
10/* This module contains interface functions to the two Cyrus authentication
11daemons. The original one was "pwcheck", which gives its name to the source
12file. This is now deprecated in favour of "saslauthd". */
13
14
15#include "../exim.h"
16#include "pwcheck.h"
17
18
19/*************************************************
20* External entry point for pwcheck *
21*************************************************/
22
23/* This function calls the now-deprecated "pwcheck" Cyrus-SASL authentication
24daemon, passing over a colon-separated user name and password. As this is
25called from the string expander, the string will always be in dynamic store and
26can be overwritten.
27
28Arguments:
29 s a colon-separated username:password string
30 errptr where to point an error message
31
32Returns: OK if authentication succeeded
33 FAIL if authentication failed
34 ERROR some other error condition
35*/
36
37int
38auth_call_pwcheck(uschar *s, uschar **errptr)
39{
40uschar *reply = NULL;
41uschar *pw = Ustrrchr(s, ':');
42
43if (pw == NULL)
44 {
45 *errptr = US"pwcheck: malformed input - missing colon";
46 return ERROR;
47 }
48
49*pw++ = 0; /* Separate user and password */
50
51DEBUG(D_auth)
52 debug_printf("Running pwcheck authentication for user \"%s\"\n", s);
53
54switch (pwcheck_verify_password(CS s, CS pw, (const char **)(&reply)))
55 {
56 case PWCHECK_OK:
57 DEBUG(D_auth) debug_printf("pwcheck: success (%s)\n", reply);
58 return OK;
59
60 case PWCHECK_NO:
61 DEBUG(D_auth) debug_printf("pwcheck: access denied (%s)\n", reply);
62 return FAIL;
63
64 default:
65 DEBUG(D_auth) debug_printf("pwcheck: query failed (%s)\n", reply);
66 *errptr = reply;
67 return ERROR;
68 }
69}
70
71
72/*************************************************
73* External entry point for pwauthd *
74*************************************************/
75
76/* This function calls the "saslauthd" Cyrus-SASL authentication daemon,
77saslauthd, As this is called from the string expander, all the strings will
78always be in dynamic store and can be overwritten.
79
80Arguments:
81 username username
82 password password
83 service optional service
84 realm optional realm
85 errptr where to point an error message
86
87Returns: OK if authentication succeeded
88 FAIL if authentication failed
89 ERROR some other error condition
90*/
91
92int
93auth_call_saslauthd(uschar *username, uschar *password, uschar *service,
94 uschar *realm, uschar **errptr)
95{
96uschar *reply = NULL;
97
98if (service == NULL) service = US"";
99if (realm == NULL) realm = US"";
100
101DEBUG(D_auth)
102 debug_printf("Running saslauthd authentication for user \"%s\" \n", username);
103
104switch (saslauthd_verify_password(username, password, service,
105 realm, (const uschar **)(&reply)))
106 {
107 case PWCHECK_OK:
108 DEBUG(D_auth) debug_printf("saslauthd: success (%s)\n", reply);
109 return OK;
110
111 case PWCHECK_NO:
112 DEBUG(D_auth) debug_printf("saslauthd: access denied (%s)\n", reply);
113 return FAIL;
114
115 default:
116 DEBUG(D_auth) debug_printf("saslauthd: query failed (%s)\n", reply);
117 *errptr = reply;
118 return ERROR;
119 }
120}
121
122/* End of call_pwcheck.c */