Package: apt-cacher
Version: 0.9.9

The package dependency list has a

  Depends: perl (>= 5.6.0-16)

line but the open() form used to execute curl in apt-cacher.pl 
is present on versions of Perl since version 5.8. See
"Using open() for IPC" - "Safe Pipe Opens" section of perlipc(1)

As I understand it (with my very basic Perl knowlegde)
the combination of a 3-parameter open() call and
a second parameter value of "-|" isn't valid on perl < 5.8.

I found this trying to backport (not really, it´s only a 
matter of apt-get source ...; dpkg-buildpackage ...) the 
current Sid apt-cacher (0.9.9) and Sarge (0.9.4) packages 
to Woody (perl 5.6.1). A basic test program I made trying
to isolate the problem gives:

Can't use an undefined value as filehandle reference at ./test.pl line 80.

pointng to the 

  open($getpipe, "-|", @elist);

line (test.pl:80 is equivalent to apt-cacher.pl:768).

The end user symptom is that on Woody the child apt-cacher
doesn´t get any data from curl when a client system connects
to the apt-cacher central cache, with debug set to 1 on
/etc/apt-cacher/apt-cacher.conf, /var/log/apt-cacher/error.log
shows:

Tue Jul 12 14:30:19 2005|172.17.2.2|debug: fetcher: try to pick up
http://security.debian.org/dists/sarge/updates/main/binary-i386/Packages.gz
Tue Jul 12 14:30:19 2005|172.17.2.2|debug: Executing /usr/bin/curl -D-
--stderr /dev/null
http://security.debian.org/dists/sarge/updates/main/binary-i386/Packages.gz
Tue Jul 12 14:30:21 2005|172.17.2.2|debug: no header yet...
Tue Jul 12 14:30:21 2005|172.17.2.2|debug: read 0 bytes
Tue Jul 12 14:30:23 2005|172.17.2.2|debug: no header yet...
Tue Jul 12 14:30:23 2005|172.17.2.2|debug: read 0 bytes
Tue Jul 12 14:30:25 2005|172.17.2.2|debug: no header yet...
...

The solution is trivial if you update the above Depends line
just for correctness (because the problem never will occur
on Sarge or later releases of Debian).

Alternatively you may wish to consider the patch below
(I  managed to assemble it by copying sample code from the 
relevant perlipc(1) manpage section) to make it compatible 
with older perls ... and making us users of Woody systems happy :-).

If so please review the following because I´m not fond on them:

* The $mypid variable scope
* The fact I only put the while(<$getpipe>) loop 
  inside the parent code path
* The
    ($EUID, $EGID) = ($UID, $GID); # suid only
  line
* The
    exec(@elist) || die "can't exec program: $!";
  line

--- apt-cacher.pl-dist  Tue Jul 12 21:19:04 2005
+++ apt-cacher.pl       Tue Jul 12 21:35:18 2005
@@ -765,19 +765,25 @@
   # Run the command we've built up
   my ($data, $getpipe, $chfd);
   open($chfd, ">$cached_head");
-  open($getpipe, "-|", @elist);
-  while(<$getpipe>) {
-     if($data) {
+  my $mypid = open($getpipe, "-|");
+  if ($mypid) { # parent
+    while(<$getpipe>) {
+      if($data) {
         data_feed(\$_) if !$do_import; # checksum passed data if not an
meta file
         print CF $_;
-        next ;
-     }
-     s/\r//;
-     print $chfd $_;
-     if(/^$/) {
+       next ;
+      }
+      s/\r//;
+      print $chfd $_;
+      if(/^$/) {
         close($chfd);
         $data=1;
-     }
+      }
+    }
+  } else { # child
+    ($EUID, $EGID) = ($UID, $GID); # suid only
+    exec(@elist) || die "can't exec program: $!";
+    # NOTREACHED
   }
   close($getpipe);
   my $rc=($?>>8);


Regards,

--
 Ramiro

-- 
Weitersagen: GMX DSL-Flatrates mit Tempo-Garantie!
Ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl


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

Reply via email to