DWORD dwaccess, dwflags, dwshare;
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
if (bfd->fattrs & FILE_ATTRIBUTE_ENCRYPTED) {
return encrypt_bopen(bfd, fname, flags, mode);
}
bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
dwaccess, /* Requested access */
0, /* Shared mode */
- NULL, /* SecurityAttributes */
+ &sec, /* SecurityAttributes */
CREATE_ALWAYS, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
dwaccess, /* Requested access */
dwshare, /* Shared mode */
- NULL, /* SecurityAttributes */
+ &sec, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
bfd->fh = p_CreateFileW((LPCWSTR)win32_fname_wchar,
dwaccess, /* Requested access */
dwshare, /* Share modes */
- NULL, /* SecurityAttributes */
+ &sec, /* SecurityAttributes */
OPEN_EXISTING, /* CreationDisposition */
dwflags, /* Flags and attributes */
NULL); /* TemplateFile */
self->connected = false;
self->mode = mode;
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
if (self->fd != INVALID_HANDLE_VALUE) { /* server mode */
self->connected = ConnectNamedPipe(self->fd, NULL) ?
path, // pipe name
GENERIC_WRITE | GENERIC_READ,
0, // no sharing
- NULL, // default security attributes
+ &sec, // default security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
errno = tmp_errno;
}
}
+#endif
+#if defined(HAVE_WIN32)
+ SetHandleInformation((HANDLE)_get_osfhandle(fileno(fp)),
+ HANDLE_FLAG_INHERIT, 0);
#endif
return fp;
}
static int win_get_reparse_point(const wchar_t *path, DWORD *reparse_tag=NULL, POOLMEM **reparse=NULL)
{
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
HANDLE h = CreateFileW(path, FILE_READ_EA,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- NULL, OPEN_EXISTING,
+ &sec, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
if (h == INVALID_HANDLE_VALUE) {
return -1;
WIN32_FIND_DATAW info_w; // window's file info
HANDLE h = INVALID_HANDLE_VALUE;
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
/*
* Oh, cool, another exception: Microsoft doesn't let us do
* FindFile operations on a Drive, so simply fake root attributes.
* or to a directory.
*/
h = CreateFileW((LPCWSTR)pwszBuf.c_str(), GENERIC_READ,
- FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_SHARE_READ, &sec, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
NULL);
if (h != INVALID_HANDLE_VALUE) {
char tmpbuf[5000];
POOL_MEM pwszBuf(PM_FNAME);
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
cvt_utime_to_ftime(times->actime, acc);
cvt_utime_to_ftime(times->modtime, mod);
HANDLE h = p_CreateFileW((LPCWSTR)pwszBuf.c_str(),
FILE_WRITE_ATTRIBUTES,
FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_SHARE_DELETE,
- NULL,
+ &sec,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, // required for directories
NULL);
HANDLE foo = INVALID_HANDLE_VALUE;
const char *remap = file;
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
if (flags & O_WRONLY) access = GENERIC_WRITE;
else if (flags & O_RDWR) access = GENERIC_READ|GENERIC_WRITE;
else access = GENERIC_READ;
POOL_MEM pwszBuf(PM_FNAME);
make_win32_path_UTF8_2_wchar(&pwszBuf.addr(), file);
- foo = p_CreateFileW((LPCWSTR) pwszBuf.c_str(), access, shareMode, NULL, create, msflags, NULL);
+ foo = p_CreateFileW((LPCWSTR) pwszBuf.c_str(), access, shareMode, &sec, create, msflags, NULL);
if (INVALID_HANDLE_VALUE == foo) {
errno = b_errno_win32;
char *tmp = new char[wcslen(filename) + 1];
wcstombs(tmp, filename, wcslen(filename) + 1);
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
_DebugMessage(0, "pluginIoOpen_FILE - filename = %s\n", tmp);
io->status = 0;
io->io_errno = 0;
{
restore_at_file_level = true;
_DebugMessage(100, "Calling CreateFileW for '%s'\n", tmp);
- handle = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ handle = CreateFileW(filename, GENERIC_WRITE, 0, &sec, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (handle == INVALID_HANDLE_VALUE)
{
_JobMessage(M_FATAL, "CreateFile failed");
int idxFile;
DWORD dwResult;
+ /* Do not pass this descriptor to a sub process */
+ SECURITY_ATTRIBUTES sec;
+ sec.nLength = sizeof(sec);
+ sec.lpSecurityDescriptor = NULL;
+ sec.bInheritHandle = false;
+
for (idxFile = 0; idxFile < (int)NUMBER_HANDLE_ENTRIES; idxFile++) {
if (TapeHandleTable[idxFile].OSHandle == INVALID_HANDLE_VALUE) {
break;
bstrncpy(&szDeviceName[0], file, sizeof(szDeviceName));
}
- hDevice = CreateFile(szDeviceName, FILE_ALL_ACCESS, 0, NULL, OPEN_EXISTING, 0, NULL);
+ hDevice = CreateFile(szDeviceName, FILE_ALL_ACCESS, 0, &sec, OPEN_EXISTING, 0, NULL);
if (hDevice != INVALID_HANDLE_VALUE) {
PTAPE_HANDLE_INFO pHandleInfo = &TapeHandleTable[idxFile];