Author: hertzog
Date: 2007-07-02 13:26:01 +0000 (Mon, 02 Jul 2007)
New Revision: 830

Modified:
   branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl
   branches/dpkg-shlibdeps-buxy/scripts/modules/Objdump.pm
   branches/dpkg-shlibdeps-buxy/scripts/modules/Shlibs.pm
   branches/dpkg-shlibdeps-buxy/scripts/modules/SymbolFile.pm
Log:
Use new-style open calls everywhere: it's safer with weird filenames.


Modified: branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl      2007-07-01 
15:14:43 UTC (rev 829)
+++ branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl      2007-07-02 
13:26:01 UTC (rev 830)
@@ -202,10 +202,10 @@
 if ($stdout) {
     $fh = \*STDOUT;
 } else {
-    open(NEW,"> $varlistfile.new") ||
+    open(NEW, ">", "$varlistfile.new") ||
         syserr(sprintf(_g("open new substvars file \`%s'"), 
"$varlistfile.new"));
     if (-e $varlistfile) {
-       open(OLD,"< $varlistfile") || 
+       open(OLD, "<", $varlistfile) || 
            syserr(sprintf(_g("open old varlist file \`%s' for reading"), 
$varlistfile));
        foreach my $entry (grep { not /^\Q$varnameprefix\E:/ } (<OLD>)) {
            print(NEW $entry) ||
@@ -336,7 +336,7 @@
     }
     # Open shlibs file
     $shlibfile = "./$shlibfile" if $shlibfile =~ m/^\s/;
-    open(SHLIBS, "< $shlibfile") || syserr(sprintf(_g("unable to open shared 
libs info file \`%s'"), $shlibfile));
+    open(SHLIBS, "<", $shlibfile) || syserr(sprintf(_g("unable to open shared 
libs info file \`%s'"), $shlibfile));
     my $dep;
     while (<SHLIBS>) {
        s/\s*\n$//; next if m/^\#/;
@@ -371,7 +371,7 @@
 
 sub symfile_has_soname {
     my ($file, $soname) = @_;
-    open(SYM_FILE, "< $file") || syserr("can't open file $file");
+    open(SYM_FILE, "<", $file) || syserr("can't open file $file");
     my $result = 0;
     while (<SYM_FILE>) {
        if (/^\Q$soname\E /) {
@@ -403,8 +403,14 @@
 sub find_packages {
     my @files = (@_);
     my $pkgmatch = {};
-    open(DPKG, "dpkg --search -- @files 2>/dev/null |") ||
-       syserr(sprintf(_g("Can't execute dpkg --search: %s"), $!));
+    my $pid = open(DPKG, "-|") || syserr(_g("cannot fork for dpkg --search"));;
+    if (!$pid) {
+       # Child process running dpkg --search and discarding errors
+       close STDERR;
+       open STDERR, ">", "/dev/null";
+       $ENV{LC_ALL} = "C";
+       exec("dpkg", "--search", "--", @files) or syserr(_g("cannot exec 
dpkg"));;
+    }
     while(defined($_ = <DPKG>)) {
        chomp($_);
        if (m/^local diversion |^diversion by/) {

Modified: branches/dpkg-shlibdeps-buxy/scripts/modules/Objdump.pm
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/modules/Objdump.pm     2007-07-01 
15:14:43 UTC (rev 829)
+++ branches/dpkg-shlibdeps-buxy/scripts/modules/Objdump.pm     2007-07-02 
13:26:01 UTC (rev 830)
@@ -13,7 +13,8 @@
 sub parse {
     my ($self, $file) = @_;
     local $ENV{LC_ALL} = 'C';
-    open(OBJDUMP, "objdump -w -p -T $file |") || syserr(sprintf(_g("Can't 
execute objdump: %s"), $!));
+    open(OBJDUMP, "-|", "objdump", "-w", "-p", "-T", $file) || 
+           syserr(sprintf(_g("Can't execute objdump: %s"), $!));
     my $obj = Dpkg::Shlibs::Objdump::Object->new($file);
     my $section = "none";
     while (defined($_ = <OBJDUMP>)) {
@@ -171,7 +172,7 @@
 
 sub is_elf {
     my ($file) = @_;
-    open(FILE, "< $file") || main::syserr(sprintf(_g("Can't open %s for test: 
%s"), $file, $!));
+    open(FILE, "<", $file) || main::syserr(sprintf(_g("Can't open %s for test: 
%s"), $file, $!));
     my ($header, $result) = ("", 0);
     if (read(FILE, $header, 4) == 4) {
        $result = 1 if ($header =~ /^\177ELF$/);

Modified: branches/dpkg-shlibdeps-buxy/scripts/modules/Shlibs.pm
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/modules/Shlibs.pm      2007-07-01 
15:14:43 UTC (rev 829)
+++ branches/dpkg-shlibdeps-buxy/scripts/modules/Shlibs.pm      2007-07-02 
13:26:01 UTC (rev 830)
@@ -29,7 +29,7 @@
 sub parse_ldso_conf {
     my $file = shift;
     my $fh = new IO::File;
-    $fh->open("< $file")
+    $fh->open($file, "<")
        or main::syserr(sprintf(_g("couldn't open %s: %s"), $file, $!));
     while (<$fh>) {
        next if /^\s*$/;

Modified: branches/dpkg-shlibdeps-buxy/scripts/modules/SymbolFile.pm
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/modules/SymbolFile.pm  2007-07-01 
15:14:43 UTC (rev 829)
+++ branches/dpkg-shlibdeps-buxy/scripts/modules/SymbolFile.pm  2007-07-02 
13:26:01 UTC (rev 830)
@@ -34,7 +34,7 @@
 sub load {
     my ($self, $file) = @_;
     $self->{file} = $file;
-    open(SYM_FILE, "< $file") || main::syserr(sprintf(_g("Can't open %s: %s"), 
$file));
+    open(SYM_FILE, "<", $file) || main::syserr(sprintf(_g("Can't open %s: 
%s"), $file));
     my ($object);
     while (defined($_ = <SYM_FILE>)) {
        chomp($_);


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to