* fhandler_socket.cc (fhandler_socket::connect): Always set sun_path

in case of a successful or pending connect.
	(fhandler_socket::accept): Don't run secret event and eid credential
	transactions if OS accept returned WSAEWOULDBLOCK.
This commit is contained in:
Corinna Vinschen 2005-03-17 11:56:30 +00:00
parent 333eabc6f8
commit 2e7c4a2ab1
2 changed files with 41 additions and 42 deletions

View File

@ -1,3 +1,10 @@
2005-03-17 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::connect): Always set sun_path
in case of a successful or pending connect.
(fhandler_socket::accept): Don't run secret event and eid credential
transactions if OS accept returned WSAEWOULDBLOCK.
2005-03-16 Christopher Faylor <cgf@timesys.com> 2005-03-16 Christopher Faylor <cgf@timesys.com>
* fhandler_tape.cc (get_ll): This is a generally useful function so * fhandler_tape.cc (get_ll): This is a generally useful function so

View File

@ -637,6 +637,10 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
} }
set_winsock_errno (); set_winsock_errno ();
} }
if (get_addr_family () == AF_LOCAL && (!res || in_progress))
set_sun_path (name->sa_data);
if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM) if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM)
{ {
if (!res || in_progress) if (!res || in_progress)
@ -670,12 +674,12 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
if (!res || in_progress) if (!res || in_progress)
{ {
/* eid credential transaction. */ /* eid credential transaction. */
set_sun_path (name->sa_data);
if (wincap.has_named_pipes ()) if (wincap.has_named_pipes ())
{ {
struct ucred in = { getpid (), geteuid32 (), getegid32 () }; struct ucred in = { getpid (), geteuid32 (), getegid32 () };
struct ucred out = { (pid_t) 0, (__uid32_t) -1, (__gid32_t) -1 }; struct ucred out = { (pid_t) 0, (__uid32_t) -1, (__gid32_t) -1 };
DWORD bytes = 0; DWORD bytes = 0;
debug_printf ("Calling CallNamedPipe");
if (CallNamedPipe(eid_pipe_name ((char *) alloca (CYG_MAX_PATH + 1)), if (CallNamedPipe(eid_pipe_name ((char *) alloca (CYG_MAX_PATH + 1)),
&in, sizeof in, &out, sizeof out, &bytes, 1000)) &in, sizeof in, &out, sizeof out, &bytes, 1000))
{ {
@ -745,7 +749,6 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
{ {
int res = -1; int res = -1;
bool secret_check_failed = false; bool secret_check_failed = false;
bool in_progress = false;
struct ucred in = { sec_pid, sec_uid, sec_gid }; struct ucred in = { sec_pid, sec_uid, sec_gid };
struct ucred out = { (pid_t) 0, (__uid32_t) -1, (__gid32_t) -1 }; struct ucred out = { (pid_t) 0, (__uid32_t) -1, (__gid32_t) -1 };
@ -769,21 +772,13 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
res = ::accept (get_socket (), peer, len); res = ::accept (get_socket (), peer, len);
if ((SOCKET) res == INVALID_SOCKET && WSAGetLastError () == WSAEWOULDBLOCK) if ((SOCKET) res != INVALID_SOCKET && get_addr_family () == AF_LOCAL
in_progress = true; && get_socket_type () == SOCK_STREAM)
if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM)
{
if ((SOCKET) res != INVALID_SOCKET || in_progress)
{ {
if (!create_secret_event ()) if (!create_secret_event ())
secret_check_failed = true; secret_check_failed = true;
else if (in_progress)
signal_secret_event ();
}
if (!secret_check_failed && if (!secret_check_failed)
(SOCKET) res != INVALID_SOCKET)
{ {
if (!check_peer_secret_event ((struct sockaddr_in*) peer)) if (!check_peer_secret_event ((struct sockaddr_in*) peer))
{ {
@ -795,18 +790,16 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
if (secret_check_failed) if (secret_check_failed)
{ {
close_secret_event (); close_secret_event ();
if ((SOCKET) res != INVALID_SOCKET)
closesocket (res); closesocket (res);
set_errno (ECONNABORTED); set_errno (ECONNABORTED);
return -1; return -1;
} }
if ((SOCKET) res != INVALID_SOCKET || in_progress)
{
/* eid credential transaction. */ /* eid credential transaction. */
if (wincap.has_named_pipes ()) if (wincap.has_named_pipes ())
{ {
DWORD bytes = 0; DWORD bytes = 0;
debug_printf ("Calling ConnectNamedPipe");
bool ret = ConnectNamedPipe (sec_pipe, NULL); bool ret = ConnectNamedPipe (sec_pipe, NULL);
if (ret || GetLastError () == ERROR_PIPE_CONNECTED) if (ret || GetLastError () == ERROR_PIPE_CONNECTED)
{ {
@ -830,7 +823,6 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
out.gid = sec_gid; out.gid = sec_gid;
} }
} }
}
if ((SOCKET) res == INVALID_SOCKET) if ((SOCKET) res == INVALID_SOCKET)
set_winsock_errno (); set_winsock_errno ();