~kroq-gar78/ubuntu/precise/rsyslog/fix-846818

« back to all changes in this revision

Viewing changes to net.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2008-07-23 02:22:32 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080723022232-496osxty0v9vvw9g
Tags: 3.18.1-1
* New upstream release. Closes: #490445
  - List Debian in doc/rsyslog_packages.html. Closes: #488870
  - Fix compilation of imklog module on GNU/kFreeBSD. Closes: #491193
* debian/rsyslog-doc.install
  - Install the example config file. Closes: #488860
* debian/rules
  - Enable mail output plugin.
  - Make sure all directories are created by calling dh_installdirs for both
    binary-arch and binary-indep. Closes: #491459
* debian/rsyslog.install
  - Install mail output plugin (ommail.so).
* debian/control
  - Add Suggests www-browser to rsyslog-doc as the package contains mostly
    html documents.
  - Update feature list.
  - Adjust priorities, set rsyslog priority to important.

Show diffs side-by-side

added added

removed removed

Lines of Context:
580
580
static int
581
581
should_use_so_bsdcompat(void)
582
582
{
583
 
#ifndef BSD
 
583
#ifndef OS_BSD
584
584
    static int init_done;
585
585
    static int so_bsdcompat_is_obsolete;
586
586
 
608
608
            so_bsdcompat_is_obsolete = 1;
609
609
    }
610
610
    return !so_bsdcompat_is_obsolete;
611
 
#else   /* #ifndef BSD */
 
611
#else   /* #ifndef OS_BSD */
612
612
    return 1;
613
 
#endif  /* #ifndef BSD */
 
613
#endif  /* #ifndef OS_BSD */
614
614
}
615
615
#ifndef SO_BSDCOMPAT
616
616
/* this shall prevent compiler errors due to undfined name */
852
852
}
853
853
 
854
854
 
 
855
/* get the name of the local host. A pointer to a character pointer is passed
 
856
 * in, which on exit points to the local hostname. This buffer is dynamically
 
857
 * allocated and must be free()ed by the caller. If the functions returns an
 
858
 * error, the pointer is NULL. This function is based on GNU/Hurd's localhostname
 
859
 * function.
 
860
 * rgerhards, 20080-04-10
 
861
 */
 
862
static rsRetVal
 
863
getLocalHostname(uchar **ppName)
 
864
{
 
865
        DEFiRet;
 
866
        uchar *buf = NULL;
 
867
        size_t buf_len = 0;
 
868
 
 
869
        assert(ppName != NULL);
 
870
 
 
871
        do {
 
872
                if(buf == NULL) {
 
873
                        buf_len = 128;        /* Initial guess */
 
874
                        CHKmalloc(buf = malloc(buf_len));
 
875
                } else {
 
876
                        buf_len += buf_len;
 
877
                        CHKmalloc(buf = realloc (buf, buf_len));
 
878
                }
 
879
        } while((gethostname((char*)buf, buf_len) == 0 && !memchr (buf, '\0', buf_len)) || errno == ENAMETOOLONG);
 
880
 
 
881
        *ppName = buf;
 
882
        buf = NULL;
 
883
 
 
884
finalize_it:
 
885
        if(iRet != RS_RET_OK) {
 
886
                if(buf != NULL)
 
887
                        free(buf);
 
888
        }
 
889
        RETiRet;
 
890
}
 
891
 
 
892
 
855
893
/* closes the UDP listen sockets (if they exist) and frees
856
894
 * all dynamically assigned memory. 
857
895
 */
948
986
                /* We need to enable BSD compatibility. Otherwise an attacker
949
987
                 * could flood our log files by sending us tons of ICMP errors.
950
988
                 */
951
 
#if !defined(BSD) && !defined(__hpux)
 
989
#if !defined(OS_BSD) && !defined(__hpux)
952
990
                if (should_use_so_bsdcompat()) {
953
991
                        if (setsockopt(*s, SOL_SOCKET, SO_BSDCOMPAT,
954
992
                                        (char *) &on, sizeof(on)) < 0) {
1047
1085
        pIf->closeUDPListenSockets = closeUDPListenSockets;
1048
1086
        pIf->isAllowedSender = isAllowedSender;
1049
1087
        pIf->should_use_so_bsdcompat = should_use_so_bsdcompat;
 
1088
        pIf->getLocalHostname = getLocalHostname;
1050
1089
finalize_it:
1051
1090
ENDobjQueryInterface(net)
1052
1091