* fhandler_socket.cc (fhandler_socket::fhandler_socket): Fix compiler

warning.
	(fhandler_socket::fstat): Simplify.  Set st_uid/st_gid to effective
	uid/gid of current process in case of open sockets.
This commit is contained in:
Corinna Vinschen 2003-02-21 14:59:35 +00:00
parent cf762b08cf
commit b1d1e50d04
2 changed files with 13 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2003-02-21 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Fix compiler
warning.
(fhandler_socket::fstat): Simplify. Set st_uid/st_gid to effective
uid/gid of current process in case of open sockets.
2003-02-21 Corinna Vinschen <corinna@vinschen.de> 2003-02-21 Corinna Vinschen <corinna@vinschen.de>
* dtable.cc (dtable::build_fhandler_from_name): Set some fhandler * dtable.cc (dtable::build_fhandler_from_name): Set some fhandler

View File

@ -95,7 +95,7 @@ get_inet_addr (const struct sockaddr *in, int inlen,
/* fhandler_socket */ /* fhandler_socket */
fhandler_socket::fhandler_socket (int nunit) fhandler_socket::fhandler_socket (int nunit)
: fhandler_base (FH_SOCKET), unit (nunit), sun_path (NULL) : fhandler_base (FH_SOCKET), sun_path (NULL), unit (nunit)
{ {
set_need_fork_fixup (); set_need_fork_fixup ();
prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF, prot_info_ptr = (LPWSAPROTOCOL_INFOA) cmalloc (HEAP_BUF,
@ -310,7 +310,7 @@ int __stdcall
fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc) fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc)
{ {
int res; int res;
if (get_addr_family () == AF_LOCAL && get_sun_path ()) if (get_addr_family () == AF_LOCAL && get_sun_path () && !get_socket_type ())
{ {
path_conv spc (get_sun_path (), path_conv spc (get_sun_path (),
PC_SYM_NOFOLLOW | PC_NULLEMPTY | PC_FULL | PC_POSIX, PC_SYM_NOFOLLOW | PC_NULLEMPTY | PC_FULL | PC_POSIX,
@ -321,13 +321,6 @@ fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc)
if (fh) if (fh)
{ {
res = fh->fstat (buf, &spc); res = fh->fstat (buf, &spc);
/* Faking Linux like values on top of the file specific values. */
if (get_socket_type ()) /* fstat() */
{
buf->st_dev = 0;
buf->st_mode |= S_IRWXU | S_IRWXG | S_IRWXO;
buf->st_ino = (ino_t) get_handle ();
}
buf->st_rdev = buf->st_size = buf->st_blocks = 0; buf->st_rdev = buf->st_size = buf->st_blocks = 0;
return res; return res;
} }
@ -338,9 +331,11 @@ fhandler_socket::fstat (struct __stat64 *buf, path_conv *pc)
{ {
if (get_socket_type ()) /* fstat */ if (get_socket_type ()) /* fstat */
{ {
buf->st_dev = 0;
buf->st_ino = (ino_t) get_handle (); buf->st_ino = (ino_t) get_handle ();
buf->st_mode &= ~S_IFMT; buf->st_mode = S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO;
buf->st_mode |= S_IFSOCK; buf->st_uid = geteuid32 ();
buf->st_gid = getegid32 ();
} }
else else
{ {