[dovecot-cvs] dovecot/src/auth auth-request.c, 1.59, 1.60 passdb-pam.c, 1.39, 1.40 passdb.h, 1.33, 1.34

cras at dovecot.org cras at dovecot.org
Fri Jun 16 13:01:27 EEST 2006


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv3756

Modified Files:
	auth-request.c passdb-pam.c passdb.h 
Log Message:
If password is expired, give "Password expired" error. Currently works only
with PAM. Also added "unknown user" PAM return value handling.



Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- auth-request.c	31 May 2006 11:03:53 -0000	1.59
+++ auth-request.c	16 Jun 2006 10:01:25 -0000	1.60
@@ -192,6 +192,7 @@
 		/* can be cached */
 		break;
 	case PASSDB_RESULT_USER_DISABLED:
+	case PASSDB_RESULT_PASS_EXPIRED:
 		/* FIXME: we can't cache this now, or cache lookup would
 		   return success. */
 		return;
@@ -316,6 +317,11 @@
 				return FALSE;
 			}
 		}
+	} else if (*result == PASSDB_RESULT_PASS_EXPIRED) {
+	        if (request->extra_fields == NULL)
+		        request->extra_fields = auth_stream_reply_init(request);
+	        auth_stream_reply_add(request->extra_fields, "reason",
+				      "Password expired");
 	} else if (request->passdb->next != NULL &&
 		   *result != PASSDB_RESULT_USER_DISABLED) {
 		/* try next passdb. */

Index: passdb-pam.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-pam.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- passdb-pam.c	16 Jun 2006 09:49:51 -0000	1.39
+++ passdb-pam.c	16 Jun 2006 10:01:25 -0000	1.40
@@ -266,10 +266,21 @@
 
 		status = pam_auth(request, pamh, &str);
 		if ((status2 = pam_end(pamh, status)) == PAM_SUCCESS) {
-			/* FIXME: check for PASSDB_RESULT_UNKNOWN_USER
-			   somehow? */
-			result = status == PAM_SUCCESS ? PASSDB_RESULT_OK :
-				PASSDB_RESULT_PASSWORD_MISMATCH;
+			switch (status) {
+			case PAM_SUCCESS:
+				result = PASSDB_RESULT_OK;
+				break;
+			case PAM_USER_UNKNOWN:
+				result = PASSDB_RESULT_USER_UNKNOWN;
+				break;
+			case PAM_NEW_AUTHTOK_REQD:
+			case PAM_ACCT_EXPIRED:
+				result = PASSDB_RESULT_PASS_EXPIRED;
+				break;
+			default:
+				result = PASSDB_RESULT_PASSWORD_MISMATCH;
+				break;
+			}
 		} else {
 			result = PASSDB_RESULT_INTERNAL_FAILURE;
 			str = t_strdup_printf("pam_end() failed: %s",

Index: passdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- passdb.h	24 Feb 2006 10:49:05 -0000	1.33
+++ passdb.h	16 Jun 2006 10:01:25 -0000	1.34
@@ -19,10 +19,12 @@
 };
 
 enum passdb_result {
-	PASSDB_RESULT_USER_UNKNOWN = -1,
-	PASSDB_RESULT_USER_DISABLED = -2,
-	PASSDB_RESULT_INTERNAL_FAILURE = -3,
-	PASSDB_RESULT_SCHEME_NOT_AVAILABLE = -4,
+	PASSDB_RESULT_INTERNAL_FAILURE = -1,
+	PASSDB_RESULT_SCHEME_NOT_AVAILABLE = -2,
+
+	PASSDB_RESULT_USER_UNKNOWN = -3,
+	PASSDB_RESULT_USER_DISABLED = -4,
+	PASSDB_RESULT_PASS_EXPIRED = -5,
 
 	PASSDB_RESULT_PASSWORD_MISMATCH = 0,
 	PASSDB_RESULT_OK = 1



More information about the dovecot-cvs mailing list