Bug 510774

Summary: pkisilent returns 0 on errors
Product: [Retired] Dogtag Certificate System Reporter: Rob Crittenden <rcritten>
Component: ScriptsAssignee: Ade Lee <alee>
Status: CLOSED CURRENTRELEASE QA Contact: Chandrasekar Kannan <ckannan>
Severity: medium Docs Contact:
Priority: low    
Version: 1.1CC: aakkiang, alee, awnuk, benl, cfu, jgalipea, jmagne
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-04 19:59:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 431020, 431022, 445047    

Description Rob Crittenden 2009-07-10 17:49:43 UTC
Description of problem:

pkisilent always returns 0 whether the command succeeds or not. This makes it difficult to use within a script.

Version-Release number of selected component (if applicable):

dogtag 1.1 SVN revision 675

Steps to Reproduce:
1. /usr/bin/pkisilent -foo
2. echo $?

Comment 1 Ade Lee 2009-12-03 15:28:44 UTC
Simple patch to fix.

Index: scripts/pkisilent
===================================================================
--- scripts/pkisilent   (revision 876)
+++ scripts/pkisilent   (working copy)
@@ -157,7 +157,15 @@
 ###############################################################################
 
 my $output = `java -cp $ENV{CLASSPATH} @ARGV`;
+my $status = $?;
 
 print "#######################################################################\n";
 print "$output\n";
 print "#######################################################################\n";
+
+if ($status != 0) {
+  exit(255);
+} else {
+  exit(0);
+}
+

Comment 2 Jack Magne 2009-12-03 20:58:31 UTC
Attachments id=375817 id=375819 jmagne+

With caveat of checking for an empty string in the function:
checkRequireArgs.

Comment 3 Ade Lee 2009-12-03 21:30:34 UTC
Checked in as part of fixes to 504030:

Checked into tip:
[builder@dhcp231-70 silent]$  svn ci -m "fixes for BZ 510774,531162,504030,
493418"  
Sending        silent/scripts/pkisilent
Sending        silent/src/argparser/ArgParser.java
Sending        silent/src/ca/ConfigureCA.java
Sending        silent/src/common/ComCrypto.java
Sending        silent/src/drm/ConfigureDRM.java
Sending        silent/src/ocsp/ConfigureOCSP.java
Sending        silent/src/subca/ConfigureSubCA.java
Sending        silent/src/tks/ConfigureTKS.java
Sending        silent/src/tps/ConfigureTPS.java
Transmitting file data .........
Committed revision 877.

Checked into 8.1
[builder@oliver silent]$ svn ci -m "fixes for BZ 510774,531162, 504030, 493418"
Sending        silent/scripts/pkisilent
Sending        silent/src/argparser/ArgParser.java
Sending        silent/src/ca/ConfigureCA.java
Sending        silent/src/drm/ConfigureDRM.java
Sending        silent/src/ocsp/ConfigureOCSP.java
Sending        silent/src/subca/ConfigureSubCA.java
Sending        silent/src/tks/ConfigureTKS.java
Sending        silent/src/tps/ConfigureTPS.java
Transmitting file data ........
Committed revision 878.

Comment 4 Ade Lee 2009-12-03 21:34:06 UTC
Note to docs/ QE:

This is easy to test. See description.
You should be able to invoke pkisilent and check status with 
echo $?

You should get 0 for success, and non-zero for any errors.

Comment 5 Asha Akkiangady 2010-05-13 15:41:11 UTC
Tested pkisilent for CA, KRA, OCSP, RA, TKS and CA clone, returns 0 when success and non zero for failures.

Marking the bug verified.