Commit | Line | Data |
---|---|---|
0a49a7a4 | 1 | /* $Cambridge: exim/src/src/auths/call_pwcheck.c,v 1.5 2009/11/16 19:50:38 nm4 Exp $ */ |
0756eb3c PH |
2 | |
3 | /************************************************* | |
4 | * Exim - an Internet mail transport agent * | |
5 | *************************************************/ | |
6 | ||
0a49a7a4 | 7 | /* Copyright (c) University of Cambridge 1995 - 2009 */ |
0756eb3c PH |
8 | /* See the file NOTICE for conditions of use and distribution. */ |
9 | ||
10 | /* This module contains interface functions to the two Cyrus authentication | |
11 | daemons. The original one was "pwcheck", which gives its name to the source | |
12 | file. 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 | |
24 | daemon, passing over a colon-separated user name and password. As this is | |
25 | called from the string expander, the string will always be in dynamic store and | |
26 | can be overwritten. | |
27 | ||
28 | Arguments: | |
29 | s a colon-separated username:password string | |
30 | errptr where to point an error message | |
31 | ||
32 | Returns: OK if authentication succeeded | |
33 | FAIL if authentication failed | |
34 | ERROR some other error condition | |
35 | */ | |
36 | ||
37 | int | |
38 | auth_call_pwcheck(uschar *s, uschar **errptr) | |
39 | { | |
40 | uschar *reply = NULL; | |
41 | uschar *pw = Ustrrchr(s, ':'); | |
42 | ||
43 | if (pw == NULL) | |
44 | { | |
45 | *errptr = US"pwcheck: malformed input - missing colon"; | |
46 | return ERROR; | |
47 | } | |
48 | ||
49 | *pw++ = 0; /* Separate user and password */ | |
50 | ||
51 | DEBUG(D_auth) | |
52 | debug_printf("Running pwcheck authentication for user \"%s\"\n", s); | |
53 | ||
54 | switch (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, | |
77 | saslauthd, As this is called from the string expander, all the strings will | |
78 | always be in dynamic store and can be overwritten. | |
79 | ||
80 | Arguments: | |
81 | username username | |
82 | password password | |
83 | service optional service | |
84 | realm optional realm | |
85 | errptr where to point an error message | |
86 | ||
87 | Returns: OK if authentication succeeded | |
88 | FAIL if authentication failed | |
89 | ERROR some other error condition | |
90 | */ | |
91 | ||
92 | int | |
93 | auth_call_saslauthd(uschar *username, uschar *password, uschar *service, | |
94 | uschar *realm, uschar **errptr) | |
95 | { | |
96 | uschar *reply = NULL; | |
97 | ||
98 | if (service == NULL) service = US""; | |
99 | if (realm == NULL) realm = US""; | |
100 | ||
101 | DEBUG(D_auth) | |
102 | debug_printf("Running saslauthd authentication for user \"%s\" \n", username); | |
103 | ||
104 | switch (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 */ |