aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeraphim Mellos <mellos@ceid.upatras.gr>2008-06-29 14:27:58 +0300
committerSeraphim Mellos <mellos@ceid.upatras.gr>2008-06-29 14:27:58 +0300
commit03488d3e223446a0a86f7c5e775daa29a6edb20c (patch)
treeb8e039eee180610217e22327db9a5ffe3ffefc04 /modules/pam_unix
parentgentoo git overlays ready version (diff)
downloadopenpam-modules-03488d3e223446a0a86f7c5e775daa29a6edb20c.tar.gz
openpam-modules-03488d3e223446a0a86f7c5e775daa29a6edb20c.tar.bz2
openpam-modules-03488d3e223446a0a86f7c5e775daa29a6edb20c.zip
Completed pam_nologin
Diffstat (limited to 'modules/pam_unix')
-rw-r--r--modules/pam_unix/pam_unix.c63
1 files changed, 33 insertions, 30 deletions
diff --git a/modules/pam_unix/pam_unix.c b/modules/pam_unix/pam_unix.c
index 8e1351c..e516162 100644
--- a/modules/pam_unix/pam_unix.c
+++ b/modules/pam_unix/pam_unix.c
@@ -191,7 +191,7 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags ,
if (pam_err != PAM_SUCCESS)
return (pam_err);
- if (user == NULL || (pwd = getpwnam(user)) == NULL)
+ if (user == NULL || (pwd = getspnam(user)) == NULL)
return (PAM_SERVICE_ERR);
@@ -227,11 +227,12 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags ,
return (PAM_SERVICE_ERR);
}
#endif
- /* Check if pw_lstchg or sp_expire is set */
-/*
- if (pwd->sp_lstchg || pwd->sp_expire)
- curtime = time(NULL) / (60 * 60 * 24);
- if (pwd->sp_expire) {
+ /* Calculate current time */
+ curtime = time(NULL) / (60 * 60 * 24);
+
+ /* Check for account expiration */
+ if (pwd->sp_expire > 0) {
+ fprintf(stdout, "Account expiration data value is %ld\n", pwd->sp_expire);
if ( (curtime > pwd->sp_expire ) && ( pwd->sp_expire != -1 ) ) {
#ifndef __linux__
login_close(lc);
@@ -242,35 +243,37 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags ,
PAM_ERROR("Warning: your account expires on %s",
ctime(&pwd->sp_expire));
}
- }
+
- if (pwd->sp_lstchg == 0 ) {
- return (PAM_NEW_AUTHTOK_REQD);
- }
- * check all other possibilities (mostly stolen from pam_tcb) *
+ if (pwd->sp_lstchg == 0 ) {
+ return (PAM_NEW_AUTHTOK_REQD);
+ }
+
+ /* check all other possibilities (mostly stolen from pam_tcb) */
- if ((curtime > (pwd->sp_lstchg + pwd->sp_max + pwd->sp_inact)) &&
- (pwd->sp_max != -1) && (pwd->sp_inact != -1) &&
- (pwd->sp_lstchg != 0)) {
- PAM_ERROR("Account has expired!");
- return (PAM_ACCT_EXPIRED);
- }
+ if ((curtime > (pwd->sp_lstchg + pwd->sp_max + pwd->sp_inact)) &&
+ (pwd->sp_max != -1) && (pwd->sp_inact != -1) &&
+ (pwd->sp_lstchg != 0)) {
+ PAM_ERROR("Account has expired!");
+ return (PAM_ACCT_EXPIRED);
+ }
- if (((pwd->sp_lstchg + pwd->sp_max) < curtime) &&
- (pwd->sp_max != -1)) {
- PAM_ERROR("Account has expired!");
- return (PAM_ACCT_EXPIRED);
- }
+ if (((pwd->sp_lstchg + pwd->sp_max) < curtime) &&
+ (pwd->sp_max != -1)) {
+ PAM_ERROR("Account has expired!");
+ return (PAM_ACCT_EXPIRED);
+ }
- if ((curtime - pwd->sp_lstchg > pwd->sp_max)
- && (curtime - pwd->sp_lstchg > pwd->sp_inact)
- && (curtime - pwd->sp_lstchg > pwd->sp_max + pwd->sp_inact)
- && (pwd->sp_max != -1) && (pwd->sp_inact != -1)) {
- PAM_ERROR("Account has expired!");
- return (PAM_ACCT_EXPIRED);
- }
+ if ((curtime - pwd->sp_lstchg > pwd->sp_max)
+ && (curtime - pwd->sp_lstchg > pwd->sp_inact)
+ && (curtime - pwd->sp_lstchg > pwd->sp_max + pwd->sp_inact)
+ && (pwd->sp_max != -1) && (pwd->sp_inact != -1)) {
+ PAM_ERROR("Account has expired!");
+ return (PAM_ACCT_EXPIRED);
+ }
-*/ pam_err = (PAM_SUCCESS);
+ }
+ pam_err = (PAM_SUCCESS);
#ifndef __linux__