sysklogd-1.4.2-caen-owl-syslogd-bind.diff 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. http://cvsweb.openwall.com/cgi/cvsweb.cgi/~checkout~/Owl/packages/sysklogd/sysklogd-1.4.2-caen-owl-syslogd-bind.diff?rev=1.1;content-type=text%2Fplain
  2. diff -upk.orig sysklogd-1.4.2.orig/sysklogd.8 sysklogd-1.4.2/sysklogd.8
  3. --- sysklogd-1.4.2.orig/sysklogd.8 2004-07-09 17:33:32 +0000
  4. +++ sysklogd-1.4.2/sysklogd.8 2005-08-18 14:40:25 +0000
  5. @@ -15,6 +15,9 @@ sysklogd \- Linux system logging utiliti
  6. .I config file
  7. ]
  8. .RB [ " \-h " ]
  9. +.RB [ " \-i "
  10. +.I IP address
  11. +]
  12. .RB [ " \-l "
  13. .I hostlist
  14. ]
  15. @@ -104,6 +107,13 @@ Specifying this switch on the command li
  16. This can cause syslog loops that fill up hard disks quite fast and
  17. thus needs to be used with caution.
  18. .TP
  19. +.BI "\-i " "IP address"
  20. +If
  21. +.B syslogd
  22. +is configured to accept log input from a UDP port, specify an IP address
  23. +to bind to, rather than the default of INADDR_ANY. The address must be in
  24. +dotted quad notation, DNS host names are not allowed.
  25. +.TP
  26. .BI "\-l " "hostlist"
  27. Specify a hostname that should be logged only with its simple hostname
  28. and not the fqdn. Multiple hosts may be specified using the colon
  29. diff -upk.orig sysklogd-1.4.2.orig/syslogd.c sysklogd-1.4.2/syslogd.c
  30. --- sysklogd-1.4.2.orig/syslogd.c 2005-08-18 14:33:22 +0000
  31. +++ sysklogd-1.4.2/syslogd.c 2005-08-18 14:40:25 +0000
  32. @@ -774,6 +774,8 @@ char **LocalHosts = NULL; /* these hosts
  33. int NoHops = 1; /* Can we bounce syslog messages through an
  34. intermediate host. */
  35. +char *bind_addr = NULL; /* bind UDP port to this interface only */
  36. +
  37. extern int errno;
  38. /* Function prototypes. */
  39. @@ -878,7 +880,7 @@ int main(argc, argv)
  40. funix[i] = -1;
  41. }
  42. - while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
  43. + while ((ch = getopt(argc, argv, "a:dhf:i:l:m:np:rs:v")) != EOF)
  44. switch((char)ch) {
  45. case 'a':
  46. if (nfunix < MAXFUNIX)
  47. @@ -895,9 +897,17 @@ int main(argc, argv)
  48. case 'h':
  49. NoHops = 0;
  50. break;
  51. + case 'i':
  52. + if (bind_addr) {
  53. + fprintf(stderr, "Only one -i argument allowed, "
  54. + "the first one is taken.\n");
  55. + break;
  56. + }
  57. + bind_addr = optarg;
  58. + break;
  59. case 'l':
  60. if (LocalHosts) {
  61. - fprintf (stderr, "Only one -l argument allowed," \
  62. + fprintf(stderr, "Only one -l argument allowed, "
  63. "the first one is taken.\n");
  64. break;
  65. }
  66. @@ -1244,7 +1254,7 @@ int main(argc, argv)
  67. int usage()
  68. {
  69. fprintf(stderr, "usage: syslogd [-drvh] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
  70. - " [-s domainlist] [-f conffile]\n");
  71. + " [-s domainlist] [-f conffile] [-i IP address]\n");
  72. exit(1);
  73. }
  74. @@ -1286,15 +1296,22 @@ static int create_inet_socket()
  75. int fd, on = 1;
  76. struct sockaddr_in sin;
  77. + memset(&sin, 0, sizeof(sin));
  78. + sin.sin_family = AF_INET;
  79. + sin.sin_port = LogPort;
  80. + if (bind_addr) {
  81. + if (!inet_aton(bind_addr, &sin.sin_addr)) {
  82. + logerror("syslog: not a valid IP address to bind to.");
  83. + return -1;
  84. + }
  85. + }
  86. +
  87. fd = socket(AF_INET, SOCK_DGRAM, 0);
  88. if (fd < 0) {
  89. logerror("syslog: Unknown protocol, suspending inet service.");
  90. return fd;
  91. }
  92. - memset(&sin, 0, sizeof(sin));
  93. - sin.sin_family = AF_INET;
  94. - sin.sin_port = LogPort;
  95. if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, \
  96. (char *) &on, sizeof(on)) < 0 ) {
  97. logerror("setsockopt(REUSEADDR), suspending inet");