Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Jul 2001 13:54:48 -0500
From:      "Jacques A. Vidrine" <n@nectar.com>
To:        freebsd-audit@freebsd.org
Subject:   syslogd: bind to localhost only
Message-ID:  <20010713135448.A67153@madman.nectar.com>

next in thread | raw e-mail | index | archive | help

The following patch adds a "-L"  option to syslogd to force binding to
localhost  only.  This  is useful  for running  syslogd in  a chroot'd
environment, where the log socket will not be available.
-- 
Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org



*** syslogd.c.orig	Wed Jul 11 16:41:06 2001
--- syslogd.c	Thu Jul 12 12:20:38 2001
***************
*** 265,270 ****
--- 265,271 ----
  int	MarkInterval = 20 * 60;	/* interval between marks in seconds */
  int	MarkSeq = 0;		/* mark sequence number */
  int	SecureMode = 0;		/* when true, receive only unix domain socks */
+ int	LocalHostOnly = 0;	/* when true, bind to only localhost */
  #ifdef INET6
  int	family = PF_UNSPEC;	/* protocol family (IPv4, IPv6 or both) */
  #else
***************
*** 325,331 ****
  	pid_t ppid = 1;
  	socklen_t len;
  
! 	while ((ch = getopt(argc, argv, "46Aa:df:kl:m:np:suv")) != -1)
  		switch (ch) {
  		case '4':
  			family = PF_INET;
--- 326,332 ----
  	pid_t ppid = 1;
  	socklen_t len;
  
! 	while ((ch = getopt(argc, argv, "46ALa:df:kl:m:np:suv")) != -1)
  		switch (ch) {
  		case '4':
  			family = PF_INET;
***************
*** 338,343 ****
--- 339,347 ----
  		case 'A':
  			send_to_all++;
  			break;
+ 		case 'L':
+ 			LocalHostOnly++;
+ 			break;
  		case 'a':		/* allow specific network addresses only */
  			if (allowaddr(optarg) == -1)
  				usage();
***************
*** 2235,2241 ****
  	hints.ai_flags = AI_PASSIVE;
  	hints.ai_family = af;
  	hints.ai_socktype = SOCK_DGRAM;
! 	error = getaddrinfo(NULL, "syslog", &hints, &res);
  	if (error) {
  		logerror(gai_strerror(error));
  		errno = 0;
--- 2239,2248 ----
  	hints.ai_flags = AI_PASSIVE;
  	hints.ai_family = af;
  	hints.ai_socktype = SOCK_DGRAM;
! 	if (LocalHostOnly)
! 		error = getaddrinfo("localhost", "syslog", &hints, &res);
! 	else
! 		error = getaddrinfo(NULL, "syslog", &hints, &res);
  	if (error) {
  		logerror(gai_strerror(error));
  		errno = 0;
*** syslogd.8.orig	Thu Jul 12 12:30:08 2001
--- syslogd.8	Thu Jul 12 12:35:36 2001
***************
*** 40,46 ****
  .Nd log systems messages
  .Sh SYNOPSIS
  .Nm
! .Op Fl 46Adknsuv
  .Op Fl a Ar allowed_peer
  .Op Fl f Ar config_file
  .Op Fl m Ar mark_interval
--- 40,46 ----
  .Nd log systems messages
  .Sh SYNOPSIS
  .Nm
! .Op Fl 46ALdknsuv
  .Op Fl a Ar allowed_peer
  .Op Fl f Ar config_file
  .Op Fl m Ar mark_interval
***************
*** 69,74 ****
--- 69,78 ----
  If this option is specified,
  .Nm
  tries to send the message to all addresses.
+ .It Fl L
+ Forces
+ .Nm
+ to bind to localhost only.
  .It Fl a Ar allowed_peer
  Allow
  .Ar allowed_peer


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010713135448.A67153>