[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Files-Excluded field and security implications of uscan and debian/copyright.

On Tue, 11 Sep 2012 17:54:44 +0200, Andreas Tille wrote:

> Point taken for those calls where "user-input" (= strings mentioned in
> debian/copyright Files-Excluded) is involved.  I left calls like
>    my $tempdir = tempdir ( "uscanXXXX", TMPDIR => 1, CLEANUP => 1 );
>    my $nfiles_before = `find "$tempdir" | wc -l`;
> like calls because system does not return the number of files.  

I'm attaching a small example that uses File::Find for this purpose.

> > (You could also avoid calling out to find completely, and use
> > Find::File and File::Path::rmtree or similar, but that's a more
> > personal decision.)
> I'm fine with anything that works - my method was the first one that
> came to mind.  I have no idea in how far system('find',...) compares to
> Find::File and in how for this difference is relevant for the intended
> purpose.

When I looked at your patches first, I also wanted to suggest to
replace various calls of system() by perl modules [0] -- but then I saw
that system() is used all over the place in uscan.pl, so that would
mean a major rewrite ...


[0] e.g. Archive::Tar or Archive::Zip
 .''`.  Homepage: http://info.comodo.priv.at/ - OpenPGP key 0xBB3A68018649AA06
 : :' : Debian GNU/Linux user, admin, and developer  -  http://www.debian.org/
 `. `'  Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
   `-   NP: Don McLean: Crying

use strict;
use warnings;

use File::Temp qw/ tempdir /;
use File::Find;

my $tempdir = tempdir( "uscanXXXX", TMPDIR => 1, CLEANUP => 1 );

# create some files for testing
system( 'mkdir', "$tempdir/a",   "$tempdir/b" );
system( 'touch', "$tempdir/a/1", "$tempdir/b/1" );

my $nfiles_before = 0;

# system/find/wc
chomp( $nfiles_before = `find "$tempdir" | wc -l` );
print "find found $nfiles_before files.\n";

$nfiles_before = 0;

# File::Find
find( \&countfiles, $tempdir );
sub countfiles { $nfiles_before++; }
print "File::Find found $nfiles_before files.\n";

Attachment: signature.asc
Description: Digital signature

Reply to: