Patch: Correct creation of ~/.gnupg (Was: Error on initial call under Darwin)

Brian Greenberg grnbrg at
Tue Aug 31 16:51:31 CEST 2004

On Mon Aug 30 19:28:15 CEST 2004 Werner Koch (wk at  said:

> On Fri, 27 Aug 2004 12:48:49 +0200, Alexander Nouak said:
>> any .gnupg dir yet. Unlike previous versions gnupg 1.2.6 needs a
>> present .gnupg dir to create some of the necessary files to run gnupg
>> properly.
> Right, that does not work anymore.  Pretty obvious.  Workaround is also obvious.
> Werner

I noticed this behavior a few days ago, and have fixed it.

Changes were made to g10/keydb.c that implemented file locking for the
creation of the keyring files.  The new code checks for a readable
keyfile, and if it cannot find one, tries to create a lockfile so that
it can continue with the creation of this file.  If it cannot create the
lock file it aborts.

The issue is that there is no check for the existence of the parent
directory before attempting to create the lockfile.  If the parent does
not exist, lock creation will always fail.

The attached patch moves the homedir creation logic ahead of the file
locking logic.  Basically, if a readable keyring does not exist, a check is 
made if it's parent exists.  If not, a lockfile is used for the parent
and try_make_homedir() is called.  If this succeeds, then creation of 
the keyring lockfile (and subsequently the keyring) is allowed to continue.

Brian Greenberg
grnbrg at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: keydb.diff
Type: application/octet-stream
Size: 2651 bytes
Desc: not available
Url : /pipermail/attachments/20040831/3c0c2cd7/keydb.exe

More information about the Gnupg-users mailing list