dovecot-2.0-sslstream: login_greeting setting now supports %vari...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 02:55:31 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0-sslstream/rev/ae2d8b121f91
changeset: 10155:ae2d8b121f91
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 22 21:37:03 2009 -0400
description:
login_greeting setting now supports %variables.

diffstat:

1 file changed, 30 insertions(+), 1 deletion(-)
src/login-common/login-settings.c |   31 ++++++++++++++++++++++++++++++-

diffs (62 lines):

diff -r 23cdea955eb3 -r ae2d8b121f91 src/login-common/login-settings.c
--- a/src/login-common/login-settings.c	Thu Oct 22 21:27:04 2009 -0400
+++ b/src/login-common/login-settings.c	Thu Oct 22 21:37:03 2009 -0400
@@ -1,6 +1,8 @@
 /* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
 
 #include "common.h"
+#include "hostpid.h"
+#include "var-expand.h"
 #include "settings-parser.h"
 #include "master-service-settings.h"
 #include "login-settings.h"
@@ -16,7 +18,7 @@ static bool login_settings_check(void *_
 
 static struct setting_define login_setting_defines[] = {
 	DEF(SET_STR, login_trusted_networks),
-	DEF(SET_STR, login_greeting),
+	DEF(SET_STR_VARS, login_greeting),
 	DEF(SET_STR, login_log_format_elements),
 	DEF(SET_STR, login_log_format),
 
@@ -155,6 +157,30 @@ static bool login_settings_check(void *_
 }
 /* </settings checks> */
 
+static const struct var_expand_table *
+login_set_var_expand_table(const struct master_service_settings_input *input)
+{
+	static struct var_expand_table static_tab[] = {
+		{ 'l', NULL, "lip" },
+		{ 'r', NULL, "rip" },
+		{ 'p', NULL, "pid" },
+		{ 's', NULL, "service" },
+		{ '\0', NULL, "hostname" },
+		{ '\0', NULL, NULL }
+	};
+	struct var_expand_table *tab;
+
+	tab = t_malloc(sizeof(static_tab));
+	memcpy(tab, static_tab, sizeof(static_tab));
+
+	tab[0].value = net_ip2addr(&input->local_ip);
+	tab[1].value = net_ip2addr(&input->remote_ip);
+	tab[2].value = my_pid;
+	tab[3].value = input->service;
+	tab[4].value = my_hostname;
+	return tab;
+}
+
 struct login_settings *
 login_settings_read(struct master_service *service, pool_t pool,
 		    const struct ip_addr *local_ip,
@@ -192,6 +218,9 @@ login_settings_read(struct master_servic
 		}
 	}
 
+	settings_var_expand(&login_setting_parser_info, sets[0], pool,
+			    login_set_var_expand_table(&input));
+
 	*other_settings_r = sets + 1;
 	return sets[0];
 }


More information about the dovecot-cvs mailing list