diff --git a/g10/ChangeLog b/g10/ChangeLog index 669c135ee..0c8cbd418 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -2,7 +2,7 @@ * tdbio.c (tdbio_set_dbname) [W32CE]: Take care of missing errno. (strerror) [W32CE]: Dummy replacement. - (open_db) [W32CE]: Fall back to read-only on any error. + (open_db) [W32CE]: Use CreateFile. 2010-12-02 Werner Koch diff --git a/g10/tdbio.c b/g10/tdbio.c index 73681af7d..1c775d22d 100644 --- a/g10/tdbio.c +++ b/g10/tdbio.c @@ -615,22 +615,37 @@ open_db() if (make_dotlock( lockhandle, -1 ) ) log_fatal( _("can't lock `%s'\n"), db_name ); #endif /* __riscos__ */ +#ifdef HAVE_W32CE_SYSTEM + { + DWORD prevrc = 0; + wchar_t *wname = utf8_to_wchar (db_name); + if (wname) + { + db_fd = (int)CreateFile (wname, GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, 0, NULL); + xfree (wname); + } + if (db_fd == -1) + log_fatal ("can't open `%s': %d, %d\n", db_name, + (int)prevrc, (int)GetLastError ()); + } +#else /*!HAVE_W32CE_SYSTEM*/ db_fd = open (db_name, O_RDWR | MY_O_BINARY ); if (db_fd == -1 && (errno == EACCES #ifdef EROFS || errno == EROFS -#endif -#ifdef HAVE_W32CE_SYSTEM - || 1 /* cegcc's open does not set ERRNO. */ #endif ) ) { + /* Take care of read-only trustdbs. */ db_fd = open (db_name, O_RDONLY | MY_O_BINARY ); if (db_fd != -1) log_info (_("NOTE: trustdb not writable\n")); } if ( db_fd == -1 ) log_fatal( _("can't open `%s': %s\n"), db_name, strerror(errno) ); +#endif /*!HAVE_W32CE_SYSTEM*/ register_secured_file (db_name); /* Read the version record. */