[dovecot-cvs] dovecot/src/auth userdb-static.c,1.6,1.7

cras at dovecot.org cras at dovecot.org
Sat Aug 28 23:07:41 EEST 2004


Update of /home/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv32275

Modified Files:
	userdb-static.c 
Log Message:
Added mail setting and made home optional.



Index: userdb-static.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/userdb-static.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- userdb-static.c	24 May 2004 22:33:50 -0000	1.6
+++ userdb-static.c	28 Aug 2004 20:07:39 -0000	1.7
@@ -14,7 +14,7 @@
 
 static uid_t static_uid;
 static gid_t static_gid;
-static char *static_home_template;
+static char *static_home_template, *static_mail_template;
 
 static void static_lookup(struct auth_request *auth_request,
 			  userdb_callback_t *callback, void *context)
@@ -28,10 +28,20 @@
 
 	data.virtual_user = data.system_user = auth_request->user;
 
-	str = t_str_new(256);
-	var_expand(str, static_home_template,
-		   auth_request_get_var_expand_table(auth_request, NULL));
-	data.home = str_c(str);
+	if (static_home_template != NULL) {
+		str = t_str_new(256);
+		var_expand(str, static_home_template,
+			   auth_request_get_var_expand_table(auth_request,
+							     NULL));
+		data.home = str_c(str);
+	}
+	if (static_mail_template != NULL) {
+		str = t_str_new(256);
+		var_expand(str, static_mail_template,
+			   auth_request_get_var_expand_table(auth_request,
+							     NULL));
+		data.mail = str_c(str);
+	}
 
 	callback(&data, context);
 }
@@ -43,6 +53,7 @@
 	static_uid = 0;
 	static_gid = 0;
 	static_home_template = NULL;
+	static_mail_template = NULL;
 
 	for (tmp = t_strsplit_spaces(args, " "); *tmp != NULL; tmp++) {
 		if (strncasecmp(*tmp, "uid=", 4) == 0)
@@ -52,6 +63,9 @@
 		else if (strncasecmp(*tmp, "home=", 5) == 0) {
 			i_free(static_home_template);
 			static_home_template = i_strdup(*tmp + 5);
+		} else if (strncasecmp(*tmp, "mail=", 5) == 0) {
+			i_free(static_mail_template);
+			static_mail_template = i_strdup(*tmp + 5);
 		} else {
 			i_fatal("Invalid static userdb option: '%s'", *tmp);
 		}
@@ -61,13 +75,12 @@
 		i_fatal("static userdb: uid missing");
 	if (static_gid == 0)
 		i_fatal("static userdb: gid missing");
-	if (static_home_template == NULL)
-		i_fatal("static userdb: home option missing");
 }
 
 static void static_deinit(void)
 {
 	i_free(static_home_template);
+	i_free(static_mail_template);
 }
 
 struct userdb_module userdb_static = {



More information about the dovecot-cvs mailing list