From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26352 invoked from network); 3 Dec 2007 21:36:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Dec 2007 21:36:27 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 9913 invoked from network); 3 Dec 2007 21:36:21 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Dec 2007 21:36:21 -0000 Received: (qmail 23614 invoked by alias); 3 Dec 2007 21:36:14 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24147 Received: (qmail 23582 invoked from network); 3 Dec 2007 21:36:13 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 3 Dec 2007 21:36:13 -0000 Received: (qmail 9440 invoked from network); 3 Dec 2007 21:36:13 -0000 Received: from dsl-74-220-69-132.cruzio.com (HELO dot.blorf.net) (74.220.69.132) by a.mx.sunsite.dk with SMTP; 3 Dec 2007 21:36:06 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id 93BA12E13; Mon, 3 Dec 2007 13:36:04 -0800 (PST) Date: Mon, 3 Dec 2007 13:36:04 -0800 From: Wayne Davison To: Peter Stephenson Cc: zsh-workers@sunsite.dk Subject: Re: difflog.pl and "security" Message-ID: <20071203213604.GA6645@blorf.net> References: <20071202214005.GA6517@scowler.net> <071202174520.ZM3017@torch.brasslantern.com> <20071203104256.09dc9684@news01> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ikeVEW9yuYc//A+q" Content-Disposition: inline In-Reply-To: <20071203104256.09dc9684@news01> User-Agent: Mutt/1.5.17 (2007-11-01) --ikeVEW9yuYc//A+q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Dec 03, 2007 at 10:42:56AM +0000, Peter Stephenson wrote: > Maybe we should simply leave it out of the distribution (but leave it in > the archive), since it's essentially no use unless you have a CVS tree. Seems quite reasonable to me. I also coded up an improved version that uses File::Temp. I also changed the opening of the DIFF pipe to use a newer, safer exec syntax (since we don't need this to be very portable, I figure the perl version should be recent enough for anyone who might be using the script). ..wayne.. --ikeVEW9yuYc//A+q Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="difflog.patch" --- difflog.pl 18 Apr 2002 14:35:17 -0000 1.3 +++ difflog.pl 3 Dec 2007 21:32:03 -0000 @@ -2,10 +2,9 @@ use strict; use IO::File; +use File::Temp qw(tempfile); my @differ = qw(diff -bw); -my $oldtmp = "/tmp/difflog$$.old"; -my $newtmp = "/tmp/difflog$$.new"; my $newfn = pop(@ARGV); my $oldfn = pop(@ARGV); @@ -36,16 +35,17 @@ while ($old < @oldentries && $new < @new else { if ($oldhash{$oldentries[$old]} ne $newhash{$newentries[$new]}) { - my $oldfh = new IO::File("/tmp/difflog$$.old", 'w'); - $oldfh->print($oldhash{$oldentries[$old]}); - $oldfh->close(); - my $newfh = new IO::File("/tmp/difflog$$.new", 'w'); - $newfh->print($newhash{$newentries[$new]}); - $newfh->close(); - open(DIFF, join(' ', @differ, @ARGV, $oldtmp, $newtmp, '|')); + my($oldfh, $oldtmp) = tempfile('difflog-XXXXXXXX', SUFFIX => '.old', DIR => '/tmp'); + print $oldfh $oldhash{$oldentries[$old]}; + close $oldfh; + my($newfh, $newtmp) = tempfile('difflog-XXXXXXXX', SUFFIX => '.new', DIR => '/tmp'); + print $newfh $newhash{$newentries[$new]}; + close $newfh; + open(DIFF, '-|', @differ, @ARGV, $oldtmp, $newtmp) or die $!; my @lines = ; close(DIFF); - unlink ; + unlink($oldtmp); + unlink($newtmp); if (@lines) { print "diff for ", $oldentries[$old], ":\n"; --ikeVEW9yuYc//A+q--