- this out */
- fd2 = do_open(fnametmp,O_WRONLY|O_CREAT|O_EXCL,
- file->mode & ACCESSPERMS);
+ this out. We also set it initially without group
+ access because of a similar race condition. */
+ fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
+ if (fd2 == -1) {
+ rprintf(FERROR,"mkstemp %s failed\n",fnametmp);
+ receive_data(f_in,buf,-1,NULL,file->length);
+ if (buf) unmap_file(buf);
+ continue;
+ }