changeset 1361:dc2163fafa70 HEAD

passwd-file fixes. passdb ignores now fields after password, so it can work with shadow-like file.
author Timo Sirainen <tss@iki.fi>
date Wed, 16 Apr 2003 16:38:17 +0300
parents 5c67f77e4116
children 085c5b7a69ad
files src/auth/db-passwd-file.c src/auth/db-passwd-file.h src/auth/passdb-passwd-file.c src/auth/userdb-passwd-file.c
diffstat 4 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/db-passwd-file.c	Wed Apr 16 02:13:49 2003 +0300
+++ b/src/auth/db-passwd-file.c	Wed Apr 16 16:38:17 2003 +0300
@@ -153,7 +153,9 @@
 		args = t_strsplit(line, ":");
 		if (args[1] != NULL) {
 			/* at least two fields */
-			passwd_file_add(pw, args[0], args[1], args+2);
+			const char *no_args = NULL;
+			passwd_file_add(pw, args[0], args[1],
+					pw->userdb ? args+2 : &no_args);
 		}
 		t_pop();
 	}
@@ -191,13 +193,14 @@
 	}
 }
 
-struct passwd_file *db_passwd_file_parse(const char *path)
+struct passwd_file *db_passwd_file_parse(const char *path, int userdb)
 {
 	struct passwd_file *pw;
 
 	pw = i_new(struct passwd_file, 1);
 	pw->refcount = 1;
 	pw->path = i_strdup(path);
+	pw->userdb = userdb;
 
 	passwd_file_open(pw);
 	return pw;
--- a/src/auth/db-passwd-file.h	Wed Apr 16 02:13:49 2003 +0300
+++ b/src/auth/db-passwd-file.h	Wed Apr 16 16:38:17 2003 +0300
@@ -23,6 +23,7 @@
 	char *path;
 	time_t stamp;
 	int fd;
+	int userdb;
 
 	struct hash_table *users;
 };
@@ -33,7 +34,7 @@
 struct passwd_user *
 db_passwd_file_lookup(struct passwd_file *pw, const char *user);
 
-struct passwd_file *db_passwd_file_parse(const char *path);
+struct passwd_file *db_passwd_file_parse(const char *path, int userdb);
 void db_passwd_file_unref(struct passwd_file *pw);
 
 #endif
--- a/src/auth/passdb-passwd-file.c	Wed Apr 16 02:13:49 2003 +0300
+++ b/src/auth/passdb-passwd-file.c	Wed Apr 16 16:38:17 2003 +0300
@@ -73,7 +73,7 @@
 		passdb_pwf = userdb_pwf;
                 passdb_pwf->refcount++;
 	} else {
-		passdb_pwf = db_passwd_file_parse(args);
+		passdb_pwf = db_passwd_file_parse(args, FALSE);
 	}
 }
 
--- a/src/auth/userdb-passwd-file.c	Wed Apr 16 02:13:49 2003 +0300
+++ b/src/auth/userdb-passwd-file.c	Wed Apr 16 16:38:17 2003 +0300
@@ -40,9 +40,13 @@
 {
 	if (passdb_pwf != NULL && strcmp(passdb_pwf->path, args) == 0) {
 		userdb_pwf = passdb_pwf;
-                userdb_pwf->refcount++;
+		userdb_pwf->refcount++;
+
+		/* resync */
+		userdb_pwf->userdb = FALSE;
+                userdb_pwf->stamp = 0;
 	} else {
-		userdb_pwf = db_passwd_file_parse(args);
+		userdb_pwf = db_passwd_file_parse(args, TRUE);
 	}
 }