From owner-freebsd-bugs Tue Apr 16 14:50:14 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0628137B405 for ; Tue, 16 Apr 2002 14:50:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3GLo1Z54416; Tue, 16 Apr 2002 14:50:02 -0700 (PDT) (envelope-from gnats) Received: from aaz.links.ru (aaz.links.ru [193.125.152.37]) by hub.freebsd.org (Postfix) with ESMTP id C3F6C37B404 for ; 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 X-Send-Pr-Version: 3.2 Subject: bin/37159: Option to redefine pid file for natd [PATCH] Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 37159 >Category: bin >Synopsis: more then one natd use running use the same pid file >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Apr 16 14:50:01 PDT 2002 >Closed-Date: >Last-Modified: >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: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message