From babolo@links.ru  Tue Apr 16 14:41:44 2002
Return-Path: <babolo@links.ru>
Received: from aaz.links.ru (aaz.links.ru [193.125.152.37])
	by hub.freebsd.org (Postfix) with ESMTP id C3F6C37B404
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Apr 2002 14:41:42 -0700 (PDT)
Received: (from babolo@localhost)
	by aaz.links.ru (8.9.3/8.9.3) id BAA28570;
	Wed, 17 Apr 2002 01:41:34 +0400 (MSD)
Message-Id: <200204162141.BAA28570@aaz.links.ru>
Date: Wed, 17 Apr 2002 01:41:34 +0400 (MSD)
From: .@babolo.ru
Reply-To: .@babolo.ru
To: FreeBSD-gnats-submit@freebsd.org
Subject: Option to redefine pid file for natd [PATCH]
X-Send-Pr-Version: 3.2

>Number:         37159
>Category:       bin
>Synopsis:       more then one natd use running use the same pid file
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 16 14:50:01 PDT 2002
>Closed-Date:    Wed Oct 29 12:44:39 PST 2003
>Last-Modified:  Wed Oct 29 12:44:39 PST 2003
>Originator:     Aleksandr A. Babaylov
>Release:        FreeBSD 4.5-STABLE
>Organization:
home
>Environment:

There are routers with different aliasing rules
for different IP groups so more then one natd
are running.

>Description:

Every natd running writes the same /var/run/natd.pid

>How-To-Repeat:

Launch 2 natd (with different rules possibly)

>Fix:

--- sbin/natd/natd.8	Thu Dec 20 15:21:46 2001
+++ sbin/natd/natd.8	Wed Apr 17 01:08:03 2002
@@ -32,6 +32,7 @@
 .Op Fl log_facility Ar facility_name
 .Op Fl punch_fw Ar firewall_range
 .Op Fl log_ipfw_denied
+.Op Fl pid_file | P Ar pidfile
 .Ek
 .Sh DESCRIPTION
 This program provides a Network Address Translation facility for use
@@ -468,6 +469,10 @@
 rule blocks it.
 This is the default with
 .Fl verbose .
+.It Fl pid_file | P Ar file
+Use
+.Ar file
+for PID instead of default.
 .El
 .Sh RUNNING NATD
 The following steps are necessary before attempting to run
--- sbin/natd/natd.c	Thu Feb 14 03:24:30 2002
+++ sbin/natd/natd.c	Wed Apr 17 01:19:29 2002
@@ -121,6 +121,7 @@
 static  int			logDropped;
 static	int			logFacility;
 static	int			logIpfwDenied;
+static	char*			pidName;
 
 int main (int argc, char** argv)
 {
@@ -155,6 +156,7 @@
  	logDropped		= 0;
  	logFacility		= LOG_DAEMON;
 	logIpfwDenied		= -1;
+	pidName			= PIDFILE;
 
 	ParseArgs (argc, argv);
 /*
@@ -377,7 +379,7 @@
 	}
 
 	if (background)
-		unlink (PIDFILE);
+		unlink (pidName);
 
 	return 0;
 }
@@ -389,7 +391,7 @@
 	daemon (0, 0);
 	background = 1;
 
-	pidFile = fopen (PIDFILE, "w");
+	pidFile = fopen (pidName, "w");
 	if (pidFile) {
 
 		fprintf (pidFile, "%d\n", getpid ());
@@ -833,7 +835,8 @@
  	LogDenied,
  	LogFacility,
 	PunchFW,
-	LogIpfwDenied
+	LogIpfwDenied,
+	PidFile
 };
 
 enum Param {
@@ -1060,6 +1063,14 @@
 		"log packets converted by natd, but denied by ipfw",
 		"log_ipfw_denied",
 		NULL },
+
+	{ PidFile,
+		0,
+		String,
+	        "file",
+		"Pid file name",
+		"pid_file",
+		"P" },
 };
 	
 static void ParseOption (const char* option, const char* parms)
@@ -1246,6 +1257,10 @@
 
 	case LogIpfwDenied:
 		logIpfwDenied = yesNoValue;;
+		break;
+
+	case PidFile:
+		pidName = strdup (strValue);
 		break;
 	}
 }
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Sun Apr 21 11:02:35 PDT 2002 
Responsible-Changed-Why:  
Ruslan is natd maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37159 
State-Changed-From-To: open->patched 
State-Changed-By: ru 
State-Changed-When: Wed Aug 13 06:14:00 PDT 2003 
State-Changed-Why:  
Committed with slight modifications to 5.1-CURRENT, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=37159 

From: Pawel Malachowski <pawmal-posting@freebsd.lublin.pl>
To: FreeBSD-gnats-submit@freebsd.org
Cc: ru@FreeBSD.org
Subject: Re: bin/37159 (MFC, more then one natd use running use the same pid file)
Date: Tue, 23 Sep 2003 22:04:20 +0200

 Hello,
 
 	This small thing was applied to CURRENT almost 6 weeks ago,
 are there any chances for MFC? Thanks.
 
 
 -- 
 Pawe Maachowski
 	

From: Ruslan Ermilov <ru@freebsd.org>
To: Pawel Malachowski <pawmal-posting@freebsd.lublin.pl>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/37159 (MFC, more then one natd use running use the same pid file)
Date: Wed, 24 Sep 2003 10:58:03 +0300

 On Tue, Sep 23, 2003 at 10:04:20PM +0200, Pawel Malachowski wrote:
 > Hello,
 > 
 > 	This small thing was applied to CURRENT almost 6 weeks ago,
 > are there any chances for MFC? Thanks.
 > 
 Yes.  After 4.9-RELEASE is out.
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Sysadmin and DBA,
 ru@sunbay.com		Sunbay Software Ltd,
 ru@FreeBSD.org		FreeBSD committer
State-Changed-From-To: patched->closed 
State-Changed-By: ru 
State-Changed-When: Wed Oct 29 12:39:56 PST 2003 
State-Changed-Why:  
Merged in 4.9-STABLE. 

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