|
Lines 58-63
Link Here
|
| 58 |
static int password_change_required = 0; |
58 |
static int password_change_required = 0; |
| 59 |
/* remember whether the last pam_authenticate() succeeded or not */ |
59 |
/* remember whether the last pam_authenticate() succeeded or not */ |
| 60 |
static int was_authenticated = 0; |
60 |
static int was_authenticated = 0; |
|
|
61 |
static int acct_mgmt_retval = -1; |
| 61 |
|
62 |
|
| 62 |
/* Remember what has been initialised */ |
63 |
/* Remember what has been initialised */ |
| 63 |
static int session_opened = 0; |
64 |
static int session_opened = 0; |
|
Lines 71-80
Link Here
|
| 71 |
} |
72 |
} |
| 72 |
|
73 |
|
| 73 |
/* start an authentication run */ |
74 |
/* start an authentication run */ |
| 74 |
int do_pam_authenticate(int flags) |
75 |
int do_pam_authenticate(int flags, int can_age_pw_here) |
| 75 |
{ |
76 |
{ |
| 76 |
int retval = pam_authenticate(__pamh, flags); |
77 |
int retval = pam_authenticate(__pamh, flags); |
|
|
78 |
|
| 79 |
was_authenticated = (retval == PAM_SUCCESS); |
| 80 |
if (retval != PAM_SUCCESS) |
| 81 |
return retval; |
| 82 |
|
| 83 |
acct_mgmt_retval = pam_acct_mgmt(__pamh, 0); |
| 84 |
|
| 85 |
if (acct_mgmt_retval == PAM_SUCCESS) |
| 86 |
return PAM_SUCCESS; |
| 87 |
|
| 88 |
was_authenticated = 0; |
| 89 |
if (acct_mgmt_retval != PAM_NEW_AUTHTOK_REQD) |
| 90 |
return acct_mgmt_retval; |
| 91 |
|
| 92 |
/* (acct_mgmt_retval == PAM_NEW_AUTHTOK_REQD) */ |
| 93 |
/* PAM auth token (password) is expired */ |
| 94 |
|
| 95 |
/* |
| 96 |
* USERAUTH_PASSWORD_CHANGEREQ is not currently |
| 97 |
* supported. Password aged users using password |
| 98 |
* userauth are thrown out here. |
| 99 |
*/ |
| 100 |
if (!can_age_pw_here) |
| 101 |
return PAM_NEW_AUTHTOK_REQD; |
| 102 |
|
| 103 |
debug("do_pam_authenticate() - doing password aging"); |
| 104 |
retval = pam_chauthtok(__pamh, PAM_CHANGE_EXPIRED_AUTHTOK); |
| 77 |
was_authenticated = (retval == PAM_SUCCESS); |
105 |
was_authenticated = (retval == PAM_SUCCESS); |
|
|
106 |
if (retval == PAM_SUCCESS) |
| 107 |
acct_mgmt_retval = PAM_SUCCESS; |
| 108 |
|
| 78 |
return retval; |
109 |
return retval; |
| 79 |
} |
110 |
} |
| 80 |
|
111 |
|
|
Lines 218-224
Link Here
|
| 218 |
|
249 |
|
| 219 |
pamstate = INITIAL_LOGIN; |
250 |
pamstate = INITIAL_LOGIN; |
| 220 |
pam_retval = do_pam_authenticate( |
251 |
pam_retval = do_pam_authenticate( |
| 221 |
options.permit_empty_passwd == 0 ? PAM_DISALLOW_NULL_AUTHTOK : 0); |
252 |
options.permit_empty_passwd == 0 ? PAM_DISALLOW_NULL_AUTHTOK : 0, |
|
|
253 |
0); |
| 222 |
if (pam_retval == PAM_SUCCESS) { |
254 |
if (pam_retval == PAM_SUCCESS) { |
| 223 |
debug("PAM Password authentication accepted for " |
255 |
debug("PAM Password authentication accepted for " |
| 224 |
"user \"%.100s\"", pw->pw_name); |
256 |
"user \"%.100s\"", pw->pw_name); |
|
Lines 246-252
Link Here
|
| 246 |
PAM_STRERROR(__pamh, pam_retval)); |
278 |
PAM_STRERROR(__pamh, pam_retval)); |
| 247 |
} |
279 |
} |
| 248 |
|
280 |
|
| 249 |
pam_retval = pam_acct_mgmt(__pamh, 0); |
281 |
/* do_pam_authenticate() may have called pam_acct_mgmt() already */ |
|
|
282 |
pam_retval = acct_mgmt_retval; |
| 283 |
if (pam_retval == -1) |
| 284 |
pam_retval = pam_acct_mgmt(__pamh, 0); |
| 285 |
|
| 250 |
switch (pam_retval) { |
286 |
switch (pam_retval) { |
| 251 |
case PAM_SUCCESS: |
287 |
case PAM_SUCCESS: |
| 252 |
/* This is what we want */ |
288 |
/* This is what we want */ |
|
Lines 255-260
Link Here
|
| 255 |
message_cat(&__pam_msg, NEW_AUTHTOK_MSG); |
291 |
message_cat(&__pam_msg, NEW_AUTHTOK_MSG); |
| 256 |
/* flag that password change is necessary */ |
292 |
/* flag that password change is necessary */ |
| 257 |
password_change_required = 1; |
293 |
password_change_required = 1; |
|
|
294 |
return(0); /* Sorry, no TTY password aging */ |
| 258 |
break; |
295 |
break; |
| 259 |
default: |
296 |
default: |
| 260 |
log("PAM rejected by account configuration[%d]: " |
297 |
log("PAM rejected by account configuration[%d]: " |
|
Lines 314-340
Link Here
|
| 314 |
int is_pam_password_change_required(void) |
351 |
int is_pam_password_change_required(void) |
| 315 |
{ |
352 |
{ |
| 316 |
return password_change_required; |
353 |
return password_change_required; |
| 317 |
} |
|
|
| 318 |
|
| 319 |
/* |
| 320 |
* Have user change authentication token if pam_acct_mgmt() indicated |
| 321 |
* it was expired. This needs to be called after an interactive |
| 322 |
* session is established and the user's pty is connected to |
| 323 |
* stdin/stout/stderr. |
| 324 |
*/ |
| 325 |
void do_pam_chauthtok(void) |
| 326 |
{ |
| 327 |
int pam_retval; |
| 328 |
|
| 329 |
do_pam_set_conv(&conv); |
| 330 |
|
| 331 |
if (password_change_required) { |
| 332 |
pamstate = OTHER; |
| 333 |
pam_retval = pam_chauthtok(__pamh, PAM_CHANGE_EXPIRED_AUTHTOK); |
| 334 |
if (pam_retval != PAM_SUCCESS) |
| 335 |
fatal("PAM pam_chauthtok failed[%d]: %.200s", |
| 336 |
pam_retval, PAM_STRERROR(__pamh, pam_retval)); |
| 337 |
} |
| 338 |
} |
354 |
} |
| 339 |
|
355 |
|
| 340 |
/* Cleanly shutdown PAM */ |
356 |
/* Cleanly shutdown PAM */ |