bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] Problems with commit-inetutils


From: Mats Andersson
Subject: Re: [bug-inetutils] Problems with commit-inetutils
Date: Wed, 20 Jul 2011 01:49:13 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Dear Sergey,

onsdag den 20 juli 2011 klockan 01:51 skrev Sergey Poznyakoff detta:
> Mats Andersson <address@hidden> ha escrit:
> 
> > the mailer daemon return the SCM message to me, claiming the
> > 'address@hidden' is permanently damaged.
> 
> What message did it return, precisely?

Suitably pruned, the mailer-daemon sent the following material.

Regards,
  Mats


Auto-Submitted: auto-replied
From: Mail Delivery System <address@hidden>

Subject: Mail delivery failed: returning message to sender
X-SA-Exim-Version: 4.2.1 (built Wed, 25 Jun 2008 17:14:11 +0000)
X-SA-Exim-Scanned: Yes
Status: RO
Content-Length: 6913
Lines: 199

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  address@hidden
    retry time not reached for any host after a long failure period

------ This is a copy of the message, including all the headers. ------

        for address@hidden; Sun, 17 Jul 2011 00:39:13 +0000
Date: Sun, 17 Jul 2011 00:39:13 +0000
Message-Id: <address@hidden>
To: address@hidden
Subject: [SCM] GNU Inetutils  branch, master, updated. 
inetutils-1_8-108-g13af03e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 7ccaddf1f5f049343b7a85169550374d748916fc
X-Git-Newrev: 13af03e20bc1420c374fa8f96cbed1d2299d8a1e
From: Mats Erik Andersson <......>

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  13af03e20bc1420c374fa8f96cbed1d2299d8a1e (commit)
      from  7ccaddf1f5f049343b7a85169550374d748916fc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=13af03e20bc1420c374fa8f96cbed1d2299d8a1e


commit 13af03e20bc1420c374fa8f96cbed1d2299d8a1e
Author: Mats Erik Andersson <address@hidden>
Date:   Sun Jul 17 02:27:24 2011 +0200

    syslogd: Forwarding independently of remote logging.
    
    Implement temporary INET sockets in order to have
    message forwarding without opening a listening socket.
    Also prevent a failed port lookup from discarding the
    parsing of a configuration file.

diff --git a/ChangeLog b/ChangeLog
index 69c305b..7c9b917 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-17  Mats Erik Andersson <address@hidden>
+
+       * src/syslogd.c (LogPort): Remove variable.
+       (main): Initialize INET socket based only on ACCEPTREMOTE.
+       (fprintlog): Implement forwarding independently of any INET
+       listener.  A socket using TEMP_FINET is initialized as needed.
+       (init): Remove call to `getservbyname()' and variable SP.  They
+       are no longer needed and accidential config loss is now avoided.
+
 2011-07-13  Mats Erik Andersson <address@hidden>
 
        * src/syslogd.c (cfline): Prevent incrementing beyond string end.
diff --git a/src/syslogd.c b/src/syslogd.c
index 4d73f69..a09586c 100644
--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -275,7 +275,6 @@ int usefamily = AF_INET;    /* Address family for INET 
services.
 int finet = -1;                        /* Internet datagram socket fd.  */
 int fklog = -1;                        /* Kernel log device fd.  */
 char *LogPortText = "syslog";  /* Service/port for INET connections.  */
-int LogPort;                   /* LogPortText translated to a numeric value.  
*/
 int Initialized;               /* True when we are initialized. */
 int MarkInterval = 20 * 60;    /* Interval between marks in seconds.  */
 int MarkSeq;                   /* Mark sequence number.  */
@@ -560,8 +559,8 @@ main (int argc, char *argv[])
        }
     }
 
-  /* Initialize inet socket and add them to the list.  */
-  if (AcceptRemote || (!NoForward))
+  /* Initialize inet socket and add it to the list.  */
+  if (AcceptRemote)
     {
       finet = create_inet_socket (usefamily);
       if (finet >= 0)
@@ -1286,10 +1285,48 @@ fprintlog (struct filed *f, const char *from, int 
flags, const char *msg)
        dbg_printf ("Not forwarding remote message.\n");
       else if (NoForward)
        dbg_printf ("Not forwarding because forwarding is disabled.\n");
-      else if (finet < 0)
-       dbg_printf ("Not forwarding because of invalid inet fd.\n");
       else
        {
+         int temp_finet = finet;
+
+         if (temp_finet < 0)
+           {
+             int err;
+             struct addrinfo hints, *rp;
+
+             /* Forwarding needs a temporary socket.
+              * The source port is fixed!  */
+             memset (&hints, 0, sizeof (hints));
+             hints.ai_family = f->f_un.f_forw.f_addr.ss_family;
+             hints.ai_socktype = SOCK_DGRAM;
+             hints.ai_flags = AI_PASSIVE;
+
+             err = getaddrinfo (NULL, LogPortText, &hints, &rp);
+             if (err)
+               {
+                 dbg_printf ("Not forwarding due to lookup failure: %s.\n",
+                             gai_strerror(err));
+                 break;
+               }
+             temp_finet = socket (rp->ai_family, rp->ai_socktype,
+                                  rp->ai_protocol);
+             if (temp_finet < 0)
+               {
+                 dbg_printf ("Not forwarding due to socket failure.\n");
+                 freeaddrinfo (rp);
+                 break;
+               }
+
+             err = bind (temp_finet, rp->ai_addr, rp->ai_addrlen);
+             freeaddrinfo (rp);
+             if (err)
+               {
+                 dbg_printf ("Not forwarding due to bind error: %s.\n",
+                             strerror (errno));
+                 break;
+               }
+           } /* Creation of temporary outgoing socket since "finet < 0" */
+
          f->f_time = now;
          snprintf (line, sizeof (line), "<%d>%.15s %s",
                    f->f_prevpri, (char *) iov[0].iov_base,
@@ -1297,7 +1334,7 @@ fprintlog (struct filed *f, const char *from, int flags, 
const char *msg)
          l = strlen (line);
          if (l > MAXLINE)
            l = MAXLINE;
-         if (sendto (finet, line, l, 0,
+         if (sendto (temp_finet, line, l, 0,
                      (struct sockaddr *) &f->f_un.f_forw.f_addr,
                      f->f_un.f_forw.f_addrlen) != l)
            {
@@ -1307,6 +1344,9 @@ fprintlog (struct filed *f, const char *from, int flags, 
const char *msg)
              errno = e;
              logerror ("sendto");
            }
+
+         if (finet < 0)
+           close (temp_finet); /* Only temporary socket may be closed.  */
        }
       break;
 
@@ -1611,19 +1651,8 @@ init (int signo _GL_UNUSED_PARAMETER)
   char *cbuf;
   char *cline;
   int cont_line = 0;
-  struct servent *sp;
 
   dbg_printf ("init\n");
-  sp = getservbyname (LogPortText, "udp");
-  if (sp == NULL)
-    {
-      errno = 0;
-      logerror ("network logging disabled (syslog/udp service unknown).");
-      logerror
-       ("see syslogd(8) for details of whether and how to enable it.");
-      return;
-    }
-  LogPort = sp->s_port;
 
   /* Close all open log files.  */
   Initialized = 0;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog     |    9 ++++++++
 src/syslogd.c |   63 +++++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 55 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]