[dovecot-cvs] dovecot/src/auth auth-request.c, 1.58.2.1, 1.58.2.2 passdb-pam.c, 1.37, 1.37.2.1 passdb.h, 1.33, 1.33.2.1

cras at dovecot.org cras at dovecot.org
Sun Jun 11 15:51:38 EEST 2006


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

Modified Files:
      Tag: branch_1_0
	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.58.2.1
retrieving revision 1.58.2.2
diff -u -d -r1.58.2.1 -r1.58.2.2
--- auth-request.c	31 May 2006 11:03:50 -0000	1.58.2.1
+++ auth-request.c	11 Jun 2006 12:51:36 -0000	1.58.2.2
@@ -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,9 @@
 				return FALSE;
 			}
 		}
+	} else if (*result == PASSDB_RESULT_PASS_EXPIRED) {
+		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.37
retrieving revision 1.37.2.1
diff -u -d -r1.37 -r1.37.2.1
--- passdb-pam.c	7 Feb 2006 16:41:44 -0000	1.37
+++ passdb-pam.c	11 Jun 2006 12:51:36 -0000	1.37.2.1
@@ -258,10 +258,20 @@
 
 		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_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.33.2.1
diff -u -d -r1.33 -r1.33.2.1
--- passdb.h	24 Feb 2006 10:49:05 -0000	1.33
+++ passdb.h	11 Jun 2006 12:51:36 -0000	1.33.2.1
@@ -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