[dovecot-cvs] dovecot/src/login-common client-common.c, 1.5, 1.6 client-common.h, 1.11, 1.12 main.c, 1.37, 1.38
tss at dovecot.org
tss at dovecot.org
Sun Dec 3 13:50:47 UTC 2006
Update of /var/lib/cvs/dovecot/src/login-common
In directory talvi:/tmp/cvs-serv31055/src/login-common
Modified Files:
client-common.c client-common.h main.c
Log Message:
Added %a=local port and %b=remote port variables for
login_log_format_elements.
Index: client-common.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/client-common.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- client-common.c 16 Aug 2006 12:16:25 -0000 1.5
+++ client-common.c 3 Dec 2006 13:50:45 -0000 1.6
@@ -23,6 +23,8 @@
{ 'r', NULL },
{ 'p', NULL },
{ 'm', NULL },
+ { 'a', NULL },
+ { 'b', NULL },
{ 'c', NULL },
{ '\0', NULL }
};
@@ -44,10 +46,12 @@
tab[7].value = my_pid;
tab[8].value = client->auth_mech_name == NULL ? NULL :
str_sanitize(client->auth_mech_name, MAX_MECH_NAME);
+ tab[9].value = dec2str(client->local_port);
+ tab[10].value = dec2str(client->remote_port);
if (!client->tls) {
- tab[9].value = client->secured ? "secured" : NULL;
+ tab[11].value = client->secured ? "secured" : NULL;
} else {
- tab[9].value = client->proxy != NULL &&
+ tab[11].value = client->proxy != NULL &&
ssl_proxy_is_handshaked(client->proxy) ? "TLS" :
"TLS handshaking";
}
Index: client-common.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/client-common.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- client-common.h 7 Nov 2006 15:06:26 -0000 1.11
+++ client-common.h 3 Dec 2006 13:50:45 -0000 1.12
@@ -8,6 +8,7 @@
struct client {
struct ip_addr local_ip;
struct ip_addr ip;
+ unsigned int local_port, remote_port;
struct ssl_proxy *proxy;
int fd;
Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/main.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- main.c 10 Aug 2006 21:14:57 -0000 1.37
+++ main.c 3 Dec 2006 13:50:45 -0000 1.38
@@ -61,20 +61,26 @@
static void login_accept(void *context __attr_unused__)
{
- struct ip_addr ip, local_ip;
+ struct ip_addr remote_ip, local_ip;
+ unsigned int remote_port, local_port;
+ struct client *client;
int fd;
- fd = net_accept(LOGIN_LISTEN_FD, &ip, NULL);
+ fd = net_accept(LOGIN_LISTEN_FD, &remote_ip, &remote_port);
if (fd < 0) {
if (fd < -1)
i_fatal("accept() failed: %m");
return;
}
- if (net_getsockname(fd, &local_ip, NULL) < 0)
+ if (net_getsockname(fd, &local_ip, &local_port) < 0) {
memset(&local_ip, 0, sizeof(local_ip));
+ local_port = 0;
+ }
- (void)client_create(fd, FALSE, &local_ip, &ip);
+ client = client_create(fd, FALSE, &local_ip, &remote_ip);
+ client->remote_port = remote_port;
+ client->local_port = local_port;
if (process_per_connection) {
closing_down = TRUE;
@@ -84,27 +90,32 @@
static void login_accept_ssl(void *context __attr_unused__)
{
- struct ip_addr ip, local_ip;
+ struct ip_addr remote_ip, local_ip;
+ unsigned int remote_port, local_port;
struct client *client;
struct ssl_proxy *proxy;
int fd, fd_ssl;
- fd = net_accept(LOGIN_SSL_LISTEN_FD, &ip, NULL);
+ fd = net_accept(LOGIN_SSL_LISTEN_FD, &remote_ip, &remote_port);
if (fd < 0) {
if (fd < -1)
i_fatal("accept() failed: %m");
return;
}
- if (net_getsockname(fd, &local_ip, NULL) < 0)
+ if (net_getsockname(fd, &local_ip, &local_port) < 0) {
memset(&local_ip, 0, sizeof(local_ip));
+ local_port = 0;
+ }
- fd_ssl = ssl_proxy_new(fd, &ip, &proxy);
+ fd_ssl = ssl_proxy_new(fd, &remote_ip, &proxy);
if (fd_ssl == -1)
net_disconnect(fd);
else {
- client = client_create(fd_ssl, TRUE, &local_ip, &ip);
+ client = client_create(fd_ssl, TRUE, &local_ip, &remote_ip);
client->proxy = proxy;
+ client->remote_port = remote_port;
+ client->local_port = local_port;
}
if (process_per_connection) {
@@ -336,8 +347,8 @@
int main(int argc __attr_unused__, char *argv[], char *envp[])
{
const char *name, *group_name;
- struct ip_addr ip, local_ip;
- unsigned int local_port;
+ struct ip_addr remote_ip, local_ip;
+ unsigned int remote_port, local_port;
struct ssl_proxy *proxy = NULL;
struct client *client;
int i, fd = -1, master_fd = -1;
@@ -378,7 +389,7 @@
main_init();
if (is_inetd) {
- if (net_getpeername(1, &ip, NULL) < 0) {
+ if (net_getpeername(1, &remote_ip, &remote_port) < 0) {
i_fatal("%s can be started only through dovecot "
"master process, inetd or equilevant", argv[0]);
}
@@ -398,7 +409,7 @@
/* hardcoded imaps and pop3s ports to be SSL by default */
if (local_port == 993 || local_port == 995 || ssl) {
ssl = TRUE;
- fd = ssl_proxy_new(fd, &ip, &proxy);
+ fd = ssl_proxy_new(fd, &remote_ip, &proxy);
if (fd == -1)
return 1;
}
@@ -407,8 +418,10 @@
closing_down = TRUE;
if (fd != -1) {
- client = client_create(fd, ssl, &local_ip, &ip);
+ client = client_create(fd, ssl, &local_ip, &remote_ip);
client->proxy = proxy;
+ client->remote_port = remote_port;
+ client->local_port = local_port;
}
}
More information about the dovecot-cvs
mailing list