Changeset 283 for trunk/src/sh_error.c


Ignore:
Timestamp:
May 4, 2010, 10:28:11 PM (15 years ago)
Author:
katerina
Message:

Patch for ticket #207 (server logs client reports to prelude).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_error.c

    r272 r283  
    841841#ifdef SH_WITH_SERVER
    842842static char inet_peer[SH_MINIBUF] = { '\0' };
     843#ifdef HAVE_LIBPRELUDE
     844static char inet_peer_ip[SH_IP_BUF] = { '\0' };
     845
     846void sh_error_set_peer_ip(const char * str)
     847{
     848  if (str == NULL)
     849    inet_peer_ip[0] = '\0';
     850  else
     851    sl_strlcpy(inet_peer_ip, str, sizeof(inet_peer_ip));
     852}
     853#endif
    843854
    844855void sh_error_set_peer(const char * str)
     
    847858    inet_peer[0] = '\0';
    848859  else
    849     sl_strlcpy(inet_peer, str, SH_MINIBUF);
     860    sl_strlcpy(inet_peer, str, sizeof(inet_peer));
    850861}
    851862#endif
     
    880891  int    class_inet = clt_class;      /* initialize from global */
    881892  char   local_inet_peer[SH_MINIBUF];
     893#ifdef HAVE_LIBPRELUDE
     894  char   local_inet_peer_ip[SH_IP_BUF];
     895#endif   
    882896#endif
    883897
     
    924938  if ((msg_id == MSG_TCP_MSG) && (inet_peer[0] != '\0'))
    925939    {
    926       sl_strlcpy(local_inet_peer, inet_peer, SH_MINIBUF);
     940      sl_strlcpy(local_inet_peer, inet_peer, sizeof(local_inet_peer));
    927941      sh_error_set_peer(NULL);
    928942    }
    929943  else
    930944    local_inet_peer[0] = '\0';
     945
     946#ifdef HAVE_LIBPRELUDE
     947  if ((msg_id == MSG_TCP_MSG) && (inet_peer_ip[0] != '\0'))
     948    {
     949      sl_strlcpy(local_inet_peer_ip, inet_peer_ip, sizeof(local_inet_peer_ip));
     950      sh_error_set_peer_ip(NULL);
     951    }
     952  else
     953    local_inet_peer_ip[0] = '\0';
     954#endif
    931955
    932956  clt_class = (-1);      /* reset global */
     
    12631287               *  Reports first error after failure. Always tries.
    12641288               */
    1265               (void) sh_prelude_alert (severity, (int) class, lmsg->msg,
    1266                                        lmsg->status, msg_id);
    1267 
     1289#if defined(HAVE_LIBPRELUDE) && defined(SH_WITH_SERVER)
     1290              (void) sh_prelude_alert (severity, (int) class,
     1291                                       lmsg->msg, lmsg->status, msg_id,
     1292                                       local_inet_peer_ip);
     1293#else
     1294              (void) sh_prelude_alert (severity, (int) class,
     1295                                       lmsg->msg, lmsg->status, msg_id,
     1296                                       NULL);
     1297#endif
    12681298              prelude_block = 0;
    12691299            }
     
    13011331                    (void) sh_log_file (lmsg->msg, NULL);
    13021332                  else
    1303                     (void) sh_log_file (lmsg->msg, local_inet_peer);
     1333                    (void) sh_log_file (lmsg->msg, local_inet_peer);
    13041334                }
    13051335#else
Note: See TracChangeset for help on using the changeset viewer.