Bug 463935 - gpg: WARNING: nothing exported and return code is zero
gpg: WARNING: nothing exported and return code is zero
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: gnupg (Show other bugs)
5.2
All Linux
medium Severity medium
: rc
: ---
Assigned To: Tomas Mraz
BaseOS QE
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-25 11:15 EDT by Petr Sklenar
Modified: 2009-10-26 06:20 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-10-26 06:20:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Petr Sklenar 2008-09-25 11:15:42 EDT
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 15:09:48 EDT
(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 David Shaw 2008-12-03 17:57:28 EST
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.

Note You need to log in before you can comment on or make changes to this bug.