[Bug 252095] syslogd not sending hostname to loghost

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 12 May 2022 18:52:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252095

Bryan Drewery <bdrewery@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bdrewery@FreeBSD.org

--- Comment #1 from Bryan Drewery <bdrewery@FreeBSD.org> ---
The problem is that logger((1) uses capsicum now which ends up forwarding the
entire message to syslog(3) which then adds its own hostname. syslog(3) does
not support passing a hostname.
If using logger -h then capsicum is disabled and the hostname is sent in a
direct socket.


  static void                                                              
  logmessage(int pri, const char *timestamp, const char *hostname,         
      const char *tag, struct socks *sk, ssize_t nsock, const char *buf)   
  {                                                                        
          char *line;                                                      
          int len, i, lsent;                                               

  // nsock != 0 when -h is given                                                
          if (nsock == 0) {                                                
                  cap_syslog(capsyslog, pri, "%s", buf);                   
                  return;                                                  
          }                                                                
  // no capsicum, use custom format with hostname
          if ((len = asprintf(&line, "<%d>%s %s %s: %s", pri, timestamp,   
              hostname, tag, buf)) == -1)                                  
                  errx(1, "asprintf");                                     

          lsent = -1;                                                      
          for (i = 0; i < nsock; i++) {                                    
                  lsent = sendto(sk[i].sk_sock, line, len, 0,              
                                 sstosa(&sk[i].sk_addr), sk[i].sk_addrlen);

-- 
You are receiving this mail because:
You are the assignee for the bug.