server: Refuse to close handles in other processes if they have an associated fd.

This commit is contained in:
Alexandre Julliard 2006-11-02 20:52:22 +01:00
parent 8700c4341b
commit 715d78e006
9 changed files with 18 additions and 11 deletions

View File

@ -177,7 +177,7 @@ static const struct object_ops dir_ops =
dir_get_fd, /* get_fd */
dir_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
dir_destroy /* destroy */
};

View File

@ -1658,6 +1658,12 @@ int is_same_file_fd( struct fd *fd1, struct fd *fd2 )
return fd1->inode == fd2->inode;
}
/* handler for close_handle that refuses to close fd-associated handles in other processes */
int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
{
return (!current || current->process == process);
}
/* callback for event happening in the main poll() loop */
void fd_poll_event( struct fd *fd, int event )
{

View File

@ -84,7 +84,7 @@ static const struct object_ops file_ops =
file_get_fd, /* get_fd */
file_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
file_destroy /* destroy */
};

View File

@ -55,6 +55,7 @@ extern void *get_fd_user( struct fd *fd );
extern void set_fd_user( struct fd *fd, const struct fd_ops *ops, struct object *user );
extern int get_unix_fd( struct fd *fd );
extern int is_same_file_fd( struct fd *fd1, struct fd *fd2 );
extern int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
extern void fd_poll_event( struct fd *fd, int event );
extern int check_fd_events( struct fd *fd, int events );
extern void set_fd_events( struct fd *fd, int events );

View File

@ -80,7 +80,7 @@ static const struct object_ops mailslot_ops =
mailslot_get_fd, /* get_fd */
mailslot_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
mailslot_destroy /* destroy */
};
@ -124,7 +124,7 @@ static const struct object_ops mail_writer_ops =
mail_writer_get_fd, /* get_fd */
mail_writer_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
mail_writer_destroy /* destroy */
};
@ -167,7 +167,7 @@ static const struct object_ops mailslot_device_ops =
mailslot_device_get_fd, /* get_fd */
no_map_access, /* map_access */
mailslot_device_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
mailslot_device_destroy /* destroy */
};

View File

@ -68,7 +68,7 @@ static const struct object_ops mapping_ops =
mapping_get_fd, /* get_fd */
mapping_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
mapping_destroy /* destroy */
};

View File

@ -148,7 +148,7 @@ static const struct object_ops pipe_server_ops =
pipe_server_get_fd, /* get_fd */
pipe_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
pipe_server_destroy /* destroy */
};
@ -181,7 +181,7 @@ static const struct object_ops pipe_client_ops =
pipe_client_get_fd, /* get_fd */
pipe_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
pipe_client_destroy /* destroy */
};
@ -214,7 +214,7 @@ static const struct object_ops named_pipe_device_ops =
named_pipe_device_get_fd, /* get_fd */
pipe_map_access, /* map_access */
named_pipe_device_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
named_pipe_device_destroy /* destroy */
};

View File

@ -104,7 +104,7 @@ static const struct object_ops serial_ops =
serial_get_fd, /* get_fd */
serial_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
serial_destroy /* destroy */
};

View File

@ -114,7 +114,7 @@ static const struct object_ops sock_ops =
sock_get_fd, /* get_fd */
sock_map_access, /* map_access */
no_lookup_name, /* lookup_name */
no_close_handle, /* close_handle */
fd_close_handle, /* close_handle */
sock_destroy /* destroy */
};