diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index 9c07156e8..d988a6e13 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -1978,15 +1978,20 @@ bool PGPHandler::removeKeysFromPGPKeyring(const std::set& keys_to_remov char template_name[_pubring_path.length()+8] ; sprintf(template_name,"%s.XXXXXX",_pubring_path.c_str()) ; +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 int fd_keyring_backup(mkstemp(template_name)); - - if (fd_keyring_backup == -1) + if (fd_keyring_backup == -1) +#else + if(mktemp(template_name) == NULL) +#endif { std::cerr << "PGPHandler::removeKeysFromPGPKeyring(): cannot create keyring backup file. Giving up." << std::endl; error_code = PGP_KEYRING_REMOVAL_ERROR_CANNOT_CREATE_BACKUP ; return false ; } +#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 close(fd_keyring_backup); // TODO: keep the file open and use the fd +#endif if(!ops_write_keyring_to_file(_pubring,ops_false,template_name,ops_true)) {