version 1.177, 2006/09/26 06:47:20 |
version 1.177.2.2, 2008/09/18 18:12:57 |
Line 3655 cprintf(FILE *fd, const char *fmt, ...) |
|
Line 3655 cprintf(FILE *fd, const char *fmt, ...) |
|
*/ |
*/ |
#define COPY_STRING(s) (s ? strdup(s) : NULL) |
#define COPY_STRING(s) (s ? strdup(s) : NULL) |
|
|
struct cred_t { |
typedef struct { |
const char *uname; /* user name */ |
const char *uname; /* user name */ |
const char *pass; /* password */ |
const char *pass; /* password */ |
}; |
} ftpd_cred_t; |
typedef struct cred_t cred_t; |
|
|
|
static int |
static int |
auth_conv(int num_msg, const struct pam_message **msg, |
auth_conv(int num_msg, const struct pam_message **msg, |
struct pam_response **resp, void *appdata) |
struct pam_response **resp, void *appdata) |
{ |
{ |
int i; |
int i; |
cred_t *cred = (cred_t *) appdata; |
ftpd_cred_t *cred = (ftpd_cred_t *) appdata; |
struct pam_response *myreply; |
struct pam_response *myreply; |
|
|
myreply = calloc(num_msg, sizeof *myreply); |
myreply = calloc(num_msg, sizeof *myreply); |
Line 3714 auth_pam(struct passwd **ppw, const char |
|
Line 3713 auth_pam(struct passwd **ppw, const char |
|
const void *item; |
const void *item; |
int rval; |
int rval; |
int e; |
int e; |
cred_t auth_cred = { (*ppw)->pw_name, pwstr }; |
ftpd_cred_t auth_cred = { (*ppw)->pw_name, pwstr }; |
struct pam_conv conv = { &auth_conv, &auth_cred }; |
struct pam_conv conv = { &auth_conv, &auth_cred }; |
|
|
e = pam_start("ftpd", (*ppw)->pw_name, &conv, &pamh); |
e = pam_start("ftpd", (*ppw)->pw_name, &conv, &pamh); |
Line 3738 auth_pam(struct passwd **ppw, const char |
|
Line 3737 auth_pam(struct passwd **ppw, const char |
|
return -1; |
return -1; |
} |
} |
|
|
|
e = pam_set_item(pamh, PAM_SOCKADDR, &his_addr); |
|
if (e != PAM_SUCCESS) { |
|
syslog(LOG_ERR, "pam_set_item(PAM_SOCKADDR): %s", |
|
pam_strerror(pamh, e)); |
|
if ((e = pam_end(pamh, e)) != PAM_SUCCESS) { |
|
syslog(LOG_ERR, "pam_end: %s", pam_strerror(pamh, e)); |
|
} |
|
pamh = NULL; |
|
return -1; |
|
} |
|
|
e = pam_authenticate(pamh, 0); |
e = pam_authenticate(pamh, 0); |
switch (e) { |
switch (e) { |
case PAM_SUCCESS: |
case PAM_SUCCESS: |