[interchange-cvs] interchange - heins modified lib/Vend/Order.pm

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Wed Sep 18 15:08:00 2002


User:      heins
Date:      2002-09-18 19:07:08 GMT
Modified:  lib/Vend Order.pm
Log:
* Finally discovered what is going on with GPG and errors.

  -- If PGP fails due to a system problem, like out of memory or
     bad file permissions, it fails with a status that will cause
	 a real error which is in the lower 8 bits.

  -- If PGP fails due to an internal problem like "key not found",
     or no secret key ring, it will fail with system status set to
	 zero but the upper level status indicating its problem.

	 So a failed key will turn up as "File not found" in the
	 upper order bits, while a key *ring* not found will fail
	 with the same error in the lower status bits.

  This patch is temporary, and at least tells you what $! is. I will
  examine GPG's error messages and provide some simple ones like "key
  not on keyring" and catch them to provide a better error.

Revision  Changes    Path
2.33      +16 -5     interchange/lib/Vend/Order.pm


rev 2.33, prev_rev 2.32
Index: Order.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Order.pm,v
retrieving revision 2.32
retrieving revision 2.33
diff -u -r2.32 -r2.33
--- Order.pm	16 Sep 2002 23:06:31 -0000	2.32
+++ Order.pm	18 Sep 2002 19:07:08 -0000	2.33
@@ -1,6 +1,6 @@
 # Vend::Order - Interchange order routing routines
 #
-# $Id: Order.pm,v 2.32 2002/09/16 23:06:31 mheins Exp $
+# $Id: Order.pm,v 2.33 2002/09/18 19:07:08 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -28,7 +28,7 @@
 package Vend::Order;
 require Exporter;
=20
-$VERSION =3D substr(q$Revision: 2.32 $, 10);
+$VERSION =3D substr(q$Revision: 2.33 $, 10);
=20
 @ISA =3D qw(Exporter);
=20
@@ -55,6 +55,7 @@
 use Vend::Session;
 use Vend::Data;
 use Text::ParseWords;
+use Errno qw/:POSIX/;
 use strict;
=20
 use autouse 'Vend::Error' =3D> qw/do_lockout/;
@@ -853,15 +854,25 @@
 #::logDebug("after  pgp_encrypt key=3D$key cmd=3D$cmd");
=20
 	my $fpre =3D $Vend::Cfg->{ScratchDir} . "/pgp.$Vend::Session->{id}.$$";
-	$cmd .=3D ">$fpre.out";
+	$cmd .=3D " >$fpre.out";
 	$cmd .=3D " 2>$fpre.err" unless $cmd =3D~ /2>/;
 	open(PGP, "|$cmd")
 			or die "Couldn't fork: $!";
 	print PGP $body;
 	close PGP;
+
 	if($?) {
-		logError("PGP failed with status %s: %s", $? >> 8, $!);
-		return 0;
+		my $errno =3D $?;
+		my $status =3D $errno;
+		if($status > 255) {
+			$status =3D $status >> 8;
+			$! =3D $status;
+		}
+		logError("PGP failed with error level %s, status %s: $!", $?, $status);
+		if($status) {
+			logError("PGP hard failure, command that failed: %s", $cmd);
+			return;
+		}
 	}
 	$body =3D readfile("$fpre.out");
 	unlink "$fpre.out";