]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Separated rawlog into it's own binary.
authorTimo Sirainen <tss@iki.fi>
Wed, 20 Aug 2003 23:24:29 +0000 (02:24 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 20 Aug 2003 23:24:29 +0000 (02:24 +0300)
--HG--
branch : HEAD

configure.in
src/Makefile.am
src/imap/Makefile.am
src/imap/main.c
src/imap/rawlog.h [deleted file]
src/util/.cvsignore [new file with mode: 0644]
src/util/Makefile.am [new file with mode: 0644]
src/util/rawlog.c [moved from src/imap/rawlog.c with 84% similarity]

index 8e59543047ebe569bd9cf506b0f090eaafc1c9bc..66dbb6c62a74ee60be62346d23256c3abcc9c9f5 100644 (file)
@@ -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)
 
index 044c97ddd1d89f79b30918922837b5740f9f6da8..d76ee8bb46d01a8d0ec9de21626e5cfb5a344718 100644 (file)
@@ -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
index 892621c1ce9a922e26cfd5d0748b11fe38c5ab0d..8442b72d468e906785739b55e3ea7d20e2cecfe2 100644 (file)
@@ -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
index f2cbe0681e8b1b297abb173600ffc00150288c1c..d457bec658ee671065ecfcfe92915670d8b84224 100644 (file)
@@ -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 (file)
index 5778c88..0000000
+++ /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 (file)
index 0000000..666709a
--- /dev/null
@@ -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 (file)
index 0000000..8c708e4
--- /dev/null
@@ -0,0 +1,10 @@
+bin_PROGRAMS = rawlog
+
+INCLUDES = \
+       -I$(top_srcdir)/src/lib
+
+rawlog_LDADD = \
+       ../lib/liblib.a
+
+rawlog_SOURCES = \
+       rawlog.c
similarity index 84%
rename from src/imap/rawlog.c
rename to src/util/rawlog.c
index f9ee408976e6dab4eb4669efa767729bf0823e1d..369e5a673a22254cfb4ac2b3cae06ac4bcfd87f4 100644 (file)
@@ -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 <binary> <arguments>");
+
+       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