Hi,
i'm using dovecot with rawlog enabled. Well, i need to log the IP of the user, too. Could you give me a hint, how this can be implemented?
Thanks and regards, Andreas Goertz.
On Fri, 2005-03-11 at 10:13 +0100, Andreas Goertz wrote:
i'm using dovecot with rawlog enabled. Well, i need to log the IP of the user, too. Could you give me a hint, how this can be implemented?
0.99.x or 1.0-test? In any case to rawlog.c something like:
struct ip_addr ip; if (net_getpeername(proxy->client_in_fd, &ip, NULL) == 0) i_info("ip address = %s", net_ip2addr(&ip));
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Timo,
| 0.99.x or 1.0-test? In any case to rawlog.c something like:
i'm using 0.99.x
| struct ip_addr ip; | if (net_getpeername(proxy->client_in_fd, &ip, NULL) == 0) | i_info("ip address = %s", net_ip2addr(&ip));
I'll try this. Thank you so far ;-)
Regards, Andreas Goertz.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Timo,
| 0.99.x or 1.0-test? In any case to rawlog.c something like:
0.99.14
| struct ip_addr ip; | if (net_getpeername(proxy->client_in_fd, &ip, NULL) == 0) | i_info("ip address = %s", net_ip2addr(&ip));
no - this patch doesn't seem to work, because in rawlog.c proxy is not declared. So i looked for the call to rawlog_open() and saw that it's only called from main.c in imap and pop3 folder. But there also is no proxy declared. Do you have another idea? Thanks in advance.
Regards, Andreas Goertz.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Timo,
Andreas Goertz schrieb: | Hi Timo, | | | 0.99.x or 1.0-test? In any case to rawlog.c something like: | | 0.99.14 | | | struct ip_addr ip; | if (net_getpeername(proxy->client_in_fd, &ip, | NULL) == 0) | i_info("ip address = %s", net_ip2addr(&ip)); | | no - this patch doesn't seem to work, because in rawlog.c proxy is | not declared. So i looked for the call to rawlog_open() and saw that | it's only called from main.c in imap and pop3 folder. But there also | is no proxy declared. Do you have another idea? Thanks in advance.
Hmm - while searching for another solution i found the function client_syslog() in imap-login/client.c. If i understand it correctly, i_info() only writes to the syslog and i have no clue, how to write into rawlog from client.c respectively client_syslog().
Is it possible to write from imap-login/client.c into rawlog? For remember: i'm using 0.99.14.
Thanks and regards, Andreas Goertz.
On Tue, 2005-03-15 at 10:45 +0100, Andreas Goertz wrote:
| no - this patch doesn't seem to work, because in rawlog.c proxy is | not declared. So i looked for the call to rawlog_open() and saw that | it's only called from main.c in imap and pop3 folder. But there also | is no proxy declared. Do you have another idea? Thanks in advance.
That code was for 1.0-tests, 0.99.x has entirely different rawlog code.
Hmm - while searching for another solution i found the function client_syslog() in imap-login/client.c. If i understand it correctly, i_info() only writes to the syslog and i have no clue, how to write into rawlog from client.c respectively client_syslog().
Only rawlog.c knows about rawlog, it's also running as separate process so it's not even possible to see it in client.c code.
Here's a patch for 0.99.14:
--- rawlog.c.old 2005-03-15 22:59:52.731934694 +0200 +++ rawlog.c 2005-03-15 23:01:10.535201787 +0200 @@ -89,6 +89,7 @@ void rawlog_open(int *hin, int *hout) { struct io *io_imap, *io_client;
- struct ip_addr ip; const char *home, *path, *fname; char timestamp[50]; struct tm *tm;
@@ -131,6 +132,11 @@ return; }
- if (net_getpeername(0, &ip, NULL) == 0) {
str = t_strdup_printf("IP: %s\n", net_ip2addr(&ip));
write_full(log_out, str, strlen(str));
- }
- /* we need to fork the rawlog writer to separate process since imap process does blocking writes. */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Timo Sirainen schrieb: | On Tue, 2005-03-15 at 10:45 +0100, Andreas Goertz wrote: | |>| no - this patch doesn't seem to work, because in rawlog.c proxy is |>| not declared. So i looked for the call to rawlog_open() and saw that |>| it's only called from main.c in imap and pop3 folder. But there also |>| is no proxy declared. Do you have another idea? Thanks in advance. | | | That code was for 1.0-tests, 0.99.x has entirely different rawlog code.
ah - i see.
|>Hmm - while searching for another solution i found the function |>client_syslog() in imap-login/client.c. If i understand it correctly, |>i_info() only writes to the syslog and i have no clue, how to write into |>rawlog from client.c respectively client_syslog(). | | | Only rawlog.c knows about rawlog, it's also running as separate process | so it's not even possible to see it in client.c code. | | Here's a patch for 0.99.14:
thank you very much Timo, i'll try this out ;-)
| | --- rawlog.c.old 2005-03-15 22:59:52.731934694 +0200 | +++ rawlog.c 2005-03-15 23:01:10.535201787 +0200 | @@ -89,6 +89,7 @@ | void rawlog_open(int *hin, int *hout) | { | struct io *io_imap, *io_client; | + struct ip_addr ip; | const char *home, *path, *fname; | char timestamp[50]; | struct tm *tm; | @@ -131,6 +132,11 @@ | return; | } | | + if (net_getpeername(0, &ip, NULL) == 0) { | + str = t_strdup_printf("IP: %s\n", net_ip2addr(&ip)); | + write_full(log_out, str, strlen(str)); | + } | + | /* we need to fork the rawlog writer to separate process since | imap process does blocking writes. */ | if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0) |
Regards, Andreas.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi Timo,
i got a new problem :-/ Generally, this code works fine, but when using SSL, it doesn't - it only prints 'null' in rawlog. Could you give me another hint please?
To remind: i needed to rawlog the client's ip on connect and am using dovecot 0.99.14.
Thanks in advance ;-)
Regards, Andreas.
Andreas Goertz schrieb:
Timo Sirainen schrieb: | On Tue, 2005-03-15 at 10:45 +0100, Andreas Goertz wrote: | |>| no - this patch doesn't seem to work, because in rawlog.c proxy is |>| not declared. So i looked for the call to rawlog_open() and saw that |>| it's only called from main.c in imap and pop3 folder. But there also |>| is no proxy declared. Do you have another idea? Thanks in advance. | | | That code was for 1.0-tests, 0.99.x has entirely different rawlog code.
ah - i see.
|>Hmm - while searching for another solution i found the function |>client_syslog() in imap-login/client.c. If i understand it correctly, |>i_info() only writes to the syslog and i have no clue, how to write into |>rawlog from client.c respectively client_syslog(). | | | Only rawlog.c knows about rawlog, it's also running as separate process | so it's not even possible to see it in client.c code. | | Here's a patch for 0.99.14:
thank you very much Timo, i'll try this out ;-)
| | --- rawlog.c.old 2005-03-15 22:59:52.731934694 +0200 | +++ rawlog.c 2005-03-15 23:01:10.535201787 +0200 | @@ -89,6 +89,7 @@ | void rawlog_open(int *hin, int *hout) | { | struct io *io_imap, *io_client; | + struct ip_addr ip; | const char *home, *path, *fname; | char timestamp[50]; | struct tm *tm; | @@ -131,6 +132,11 @@ | return; | } | | + if (net_getpeername(0, &ip, NULL) == 0) { | + str = t_strdup_printf("IP: %s\n", net_ip2addr(&ip)); | + write_full(log_out, str, strlen(str)); | + } | + | /* we need to fork the rawlog writer to separate process since | imap process does blocking writes. */ | if (socketpair(AF_UNIX, SOCK_STREAM, 0, sfd) < 0) |
Regards, Andreas.
participants (2)
-
Andreas Goertz
-
Timo Sirainen