Bug 463935

Summary: gpg: WARNING: nothing exported and return code is zero
Product: Red Hat Enterprise Linux 5 Reporter: Petr Sklenar <psklenar>
Component: gnupgAssignee: Tomas Mraz <tmraz>
Status: CLOSED NOTABUG QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.2CC: dshaw
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-10-26 10:20:26 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:

Description Petr Sklenar 2008-09-25 15:15:42 UTC
Description of problem:
there is no keyring and I am exporting public or secret key, file shouldn't be created and echo $? shouldn't be zero.

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

How reproducible:
always

Steps to Reproduce:
1. rm yourpublickey.gpg -f
2. gpg -a --export dont_exists > yourpublickey.gpg
gpg: WARNING: nothing exported
3. echo $?
4. ll yourpublickey.gpg
-rw-r--r-- 1 root devqa8 0 Sep 25 11:06 yourpublickey.gpg  

Actual results:
If not keyring is present:
echo $? = 0
yourpublickey.gpg is created without any content

Expected results:
echo $? = non-zero
yourpublickey.gpg is not created

Additional info:

Comment 1 Nalin Dahyabhai 2008-09-25 19:09:48 UTC
(In reply to comment #0)
> Description of problem:
> there is no keyring and I am exporting public or secret key, file shouldn't be
> created and echo $? shouldn't be zero.
> 
> Version-Release number of selected component (if applicable):
> gnupg-1.4.5-13
> 
> How reproducible:
> always
> 
> Steps to Reproduce:
> 1. rm yourpublickey.gpg -f
> 2. gpg -a --export dont_exists > yourpublickey.gpg
> gpg: WARNING: nothing exported
> 3. echo $?
> 4. ll yourpublickey.gpg
> -rw-r--r-- 1 root devqa8 0 Sep 25 11:06 yourpublickey.gpg  
> 
> Actual results:
> If not keyring is present:
> echo $? = 0
> yourpublickey.gpg is created without any content
> 
> Expected results:
> echo $? = non-zero
> yourpublickey.gpg is not created

Any time you redirect output to a file, a file is created, whether there are contents to add to it or not.  That's not under gpg's control.

The name passed to the command-line restricts which keys are exported (the default being all keys, similar to what happens when you pipe the output of ls through grep), and having no matches, regardless of the size of the set of known keys, isn't considered an error.

I don't think anything's actually gone wrong here.

Comment 2 Daphne Shaw 2008-12-03 22:57:28 UTC
That is correct: this is the intended behavior.

gpg --export creates a keyring, and if the export does not match any keys, that keyring will be empty.  An empty file is a valid keyring.