]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
- if ipulog_read fails, print errno and ulog_errno
authorlaforge <laforge>
Tue, 30 Jul 2002 07:04:11 +0000 (07:04 +0000)
committerlaforge <laforge>
Tue, 30 Jul 2002 07:04:11 +0000 (07:04 +0000)
- close stdin and call setsid() when we daemonize
- make logfile rotate work
- add comment about log levels to ulogd.conf

TODO
libipulog/include/libipulog/libipulog.h
libipulog/libipulog.c
ulogd.c
ulogd.conf

diff --git a/TODO b/TODO
index 55b3632fa926b3a771ba3760a94a3619badf4f95..c11e2cb6606091a8241af3fee45f174e23977e08 100644 (file)
--- a/TODO
+++ b/TODO
@@ -16,13 +16,13 @@ X syslog compatibility output plugin
 - autoconf-detection of ipt_ULOG.h
 - _fini() support for plugin destructors (needed for clean shutdown and 
   SIGHUP configfile reload
-- commandline option for "to fork or not to fork"
-- various command line options (we don't even have --version)
+X commandline option for "to fork or not to fork"
+X various command line options (we don't even have --version)
 - add support for capabilities to run as non-root
 - big endian fixes
 - man pages
 - IPv6 support (core and extensions)
-- pcap output plugin (to use ethereal/tcpdump/... for the logs)
+X pcap output plugin (to use ethereal/tcpdump/... for the logs)
 
 conffile:
 - rewrite. This stuff is a real mess.
index 698c33f1651e7104940de9fb657b1a52b015a67e..78f4220997efccbbd2371299449808e521bfe28b 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _LIBIPULOG_H
 #define _LIBIPULOG_H
 
-/* $Id: libipulog.h,v 1.3 2001/05/21 19:15:16 laforge Exp $ */
+/* $Id: libipulog.h,v 1.4 2001/07/03 14:45:16 laforge Exp $ */
 
 #include <errno.h>
 #include <unistd.h>
@@ -35,6 +35,8 @@ ulog_packet_msg_t *ipulog_get_packet(struct ipulog_handle *h,
                                     const unsigned char *buf,
                                     size_t len);
 
+char *ipulog_strerror(int errcode);
+
 void ipulog_perror(const char *s);
 
 #endif /* _LIBULOG_H */
index 10fb833fab7405a504f10d3d7e7167c9f84e6f4d..bee00385d4ea0cbf534bd6a389a5586201d5e8f7 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * libipulog.c, $Revision: 1.8 $
+ * libipulog.c, $Revision: 1.9 $
  *
  * netfilter ULOG userspace library.
  *
@@ -21,7 +21,7 @@
  * This library is still under development, so be aware of sudden interface
  * changes
  *
- * $Id: libipulog.c,v 1.8 2001/07/04 00:22:54 laforge Exp $
+ * $Id: libipulog.c,v 1.9 2001/09/01 11:53:41 laforge Exp $
  */
 
 #include <stdlib.h>
@@ -59,7 +59,7 @@ enum
 
 #define IPULOG_MAXERR IPULOG_ERR_INVNL
 
-static int ipulog_errno = IPULOG_ERR_NONE;
+int ipulog_errno = IPULOG_ERR_NONE;
 
 struct ipulog_errmap_t 
 {
@@ -118,16 +118,15 @@ ipulog_netlink_recvfrom(const struct ipulog_handle *h,
        return status;
 }
 
-static char *ipulog_strerror(int errcode)
+/* public */
+
+char *ipulog_strerror(int errcode)
 {
        if (errcode < 0 || errcode > IPULOG_MAXERR)
                errcode = IPULOG_ERR_IMPL;
        return ipulog_errmap[errcode].message;
 }
 
-
-/* public */
-
 /* convert a netlink group (1-32) to a group_mask suitable for create_handle */
 u_int32_t ipulog_group2gmask(u_int32_t group)
 {
diff --git a/ulogd.c b/ulogd.c
index 19d5d536ec7ffe5c177f0d51bf42c8472ffbd553..55ec461d18cd7d8529eb528f70646c8159aaf6f9 100644 (file)
--- a/ulogd.c
+++ b/ulogd.c
@@ -1,6 +1,6 @@
-/* ulogd, Version $Revision: 1.24 $
+/* ulogd, Version $Revision: 1.25 $
  *
- * $Id: ulogd.c,v 1.24 2002/04/16 12:44:41 laforge Exp $
+ * $Id: ulogd.c,v 1.25 2002/06/13 12:57:25 laforge Exp $
  *
  * userspace logging daemon for the netfilter ULOG target
  * of the linux 2.4 netfilter subsystem.
@@ -20,7 +20,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: ulogd.c,v 1.24 2002/04/16 12:44:41 laforge Exp $
+ * $Id: ulogd.c,v 1.25 2002/06/13 12:57:25 laforge Exp $
  *
  * Modifications:
  *     14 Jun 2001 Martin Josefsson <gandalf@wlug.westbo.se>
@@ -544,6 +544,13 @@ static void sighup_handler(int signal)
 {
        ulog_output_t *p;
 
+       if (logfile != stdout) {
+               fclose(logfile);
+               logfile = fopen(logf_ce.u.string, "a");
+               if (!logfile)
+                       sigterm_handler(signal);
+       }
+
        ulogd_log(ULOGD_NOTICE, "sighup received, calling plugin handlers\n");
        
        for (p = ulogd_outputs; p; p = p->next) {
@@ -639,6 +646,8 @@ int main(int argc, char* argv[])
                if (logfile != stdout)
                        fclose(stdout);
                fclose(stderr);
+               fclose(stdin);
+               setsid();
        }
 
        signal(SIGTERM, &sigterm_handler);
@@ -653,8 +662,9 @@ int main(int argc, char* argv[])
 
                if (len <= 0) {
                        /* this is not supposed to happen */
-                       ulogd_log(ULOGD_ERROR, "ipulog_read == %d!\n",
-                                 len);
+                       ulogd_log(ULOGD_ERROR, "ipulog_read == %d! "
+                                 "ipulog_errno == %d, errno = %d\n",
+                                 len, ipulog_errno, errno);
                } else {
                        while (upkt = ipulog_get_packet(libulog_h,
                                               libulog_buf, len)) {
index a4d1fc10a51266589dd8a68df9564ceab300aa65..a3a998a84a152d884ebd0999a1ca5aa04f070b9c 100644 (file)
@@ -1,5 +1,5 @@
 # Example configuration for ulogd
-# $Id: ulogd.conf,v 1.5 2001/05/20 14:44:37 laforge Exp $
+# $Id: ulogd.conf,v 1.6 2001/10/02 16:39:17 laforge Exp $
 #
 
 ######################################################################
@@ -12,7 +12,7 @@ nlgroup 1
 # logfile for status messages
 logfile /var/log/ulogd.log
 
-# loglevel: notice, warnings, error and fatal
+# loglevel: debug(1), info(3), notice(5), error(7) or fatal(8)
 loglevel 5
 
 ######################################################################