From muir@idiom.com  Thu Mar 25 22:53:30 2004
Return-Path: <muir@idiom.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 34FD716A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Mar 2004 22:53:30 -0800 (PST)
Received: from idiom.com (idiom.com [216.240.32.1])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 240D943D2D
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Mar 2004 22:53:30 -0800 (PST)
	(envelope-from muir@idiom.com)
Received: from idiom.com (localhost [127.0.0.1])
	by idiom.com (8.12.9p2/8.12.9) with ESMTP id i2Q6rTu4001031
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 25 Mar 2004 22:53:29 -0800 (PST)
	(envelope-from muir@idiom.com)
Received: (from muir@localhost)
	by idiom.com (8.12.9p2/8.12.9/Submit) id i2Q6rSR6001022;
	Thu, 25 Mar 2004 22:53:28 -0800 (PST)
	(envelope-from muir)
Message-Id: <200403260653.i2Q6rSR6001022@idiom.com>
Date: Thu, 25 Mar 2004 22:53:28 -0800 (PST)
From: David Muir Sharnoff <muir@idiom.com>
Reply-To: David Muir Sharnoff <muir@idiom.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: SO_REUSEADDR doesn't seem to work with AF_UNIX
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         64738
>Category:       bin
>Synopsis:       sendmail(8): SO_REUSEADDR doesn't seem to work with AF_UNIX
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    gshapiro
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 25 23:00:31 PST 2004
>Closed-Date:    Fri Jun 15 04:10:17 GMT 2007
>Last-Modified:  Fri Jun 15 04:10:17 GMT 2007
>Originator:     David Muir Sharnoff
>Release:        FreeBSD 4.9-RELEASE i386
>Organization:
Idiom
>Environment:
System: FreeBSD idiom.com 4.9-RELEASE FreeBSD 4.9-RELEASE #23: Wed Nov 19 23:17:38 PST 2003 muir@staid.idiom.com:/build/obj/build/src/sys/IDIOM i386

>Description:
	I was working with milter (using perl Sendmail::Milter) and
	ran into trouble: my milter would not start up because it
	could not bind: Address In Use.

	This was highly repeatable.

	I look at the source (/usr/src/contrib/sendmail/libmilter/listener.c)
	and it clearly sets SO_REUSEADDR regardless of socket type.

	Eventually I gave up and switched to a AF_INET socket.  That
	fixed the problem immediately.  I would have preferred to
	keep with an AF_UNIX socket because it's easier to secure.

>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gshapiro 
Responsible-Changed-By: gshapiro 
Responsible-Changed-When: Thu Jun 14 16:20:21 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer (me) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=64738 
State-Changed-From-To: open->closed 
State-Changed-By: gshapiro 
State-Changed-When: Fri Jun 15 04:02:51 UTC 2007 
State-Changed-Why:  
You stated: 

> I look at the source (/usr/src/contrib/sendmail/libmilter/listener.c) 
> and it clearly sets SO_REUSEADDR regardless of socket type. 

That hasn't been the case since 8.13.6 was released.  The code is: 

if ( 
#if NETUNIX 
addr.sa.sa_family != AF_UNIX && 
#endif /* NETUNIX */ 
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &sockopt, 
sizeof(sockopt)) == -1) 
{ 

Note the check for AF_UNIX.  libmilter does not set SO_REUSEADDR on 
AF_UNIX sockets: 

LIBMILTER: Don't try to set SO_REUSEADDR on UNIX domain sockets. 
This generates an error message from libmilter on 
Solaris, though other systems appear to just discard the 
request silently. 

It is likely FreeBSD is one of those "other systems" which discard the 
request silently for AF_UNIX.  Your best bet if you want to use AF_UNIX 
is to clean up the dead socket on the file system before starting your 
filter. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=64738 
>Unformatted:
