~ubuntu-branches/ubuntu/dapper/dovecot/dapper

« back to all changes in this revision

Viewing changes to src/auth/passdb-pam.c

  • Committer: Bazaar Package Importer
  • Author(s): Jaldhar H. Vyas
  • Date: 2005-01-08 12:11:38 UTC
  • Revision ID: james.westby@ubuntu.com-20050108121138-ehzbtfejyeqwso66
Tags: 0.99.13-3
Oops -2 had to be urgency=high so -1 doesn't get into sarge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
        return PAM_SUCCESS;
167
167
}
168
168
 
169
 
static int pam_auth(pam_handle_t *pamh, const char *user, const char **error)
 
169
static int pam_auth(pam_handle_t *pamh, const char *user,
 
170
                const struct ip_addr *remote_ip, const char **error)
170
171
{
171
172
        void * item;
172
173
        int status;
 
174
        const char *addr;
173
175
 
174
176
        *error = NULL;
175
177
 
 
178
        if ((addr = net_ip2addr(remote_ip))
 
179
                && (status = pam_set_item(pamh, PAM_RHOST, addr))
 
180
                        != PAM_SUCCESS) {
 
181
                *error = t_strdup_printf("pam_set_item(PAM_RHOST, %s) failed: %s",
 
182
                                         addr, pam_strerror(pamh, status));
 
183
                return status;
 
184
        }
 
185
 
176
186
        if ((status = pam_authenticate(pamh, 0)) != PAM_SUCCESS) {
177
187
                *error = t_strdup_printf("pam_authenticate(%s) failed: %s",
178
188
                                         user, pam_strerror(pamh, status));
205
215
 
206
216
static void
207
217
pam_verify_plain_child(const char *service, const char *user,
208
 
                       const char *password, int fd)
 
218
                       const char *password, const struct ip_addr *remote_ip,
 
219
                       int fd)
209
220
{
210
221
        pam_handle_t *pamh;
211
222
        struct pam_userpass userpass;
228
239
                str = t_strdup_printf("pam_start(%s) failed: %s",
229
240
                                      user, pam_strerror(pamh, status));
230
241
        } else {
231
 
                status = pam_auth(pamh, user, &str);
 
242
                status = pam_auth(pamh, user, remote_ip, &str);
232
243
                if ((status2 = pam_end(pamh, status)) == PAM_SUCCESS) {
233
244
                        /* FIXME: check for PASSDB_RESULT_UNKNOWN_USER
234
245
                           somehow? */
353
364
 
354
365
        if (pid == 0) {
355
366
                (void)close(fd[0]);
356
 
                pam_verify_plain_child(service, request->user, password, fd[1]);
 
367
                pam_verify_plain_child(service, request->user, password, &request->remote_ip, fd[1]);
357
368
                _exit(0);
358
369
        }
359
370