|
Lines 155-164
pthread_join(sp_pthread_t thread, void *
Link Here
|
| 155 |
static pam_handle_t *sshpam_handle = NULL; |
155 |
static pam_handle_t *sshpam_handle = NULL; |
| 156 |
static int sshpam_err = 0; |
156 |
static int sshpam_err = 0; |
| 157 |
static int sshpam_authenticated = 0; |
157 |
static int sshpam_authenticated = 0; |
| 158 |
static int sshpam_new_authtok_reqd = 0; |
|
|
| 159 |
static int sshpam_session_open = 0; |
158 |
static int sshpam_session_open = 0; |
| 160 |
static int sshpam_cred_established = 0; |
159 |
static int sshpam_cred_established = 0; |
| 161 |
static int sshpam_account_status = -1; |
160 |
static int sshpam_account_status = -1; |
|
|
161 |
static int *force_pwchange; |
| 162 |
static char **sshpam_env = NULL; |
162 |
static char **sshpam_env = NULL; |
| 163 |
|
163 |
|
| 164 |
/* Some PAM implementations don't implement this */ |
164 |
/* Some PAM implementations don't implement this */ |
|
Lines 179-185
void
Link Here
|
| 179 |
pam_password_change_required(int reqd) |
179 |
pam_password_change_required(int reqd) |
| 180 |
{ |
180 |
{ |
| 181 |
debug3("%s %d", __func__, reqd); |
181 |
debug3("%s %d", __func__, reqd); |
| 182 |
sshpam_new_authtok_reqd = reqd; |
182 |
*force_pwchange = reqd; |
| 183 |
if (reqd) { |
183 |
if (reqd) { |
| 184 |
no_port_forwarding_flag |= 2; |
184 |
no_port_forwarding_flag |= 2; |
| 185 |
no_agent_forwarding_flag |= 2; |
185 |
no_agent_forwarding_flag |= 2; |
|
Lines 188-196
pam_password_change_required(int reqd)
Link Here
|
| 188 |
no_port_forwarding_flag &= ~2; |
188 |
no_port_forwarding_flag &= ~2; |
| 189 |
no_agent_forwarding_flag &= ~2; |
189 |
no_agent_forwarding_flag &= ~2; |
| 190 |
no_x11_forwarding_flag &= ~2; |
190 |
no_x11_forwarding_flag &= ~2; |
| 191 |
|
|
|
| 192 |
} |
191 |
} |
| 193 |
} |
192 |
} |
|
|
193 |
|
| 194 |
/* Import regular and PAM environment from subprocess */ |
194 |
/* Import regular and PAM environment from subprocess */ |
| 195 |
static void |
195 |
static void |
| 196 |
import_environments(Buffer *b) |
196 |
import_environments(Buffer *b) |
|
Lines 348-354
sshpam_thread(void *ctxtp)
Link Here
|
| 348 |
if (compat20) { |
348 |
if (compat20) { |
| 349 |
if (!do_pam_account()) |
349 |
if (!do_pam_account()) |
| 350 |
goto auth_fail; |
350 |
goto auth_fail; |
| 351 |
if (sshpam_new_authtok_reqd) { |
351 |
if (*force_pwchange) { |
| 352 |
sshpam_err = pam_chauthtok(sshpam_handle, |
352 |
sshpam_err = pam_chauthtok(sshpam_handle, |
| 353 |
PAM_CHANGE_EXPIRED_AUTHTOK); |
353 |
PAM_CHANGE_EXPIRED_AUTHTOK); |
| 354 |
if (sshpam_err != PAM_SUCCESS) |
354 |
if (sshpam_err != PAM_SUCCESS) |
|
Lines 362-368
sshpam_thread(void *ctxtp)
Link Here
|
| 362 |
#ifndef USE_POSIX_THREADS |
362 |
#ifndef USE_POSIX_THREADS |
| 363 |
/* Export variables set by do_pam_account */ |
363 |
/* Export variables set by do_pam_account */ |
| 364 |
buffer_put_int(&buffer, sshpam_account_status); |
364 |
buffer_put_int(&buffer, sshpam_account_status); |
| 365 |
buffer_put_int(&buffer, sshpam_new_authtok_reqd); |
365 |
buffer_put_int(&buffer, *force_pwchange); |
| 366 |
|
366 |
|
| 367 |
/* Export any environment strings set in child */ |
367 |
/* Export any environment strings set in child */ |
| 368 |
for(i = 0; environ[i] != NULL; i++) |
368 |
for(i = 0; environ[i] != NULL; i++) |
|
Lines 437-443
sshpam_cleanup(void)
Link Here
|
| 437 |
pam_close_session(sshpam_handle, PAM_SILENT); |
437 |
pam_close_session(sshpam_handle, PAM_SILENT); |
| 438 |
sshpam_session_open = 0; |
438 |
sshpam_session_open = 0; |
| 439 |
} |
439 |
} |
| 440 |
sshpam_authenticated = sshpam_new_authtok_reqd = 0; |
440 |
sshpam_authenticated = 0; |
| 441 |
pam_end(sshpam_handle, sshpam_err); |
441 |
pam_end(sshpam_handle, sshpam_err); |
| 442 |
sshpam_handle = NULL; |
442 |
sshpam_handle = NULL; |
| 443 |
} |
443 |
} |
|
Lines 511-516
sshpam_init_ctx(Authctxt *authctxt)
Link Here
|
| 511 |
ctxt = xmalloc(sizeof *ctxt); |
511 |
ctxt = xmalloc(sizeof *ctxt); |
| 512 |
memset(ctxt, 0, sizeof(*ctxt)); |
512 |
memset(ctxt, 0, sizeof(*ctxt)); |
| 513 |
|
513 |
|
|
|
514 |
force_pwchange = &(authctxt->force_pwchange); |
| 515 |
|
| 514 |
/* Start the authentication thread */ |
516 |
/* Start the authentication thread */ |
| 515 |
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) { |
517 |
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, socks) == -1) { |
| 516 |
error("PAM: failed create sockets: %s", strerror(errno)); |
518 |
error("PAM: failed create sockets: %s", strerror(errno)); |
|
Lines 744-755
do_pam_setcred(int init)
Link Here
|
| 744 |
pam_strerror(sshpam_handle, sshpam_err)); |
746 |
pam_strerror(sshpam_handle, sshpam_err)); |
| 745 |
} |
747 |
} |
| 746 |
|
748 |
|
| 747 |
int |
|
|
| 748 |
is_pam_password_change_required(void) |
| 749 |
{ |
| 750 |
return (sshpam_new_authtok_reqd); |
| 751 |
} |
| 752 |
|
| 753 |
static int |
749 |
static int |
| 754 |
pam_tty_conv(int n, const struct pam_message **msg, |
750 |
pam_tty_conv(int n, const struct pam_message **msg, |
| 755 |
struct pam_response **resp, void *data) |
751 |
struct pam_response **resp, void *data) |
|
Lines 828-833
do_pam_chauthtok(void)
Link Here
|
| 828 |
void |
824 |
void |
| 829 |
do_pam_session(void) |
825 |
do_pam_session(void) |
| 830 |
{ |
826 |
{ |
|
|
827 |
debug3("PAM: opening session"); |
| 831 |
sshpam_err = pam_set_item(sshpam_handle, PAM_CONV, |
828 |
sshpam_err = pam_set_item(sshpam_handle, PAM_CONV, |
| 832 |
(const void *)&tty_conv); |
829 |
(const void *)&tty_conv); |
| 833 |
if (sshpam_err != PAM_SUCCESS) |
830 |
if (sshpam_err != PAM_SUCCESS) |
|
Lines 862-873
do_pam_putenv(char *name, char *value)
Link Here
|
| 862 |
#endif |
859 |
#endif |
| 863 |
|
860 |
|
| 864 |
return (ret); |
861 |
return (ret); |
| 865 |
} |
|
|
| 866 |
|
| 867 |
void |
| 868 |
print_pam_messages(void) |
| 869 |
{ |
| 870 |
/* XXX */ |
| 871 |
} |
862 |
} |
| 872 |
|
863 |
|
| 873 |
char ** |
864 |
char ** |