* dtable.cc (dtable::build_fhandler_from_name): Set some fhandler

data on sockets to evaluate AF_LOCAL sockets correctly.
	(dtable::build_fhandler): Set unit number on sockets.
	* fhandler.h (fhandler_socket): Add unit number.
	(fhandler_socket::get_unit): New method.
	* fhandler_socket.cc (fhandler_socket::fhandler_socket): Set unit
	number.
	(fhandler_socket::fstat): Reorganize to return more Linux-like
	values.
	* net.cc: include ctype.h.
	(fdsock): Set unit number when building fhandler.
	* path.cc (path_conv::check): Set device type to FH_SOCKET if file
	is a AF_UNIX socket.
	(get_devn): Evaluate unit for virtual socket devices.
	(win32_device_name): Set windows path for sockets to unix_path with
	just backslashes to keep the different names.
	* syscalls.cc (fstat64): Don't override st_ino, st_dev and st_rdev
	for sockets.
	(stat_worker): Ditto.

From Pierre Humblet:

	* autoload.cc (AccessCheck): Add.
	(DuplicateToken): Add.
	* security.h (check_file_access): Declare.
	* syscalls.cc (access): Convert path to Windows, check existence
	and readonly attribute. Call check_file_access instead of acl_access.
	* security.cc (check_file_access): Create.
	* sec_acl (acl_access): Delete.
This commit is contained in:
Corinna Vinschen
2003-02-21 14:29:18 +00:00
parent d05ef21d4f
commit cf762b08cf
11 changed files with 180 additions and 85 deletions

View File

@@ -1016,7 +1016,7 @@ fstat64 (int fd, struct __stat64 *buf)
path_conv pc (cfd->get_win32_name (), PC_SYM_NOFOLLOW);
memset (buf, 0, sizeof (struct __stat64));
res = cfd->fstat (buf, &pc);
if (!res)
if (!res && cfd->get_device () != FH_SOCKET)
{
if (!buf->st_ino)
buf->st_ino = hash_path_name (0, cfd->get_win32_name ());
@@ -1106,7 +1106,7 @@ stat_worker (const char *name, struct __stat64 *buf, int nofollow,
pc, (DWORD) real_path);
memset (buf, 0, sizeof (*buf));
res = fh->fstat (buf, pc);
if (!res)
if (!res && fh->get_device () != FH_SOCKET)
{
if (!buf->st_ino)
buf->st_ino = hash_path_name (0, fh->get_win32_name ());
@@ -1163,8 +1163,6 @@ cygwin_lstat (const char *name, struct __stat32 *buf)
return ret;
}
extern int acl_access (const char *, int);
extern "C" int
access (const char *fn, int flags)
{
@@ -1176,11 +1174,33 @@ access (const char *fn, int flags)
return -1;
}
if (allow_ntsec)
return acl_access (fn, flags);
path_conv real_path (fn, PC_SYM_FOLLOW | PC_FULL, stat_suffixes);
if (real_path.error)
{
set_errno (real_path.error);
return -1;
}
if (!real_path.exists ())
{
set_errno (ENOENT);
return -1;
}
if (!(flags & (R_OK | W_OK | X_OK)))
return 0;
if (real_path.has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK))
{
set_errno (EACCES);
return -1;
}
if (real_path.has_acls () && allow_ntsec)
return check_file_access (real_path, flags);
struct __stat64 st;
int r = stat_worker (fn, &st, 0);
int r = stat_worker (real_path, &st, 0);
if (r)
return -1;
r = -1;