diff src/auth/userdb-passwd-file.c @ 6394:9e74c008484a HEAD

Added username_format parameter for passwd-file passdb and userdb.
author Timo Sirainen <tss@iki.fi>
date Sat, 15 Sep 2007 15:58:27 +0300
parents cda9824bab63
children 6a64e64fa3a3
line wrap: on
line diff
--- a/src/auth/userdb-passwd-file.c	Sat Sep 15 15:54:43 2007 +0300
+++ b/src/auth/userdb-passwd-file.c	Sat Sep 15 15:58:27 2007 +0300
@@ -79,12 +79,27 @@
 passwd_file_preinit(struct auth_userdb *auth_userdb, const char *args)
 {
 	struct passwd_file_userdb_module *module;
+	const char *format = PASSWD_FILE_DEFAULT_USERNAME_FORMAT;
+	const char *p;
+
+	if (strncmp(args, "username_format=", 16) == 0) {
+		args += 16;
+		p = strchr(args, ' ');
+		if (p == NULL) {
+			format = args;
+			args = "";
+		} else {
+			format = p_strdup_until(auth_userdb->auth->pool,
+						args, p);
+			args = p + 1;
+		}
+	}
 
 	module = p_new(auth_userdb->auth->pool,
 		       struct passwd_file_userdb_module, 1);
 	module->auth = auth_userdb->auth;
-	module->pwf =
-		db_passwd_file_init(args, TRUE, module->auth->verbose_debug);
+	module->pwf = db_passwd_file_init(args, format, TRUE,
+					  module->auth->verbose_debug);
 
 	if (!module->pwf->vars)
 		module->module.cache_key = PASSWD_FILE_CACHE_KEY;