Pass specific access rights to wine_server_handle_to_fd.

This commit is contained in:
Alexandre Julliard 2005-12-12 17:15:26 +01:00
parent a510a7e117
commit 59797f292e
8 changed files with 26 additions and 31 deletions

View File

@ -701,7 +701,7 @@ BOOL WINAPI SetCommBreak(
#if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */ #if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */
int fd,result; int fd,result;
fd = get_comm_fd( handle, GENERIC_READ ); fd = get_comm_fd( handle, FILE_READ_DATA );
if(fd<0) return FALSE; if(fd<0) return FALSE;
result = ioctl(fd,TIOCSBRK,0); result = ioctl(fd,TIOCSBRK,0);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
@ -738,7 +738,7 @@ BOOL WINAPI ClearCommBreak(
#if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */ #if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */
int fd,result; int fd,result;
fd = get_comm_fd( handle, GENERIC_READ ); fd = get_comm_fd( handle, FILE_READ_DATA );
if(fd<0) return FALSE; if(fd<0) return FALSE;
result = ioctl(fd,TIOCCBRK,0); result = ioctl(fd,TIOCCBRK,0);
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
@ -775,7 +775,7 @@ BOOL WINAPI EscapeCommFunction(
struct termios port; struct termios port;
TRACE("handle %p, function=%d\n", handle, nFunction); TRACE("handle %p, function=%d\n", handle, nFunction);
fd = get_comm_fd( handle, GENERIC_READ ); fd = get_comm_fd( handle, FILE_READ_DATA );
if(fd<0) return FALSE; if(fd<0) return FALSE;
if (tcgetattr(fd,&port) == -1) { if (tcgetattr(fd,&port) == -1) {
@ -889,7 +889,7 @@ BOOL WINAPI PurgeComm(
TRACE("handle %p, flags %lx\n", handle, flags); TRACE("handle %p, flags %lx\n", handle, flags);
fd = get_comm_fd( handle, GENERIC_READ ); fd = get_comm_fd( handle, FILE_READ_DATA );
if(fd<0) return FALSE; if(fd<0) return FALSE;
/* /*
@ -927,7 +927,7 @@ BOOL WINAPI ClearCommError(
{ {
int fd; int fd;
fd=get_comm_fd( handle, GENERIC_READ ); fd=get_comm_fd( handle, FILE_READ_DATA );
if(0>fd) return FALSE; if(0>fd) return FALSE;
if (lpStat) if (lpStat)
@ -987,7 +987,7 @@ BOOL WINAPI SetupComm(
int fd; int fd;
FIXME("insize %ld outsize %ld unimplemented stub\n", insize, outsize); FIXME("insize %ld outsize %ld unimplemented stub\n", insize, outsize);
fd=get_comm_fd( handle, GENERIC_READ ); fd=get_comm_fd( handle, FILE_READ_DATA );
if(0>fd) return FALSE; if(0>fd) return FALSE;
release_comm_fd( handle, fd ); release_comm_fd( handle, fd );
return TRUE; return TRUE;
@ -1085,7 +1085,7 @@ BOOL WINAPI SetCommState(
lpdcb->fDtrControl); lpdcb->fDtrControl);
fd = get_comm_fd( handle, GENERIC_READ ); fd = get_comm_fd( handle, FILE_READ_DATA );
if (fd < 0) return FALSE; if (fd < 0) return FALSE;
if ((tcgetattr(fd,&port)) == -1) { if ((tcgetattr(fd,&port)) == -1) {
@ -1488,7 +1488,7 @@ BOOL WINAPI GetCommState(
TRACE("handle %p, ptr %p\n", handle, lpdcb); TRACE("handle %p, ptr %p\n", handle, lpdcb);
fd = get_comm_fd( handle, GENERIC_READ ); fd = get_comm_fd( handle, FILE_READ_DATA );
if (fd < 0) return FALSE; if (fd < 0) return FALSE;
if (tcgetattr(fd, &port) == -1) { if (tcgetattr(fd, &port) == -1) {
int save_error=errno; int save_error=errno;
@ -1821,7 +1821,7 @@ BOOL WINAPI SetCommTimeouts(
if (!ret) return FALSE; if (!ret) return FALSE;
/* FIXME: move this stuff to the server */ /* FIXME: move this stuff to the server */
fd = get_comm_fd( hComm, GENERIC_READ ); fd = get_comm_fd( hComm, FILE_READ_DATA );
if (fd < 0) return FALSE; if (fd < 0) return FALSE;
if (-1==tcgetattr(fd,&tios)) { if (-1==tcgetattr(fd,&tios)) {
@ -1876,7 +1876,7 @@ BOOL WINAPI GetCommModemStatus(
*lpModemStat=0; *lpModemStat=0;
#ifdef TIOCMGET #ifdef TIOCMGET
fd = get_comm_fd( hFile, GENERIC_READ ); fd = get_comm_fd( hFile, FILE_READ_DATA );
if(fd<0) if(fd<0)
return FALSE; return FALSE;
result = ioctl(fd, TIOCMGET, &mstat); result = ioctl(fd, TIOCMGET, &mstat);
@ -1980,7 +1980,7 @@ static DWORD WINAPI COMM_WaitCommEventService(LPVOID arg)
serial_irq_info new_irq_info; serial_irq_info new_irq_info;
DWORD new_mstat, new_evtmask; DWORD new_mstat, new_evtmask;
fd=get_comm_fd( commio->handle, GENERIC_READ ); fd=get_comm_fd( commio->handle, FILE_READ_DATA );
TRACE("handle %p fd 0x%08x, mask 0x%08lx buffer %p event %p irq_info %p waitmask 0x%08x\n", TRACE("handle %p fd 0x%08x, mask 0x%08lx buffer %p event %p irq_info %p waitmask 0x%08x\n",
commio->handle, fd, commio->evtmask, commio->buffer, commio->hEvent, &commio->irq_info, waitmask); commio->handle, fd, commio->evtmask, commio->buffer, commio->hEvent, &commio->irq_info, waitmask);
@ -2038,7 +2038,7 @@ static BOOL COMM_WaitCommEvent(
if (NtResetEvent(lpOverlapped->hEvent,NULL)) if (NtResetEvent(lpOverlapped->hEvent,NULL))
return FALSE; return FALSE;
fd = get_comm_fd( hFile, GENERIC_WRITE ); fd = get_comm_fd( hFile, FILE_WRITE_DATA );
if (fd < 0) return FALSE; if (fd < 0) return FALSE;
commio = HeapAlloc(GetProcessHeap(), 0, sizeof (async_commio)); commio = HeapAlloc(GetProcessHeap(), 0, sizeof (async_commio));

View File

@ -1202,7 +1202,7 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
TRACE("(%p,%p,%lu,%p,%p,%p)\n", hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage); TRACE("(%p,%p,%lu,%p,%p,%p)\n", hPipe, lpvBuffer, cbBuffer, lpcbRead, lpcbAvail, lpcbMessage);
ret = wine_server_handle_to_fd( hPipe, GENERIC_READ, &fd, &flags ); ret = wine_server_handle_to_fd( hPipe, FILE_READ_DATA, &fd, &flags );
if (ret) if (ret)
{ {
SetLastError( RtlNtStatusToDosError(ret) ); SetLastError( RtlNtStatusToDosError(ret) );

View File

@ -1153,7 +1153,7 @@ NTSTATUS WINAPI NtQueryDirectoryFile( HANDLE handle, HANDLE event,
return io->u.Status = STATUS_NOT_IMPLEMENTED; return io->u.Status = STATUS_NOT_IMPLEMENTED;
} }
if ((io->u.Status = wine_server_handle_to_fd( handle, GENERIC_READ, &fd, NULL )) != STATUS_SUCCESS) if ((io->u.Status = wine_server_handle_to_fd( handle, FILE_LIST_DIRECTORY, &fd, NULL )) != STATUS_SUCCESS)
return io->u.Status; return io->u.Status;
io->Information = 0; io->Information = 0;

View File

@ -491,7 +491,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
if (!io_status) return STATUS_ACCESS_VIOLATION; if (!io_status) return STATUS_ACCESS_VIOLATION;
io_status->Information = 0; io_status->Information = 0;
io_status->u.Status = wine_server_handle_to_fd( hFile, GENERIC_READ, &unix_handle, &flags ); io_status->u.Status = wine_server_handle_to_fd( hFile, FILE_READ_DATA, &unix_handle, &flags );
if (io_status->u.Status) return io_status->u.Status; if (io_status->u.Status) return io_status->u.Status;
if (flags & FD_FLAG_RECV_SHUTDOWN) if (flags & FD_FLAG_RECV_SHUTDOWN)
@ -713,7 +713,7 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
if (!io_status) return STATUS_ACCESS_VIOLATION; if (!io_status) return STATUS_ACCESS_VIOLATION;
io_status->Information = 0; io_status->Information = 0;
io_status->u.Status = wine_server_handle_to_fd( hFile, GENERIC_WRITE, &unix_handle, &flags ); io_status->u.Status = wine_server_handle_to_fd( hFile, FILE_WRITE_DATA, &unix_handle, &flags );
if (io_status->u.Status) return io_status->u.Status; if (io_status->u.Status) return io_status->u.Status;
if (flags & FD_FLAG_SEND_SHUTDOWN) if (flags & FD_FLAG_SEND_SHUTDOWN)

View File

@ -484,11 +484,6 @@ int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *uni
obj_handle_t fd_handle; obj_handle_t fd_handle;
int ret, removable = -1, fd = -1; int ret, removable = -1, fd = -1;
/* FIXME: callers should be fixed to pass the appropriate specific rights */
if (access & GENERIC_READ) access |= FILE_READ_DATA;
if (access & GENERIC_WRITE) access |= FILE_WRITE_DATA;
access &= ~(GENERIC_READ|GENERIC_WRITE);
RtlEnterCriticalSection( &fd_cache_section ); RtlEnterCriticalSection( &fd_cache_section );
*unix_fd = -1; *unix_fd = -1;

View File

@ -1763,8 +1763,8 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
{ {
int shared_fd; int shared_fd;
if ((res = wine_server_handle_to_fd( shared_file, GENERIC_READ, &shared_fd, if ((res = wine_server_handle_to_fd( shared_file, FILE_READ_DATA|FILE_WRITE_DATA,
NULL ))) goto done; &shared_fd, NULL ))) goto done;
res = map_image( handle, unix_handle, base, size_low, header_size, res = map_image( handle, unix_handle, base, size_low, header_size,
shared_fd, removable, addr_ptr ); shared_fd, removable, addr_ptr );
wine_server_release_fd( shared_file, shared_fd ); wine_server_release_fd( shared_file, shared_fd );

View File

@ -125,7 +125,7 @@ static void INT13_ReadFloppyParams( CONTEXT86 *context )
h = CreateFileW(drive_root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, h = CreateFileW(drive_root, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL); FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h == INVALID_HANDLE_VALUE || if (h == INVALID_HANDLE_VALUE ||
wine_server_handle_to_fd(h, GENERIC_READ, &floppy_fd, NULL)) wine_server_handle_to_fd(h, FILE_READ_DATA, &floppy_fd, NULL))
{ {
WARN("Can't determine floppy geometry !\n"); WARN("Can't determine floppy geometry !\n");
INT13_SetStatus( context, 0x07 ); /* drive parameter activity failed */ INT13_SetStatus( context, 0x07 ); /* drive parameter activity failed */

View File

@ -1580,7 +1580,7 @@ SOCKET WINAPI WS_accept(SOCKET s, struct WS_sockaddr *addr,
do { do {
if (is_blocking) if (is_blocking)
{ {
int fd = get_sock_fd( s, GENERIC_READ, NULL ); int fd = get_sock_fd( s, FILE_READ_DATA, NULL );
if (fd == -1) return INVALID_SOCKET; if (fd == -1) return INVALID_SOCKET;
/* block here */ /* block here */
do_block(fd, POLLIN, -1); do_block(fd, POLLIN, -1);
@ -1681,7 +1681,7 @@ int WINAPI WS_closesocket(SOCKET s)
*/ */
int WINAPI WS_connect(SOCKET s, const struct WS_sockaddr* name, int namelen) int WINAPI WS_connect(SOCKET s, const struct WS_sockaddr* name, int namelen)
{ {
int fd = get_sock_fd( s, GENERIC_READ, NULL ); int fd = get_sock_fd( s, FILE_READ_DATA, NULL );
TRACE("socket %04x, ptr %p %s, length %d\n", s, name, debugstr_sockaddr(name), namelen); TRACE("socket %04x, ptr %p %s, length %d\n", s, name, debugstr_sockaddr(name), namelen);
@ -2346,7 +2346,7 @@ int WINAPI WS_ioctlsocket(SOCKET s, long cmd, u_long *argp)
*/ */
int WINAPI WS_listen(SOCKET s, int backlog) int WINAPI WS_listen(SOCKET s, int backlog)
{ {
int fd = get_sock_fd( s, GENERIC_READ, NULL ); int fd = get_sock_fd( s, FILE_READ_DATA, NULL );
TRACE("socket %04x, backlog %d\n", s, backlog); TRACE("socket %04x, backlog %d\n", s, backlog);
if (fd != -1) if (fd != -1)
@ -2416,8 +2416,8 @@ int WINAPI WS_select(int nfds, WS_fd_set *ws_readfds,
TRACE("read %p, write %p, excp %p timeout %p\n", TRACE("read %p, write %p, excp %p timeout %p\n",
ws_readfds, ws_writefds, ws_exceptfds, ws_timeout); ws_readfds, ws_writefds, ws_exceptfds, ws_timeout);
p_read = fd_set_import(&readfds, ws_readfds, GENERIC_READ, &highfd, readfd); p_read = fd_set_import(&readfds, ws_readfds, FILE_READ_DATA, &highfd, readfd);
p_write = fd_set_import(&writefds, ws_writefds, GENERIC_WRITE, &highfd, writefd); p_write = fd_set_import(&writefds, ws_writefds, FILE_WRITE_DATA, &highfd, writefd);
p_except = fd_set_import(&exceptfds, ws_exceptfds, 0, &highfd, exceptfd); p_except = fd_set_import(&exceptfds, ws_exceptfds, 0, &highfd, exceptfd);
if (ws_timeout) if (ws_timeout)
{ {
@ -2514,7 +2514,7 @@ INT WINAPI WSASendTo( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
s, lpBuffers, dwBufferCount, dwFlags, s, lpBuffers, dwBufferCount, dwFlags,
to, tolen, lpOverlapped, lpCompletionRoutine); to, tolen, lpOverlapped, lpCompletionRoutine);
fd = get_sock_fd( s, GENERIC_WRITE, &flags ); fd = get_sock_fd( s, FILE_WRITE_DATA, &flags );
TRACE( "fd=%d, flags=%x\n", fd, flags ); TRACE( "fd=%d, flags=%x\n", fd, flags );
if ( fd == -1 ) return SOCKET_ERROR; if ( fd == -1 ) return SOCKET_ERROR;
@ -3880,7 +3880,7 @@ INT WINAPI WSARecvFrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
(lpFromlen ? *lpFromlen : -1L), (lpFromlen ? *lpFromlen : -1L),
lpOverlapped, lpCompletionRoutine); lpOverlapped, lpCompletionRoutine);
fd = get_sock_fd( s, GENERIC_READ, &flags ); fd = get_sock_fd( s, FILE_READ_DATA, &flags );
TRACE( "fd=%d, flags=%x\n", fd, flags ); TRACE( "fd=%d, flags=%x\n", fd, flags );
if (fd == -1) return SOCKET_ERROR; if (fd == -1) return SOCKET_ERROR;