client-common.c revision 19e8adccba16ff419f5675b1575358c2956dce83
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
2cfe9983ce7a6280636ee12beccc2e865111967bTimo Sirainenunsigned int clients_count = 0;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenunsigned int clients_get_count(void)
ccc895c0358108d2304239063e940b7d75f364abTimo Sirainenstatic const struct var_expand_table *
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen static struct var_expand_table static_tab[] = {
b6a7e0a7899e7f5d60c23cdaa50e025e4c67d05fTimo Sirainen unsigned int i;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen tab[1].value = t_strcut(client->virtual_user, '@');
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen tab[2].value = strchr(client->virtual_user, '@');
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (i = 0; i < 3; i++)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen tab[i].value = str_sanitize(tab[i].value, 80);
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen tab[5].value = net_ip2addr(&client->local_ip);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen tab[8].value = client->auth_mech_name == NULL ? NULL :
55773f17bccf6361d6599ffcbe072d7c9fe205bfTimo Sirainen str_sanitize(client->auth_mech_name, MAX_MECH_NAME);
992a13add4eea0810e4db0f042a595dddf85536aTimo Sirainen tab[11].value = client->secured ? "secured" : NULL;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ssl_proxy_is_handshaked(client->proxy) ? "TLS" :
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen "TLS handshaking";
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainenstatic bool have_key(const struct var_expand_table *table, const char *str)
b6a7e0a7899e7f5d60c23cdaa50e025e4c67d05fTimo Sirainen unsigned int i;
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainenstatic void client_syslog_real(struct client *client, const char *msg)
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen static struct var_expand_table static_tab[3] = {
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen const struct var_expand_table *var_expand_table;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *p, *const *e;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen var_expand_table = get_var_expand_table(client);
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen for (e = log_format_elements; *e != NULL; e++) {
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen for (p = *e; *p != '\0'; p++) {
641f0c0900ee6e7cf9667f4b40ed95cec7d0cdcaTimo Sirainenvoid client_syslog(struct client *client, const char *msg)