'HAVE_DOSISH_SYSTEM' - conversion of backslashes to slashes kills fd_cache_invalidate() from iobuf.c

Tobias Winkler tobias.winkler at s1998.tu-chemnitz.de
Fri Dec 3 23:24:15 CET 2004


Hi,

I got some problems when importing a (public) key to pubkeys.pgp here
under win32.

>> gpg: renaming `n:/!--Files--/GnuPG\pubring.gpg' to `n:/!--Files--/GnuPG\pubring.bak' failed: Permission denied
>> gpg: error writing keyring `n:/!--Files--/GnuPG\pubring.gpg': file rename error
>> ...

Renaming the old keyring to backup failed because it was still held open by gpg.exe.

Obviously that
  iobuf_ioctl (NULL, 2, 0, (char*)fname );
in rename_tmp_file() [keyring.c]  did NOT close the handle.

Actually it was   fd_cache_invalidate()   which failed here.
(called indirectly by iobuf_ioctl())

The reason is that the file paths from the  close_cache
are stored with backslashes (in win32 of course ;)
and the given file path (the one to close) was using (some)
slashes instead - therefore the string comparison in
fd_cache_invalidate() failed.

The slashes came from a conversion of the home path at the
beginning of  main() [g10.c line 1409 for gnupg-1.2.6]
>> #ifdef HAVE_DOSISH_SYSTEM
>>     if ( strchr (opt.homedir,'\\') ) {
>>         char *d, *buf = m_alloc (strlen (opt.homedir)+1);
>>         const char *s = opt.homedir;
>>         for (d=buf,s=opt.homedir; *s; s++)
>>             *d++ = *s == '\\'? '/': *s;
>>         *d = 0;
>>         set_homedir (buf);
>>     }
>> #endif

I removed that part and everything works right for me now.
But I didn't do any deeper checks, if that conversion is actually
needed somewhere. (maybe there are parts which rely on slashes?)

Alternatively one could replace the strcmp() from fd_cache_invalidate()
with a function which does recognize backslashes as slashes.

Bye,
     TW.




More information about the Gnupg-devel mailing list