From owner-freebsd-questions@freebsd.org Wed Mar 29 02:44:23 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC93ED22F0D for ; Wed, 29 Mar 2017 02:44:23 +0000 (UTC) (envelope-from ws@au.dyndns.ws) Received: from ipmail07.adl2.internode.on.net (ipmail07.adl2.internode.on.net [150.101.137.131]) by mx1.freebsd.org (Postfix) with ESMTP id 628EF65EC6 for ; Wed, 29 Mar 2017 02:44:22 +0000 (UTC) (envelope-from ws@au.dyndns.ws) Received: from ppp103-111.static.internode.on.net (HELO lillith-iv.ovirt.dyndns.ws) ([150.101.103.111]) by ipmail07.adl2.internode.on.net with ESMTP; 29 Mar 2017 13:09:12 +1030 X-Envelope-From: ws@au.dyndns.ws X-Envelope-To: freebsd-questions@freebsd.org Received: from predator-ii.buffyverse (predator-ii.buffyverse [172.17.17.136]) by lillith-iv.ovirt.dyndns.ws (8.14.9/8.14.9) with ESMTP id v2T2d2Ma058682; Wed, 29 Mar 2017 13:09:03 +1030 (ACDT) (envelope-from ws@au.dyndns.ws) Message-ID: <1490755142.1981.82.camel@au.dyndns.ws> Subject: Re: Two pf questions From: Wayne Sierke To: Ralf Mardorf , freebsd-questions@freebsd.org Date: Wed, 29 Mar 2017 13:09:02 +1030 In-Reply-To: <20170328202936.74ed1741@archlinux.localdomain> References: <20170327170941.59c84eec@archlinux.localdomain> <20170327171959.405bbfbb@archlinux.localdomain> <20170328111655.121ede18@archlinux.localdomain> <20170328111959.400d4761@archlinux.localdomain> <20170328113501.2a5ebf60@archlinux.localdomain> <20170328114541.0ca0d084@archlinux.localdomain> <20170328202936.74ed1741@archlinux.localdomain> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: inspected by milter-greylist-4.6.2 (lillith-iv.ovirt.dyndns.ws [172.17.17.142]); Wed, 29 Mar 2017 13:09:03 +1030 (ACDT) for IP:'172.17.17.136' DOMAIN:'predator-ii.buffyverse' HELO:'predator-ii.buffyverse' FROM:'ws@au.dyndns.ws' RCPT:'' X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (lillith-iv.ovirt.dyndns.ws [172.17.17.142]); Wed, 29 Mar 2017 13:09:03 +1030 (ACDT) X-Scanned-By: MIMEDefang 2.75 on 172.17.17.142 X-Scanned-By: SpamAssassin 3.004000(2014-02-07) X-Scanned-By: ClamAV X-Spam-Score: -1 () ALL_TRUSTED X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2017 02:44:24 -0000 On Tue, 2017-03-28 at 20:29 +0200, Ralf Mardorf via freebsd-questions wrote: > Hi, > > while I won't add such an exit status loop as I mentioned by an earlier > reply, I still would be careful with file names in /tmp and also > consider to make the commands of a "command chain" conditional of the > preceding commands. > > Instead of > >   cp /etc/pf/bruteforce /tmp/foobar.txt >   pfctl -t bruteforce -T show >> /tmp/foobar.txt >   sort -u -n /tmp/foobar.txt > /etc/pf/bruteforce > > I would use something similar to > >   tmp_suffix="-$$-$(mcookie)" >   cp /etc/pf/bruteforce /tmp/bruteforce$tmp_suffix && \ >   pfctl -t bruteforce -T show >> /tmp/bruteforce$tmp_suffix && \ >   sort -u -n /tmp/bruteforce$tmp_suffix > /etc/pf/bruteforce > > I wouldn't use $$ and $(mcookie) together, perhaps just $(mcookie) or $$ > plus the date and time including seconds or something else unique or > at least add "$(id -u)" to the PID. "-$$-$(mcookie)" is just an example, > as "foobar.txt" was just an example, too. > > Regards, > Ralf Is there any reason that mktemp(1) is not adequate here, or not desireable? Perhaps this: bf_temp=`mktemp -t bruteforce.` cp /etc/pf/bruteforce ${bf_temp} ... etc.