From: Timo Sirainen Date: Wed, 20 Aug 2003 23:24:29 +0000 (+0300) Subject: Separated rawlog into it's own binary. X-Git-Tag: 1.1.alpha1~4412 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be5e7de9415b8fb995c0566448a5b3d2c752631e;p=thirdparty%2Fdovecot%2Fcore.git Separated rawlog into it's own binary. --HG-- branch : HEAD --- diff --git a/configure.in b/configure.in index 8e59543047..66dbb6c62a 100644 --- a/configure.in +++ b/configure.in @@ -139,12 +139,6 @@ AC_ARG_WITH(cyrus-sasl2, fi, want_cyrus_sasl2=no) -AC_ARG_WITH(rawlog, -[ --with-rawlog Build support for logging user traffic], - if test x$withval = xyes; then - AC_DEFINE(BUILD_RAWLOG,, Build with rawlogging feature) - fi) - AC_ARG_WITH(ssl, [ --with-ssl=[gnutls|openssl] Build with GNUTLS (default) or OpenSSL], if test x$withval = xno; then @@ -1122,6 +1116,7 @@ src/login-common/Makefile src/master/Makefile src/pop3/Makefile src/pop3-login/Makefile +src/util/Makefile stamp.h dovecot.spec) diff --git a/src/Makefile.am b/src/Makefile.am index 044c97ddd1..d76ee8bb46 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,4 +2,4 @@ if BUILD_POP3D POP3D = pop3-login pop3 endif -SUBDIRS = lib lib-settings lib-charset lib-mail lib-imap lib-index lib-storage auth master login-common imap-login imap $(POP3D) +SUBDIRS = lib lib-settings lib-charset lib-mail lib-imap lib-index lib-storage auth master login-common imap-login imap $(POP3D) util diff --git a/src/imap/Makefile.am b/src/imap/Makefile.am index 892621c1ce..8442b72d46 100644 --- a/src/imap/Makefile.am +++ b/src/imap/Makefile.am @@ -70,8 +70,7 @@ imap_SOURCES = \ imap-thread.c \ mail-storage-callbacks.c \ main.c \ - namespace.c \ - rawlog.c + namespace.c noinst_HEADERS = \ @@ -84,5 +83,4 @@ noinst_HEADERS = \ imap-search.h \ imap-sort.h \ imap-thread.h \ - namespace.h \ - rawlog.h + namespace.h diff --git a/src/imap/main.c b/src/imap/main.c index f2cbe0681e..d457bec658 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -5,7 +5,6 @@ #include "ostream.h" #include "str.h" #include "lib-signals.h" -#include "rawlog.h" #include "restrict-access.h" #include "fd-close-on-exec.h" #include "process-title.h" @@ -88,7 +87,6 @@ static void main_init(void) { struct client *client; const char *user, *str; - int hin, hout; lib_init_signals(sig_quit); @@ -103,9 +101,6 @@ static void main_init(void) capability_string = str_new(default_pool, sizeof(CAPABILITY_STRING)+32); str_append(capability_string, CAPABILITY_STRING); - hin = 0; hout = 1; - rawlog_open(&hin, &hout); - mail_storage_init(); mail_storage_register_all(); clients_init(); @@ -132,7 +127,7 @@ static void main_init(void) MAILBOX_OPEN_MMAP_INVALIDATE : 0; namespace_pool = pool_alloconly_create("namespaces", 1024); - client = client_create(hin, hout, namespace_init(namespace_pool, user)); + client = client_create(0, 1, namespace_init(namespace_pool, user)); o_stream_cork(client->output); if (IS_STANDALONE()) { diff --git a/src/imap/rawlog.h b/src/imap/rawlog.h deleted file mode 100644 index 5778c889dc..0000000000 --- a/src/imap/rawlog.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __RAWLOG_H -#define __RAWLOG_H - -void rawlog_open(int *hin, int *hout); - -#endif diff --git a/src/util/.cvsignore b/src/util/.cvsignore new file mode 100644 index 0000000000..666709a89b --- /dev/null +++ b/src/util/.cvsignore @@ -0,0 +1,9 @@ +*.la +*.lo +*.o +.deps +.libs +Makefile +Makefile.in +so_locations +rawlog diff --git a/src/util/Makefile.am b/src/util/Makefile.am new file mode 100644 index 0000000000..8c708e4df3 --- /dev/null +++ b/src/util/Makefile.am @@ -0,0 +1,10 @@ +bin_PROGRAMS = rawlog + +INCLUDES = \ + -I$(top_srcdir)/src/lib + +rawlog_LDADD = \ + ../lib/liblib.a + +rawlog_SOURCES = \ + rawlog.c diff --git a/src/imap/rawlog.c b/src/util/rawlog.c similarity index 84% rename from src/imap/rawlog.c rename to src/util/rawlog.c index f9ee408976..369e5a673a 100644 --- a/src/imap/rawlog.c +++ b/src/util/rawlog.c @@ -1,9 +1,6 @@ -/* Copyright (C) 2002 Timo Sirainen */ +/* Copyright (C) 2002-2003 Timo Sirainen */ #include "lib.h" -#include "rawlog.h" - -#ifdef BUILD_RAWLOG #include "ioloop.h" #include "network.h" @@ -86,7 +83,7 @@ static void client_input(void *context __attr_unused__) copy(client_in, imap_out, log_in); } -void rawlog_open(int *hin, int *hout) +static void rawlog_open(void) { struct io *io_imap, *io_client; const char *home, *path, *fname; @@ -145,9 +142,11 @@ void rawlog_open(int *hin, int *hout) if (pid > 0) { /* parent */ close(log_in); close(log_out); - close(*hin); close(*hout); close(sfd[0]); - *hin = *hout = sfd[1]; + if (dup2(sfd[1], 0) < 0) + i_fatal("dup2(sfd, 0)"); + if (dup2(sfd[1], 1) < 0) + i_fatal("dup2(sfd, 1)"); return; } close(sfd[1]); @@ -156,8 +155,8 @@ void rawlog_open(int *hin, int *hout) dec2str(parent_pid))); /* child */ - client_in = *hin; - client_out = *hout; + client_in = 0; + client_out = 1; imap_in = sfd[0]; imap_out = sfd[0]; @@ -175,8 +174,28 @@ void rawlog_open(int *hin, int *hout) exit(0); } -#else -void rawlog_open(int *hin __attr_unused__, int *hout __attr_unused__) +int main(int argc, char *argv[], char *envp[]) { + char *executable, *p; + + lib_init(); + process_title_init(argv, envp); + + if (argc < 2) + i_fatal("Usage: rawlog "); + + rawlog_open(); + + argv++; + executable = argv[0]; + + /* hide path, it's ugly */ + p = strrchr(argv[0], '/'); + if (p != NULL) argv[0] = p+1; + execv(executable, argv); + + i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", executable); + + /* not reached */ + return FATAL_EXEC; } -#endif