* fhandler_socket.cc (fhandler_socket::eid_pipe_name): Fix format
string. (fhandler_socket::connect): Set sun_path before running eid credential transaction. Run transaction only if OS connect was successful. (fhandler_socket::accept): Run transaction only if OS accept was successful.
This commit is contained in:
		| @@ -1,4 +1,13 @@ | |||||||
| 2005-03-08  Corinna Vinschen  <corinna@vinschen.de> | 2005-03-09  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
|  | 	* fhandler_socket.cc (fhandler_socket::eid_pipe_name): Fix format | ||||||
|  | 	string. | ||||||
|  | 	(fhandler_socket::connect): Set sun_path before running eid credential | ||||||
|  | 	transaction.  Run transaction only if OS connect was successful. | ||||||
|  | 	(fhandler_socket::accept): Run transaction only if OS accept was | ||||||
|  | 	successful. | ||||||
|  |  | ||||||
|  | 2005-03-09  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* signal.cc (sigprocmask): Rename first parameter to "how". | 	* signal.cc (sigprocmask): Rename first parameter to "how". | ||||||
| 	(handle_sigprocmask): Ditto.  Check "how" for being a valid "how" value. | 	(handle_sigprocmask): Ditto.  Check "how" for being a valid "how" value. | ||||||
|   | |||||||
| @@ -56,7 +56,8 @@ secret_event_name (char *buf, short port, int *secret_ptr) | |||||||
| char * | char * | ||||||
| fhandler_socket::eid_pipe_name (char *buf) | fhandler_socket::eid_pipe_name (char *buf) | ||||||
| { | { | ||||||
|   __small_sprintf (buf, "\\\\.\\pipe\\cygwin-unix-$s", get_sun_path ()); |   __small_sprintf (buf, "\\\\.\\pipe\\cygwin-unix-%s", get_sun_path ()); | ||||||
|  |   debug_printf ("%s", buf); | ||||||
|   return buf; |   return buf; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -666,7 +667,10 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen) | |||||||
| 	  res = -1; | 	  res = -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |       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 () }; | ||||||
| @@ -675,8 +679,8 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen) | |||||||
| 	      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)) | ||||||
| 		{ | 		{ | ||||||
| 	      debug_printf ("Received eid credentials: pid: %d, uid: %d, gid: %d", | 		  debug_printf ("Received eid credentials: pid: %d, uid: %d" | ||||||
| 			    out.pid, out.uid, out.gid); | 		  		", gid: %d", out.pid, out.uid, out.gid); | ||||||
| 		  sec_peer_pid = out.pid; | 		  sec_peer_pid = out.pid; | ||||||
| 		  sec_peer_uid = out.uid; | 		  sec_peer_uid = out.uid; | ||||||
| 		  sec_peer_gid = out.gid; | 		  sec_peer_gid = out.gid; | ||||||
| @@ -692,6 +696,7 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen) | |||||||
| 	      sec_peer_gid = getegid32 (); | 	      sec_peer_gid = getegid32 (); | ||||||
| 	    } | 	    } | ||||||
| 	} | 	} | ||||||
|  |     } | ||||||
|  |  | ||||||
|   err = WSAGetLastError (); |   err = WSAGetLastError (); | ||||||
|   if (err == WSAEINPROGRESS || err == WSAEALREADY) |   if (err == WSAEINPROGRESS || err == WSAEALREADY) | ||||||
| @@ -796,6 +801,8 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) | |||||||
| 	  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 ()) | ||||||
| 	    { | 	    { | ||||||
| @@ -806,8 +813,8 @@ fhandler_socket::accept (struct sockaddr *peer, int *len) | |||||||
| 		  if (!ReadFile (sec_pipe, &out, sizeof out, &bytes, NULL)) | 		  if (!ReadFile (sec_pipe, &out, sizeof out, &bytes, NULL)) | ||||||
| 		    debug_printf ("Receiving eid credentials failed: %E"); | 		    debug_printf ("Receiving eid credentials failed: %E"); | ||||||
| 		  else | 		  else | ||||||
| 		 debug_printf ("Received eid credentials: pid: %d, uid: %d, gid: %d", | 		    debug_printf ("Received eid credentials: pid: %d, uid: %d" | ||||||
| 			       out.pid, out.uid, out.gid); | 		    		  ", gid: %d", out.pid, out.uid, out.gid); | ||||||
| 		  if (!WriteFile (sec_pipe, &in, sizeof in, &bytes, NULL)) | 		  if (!WriteFile (sec_pipe, &in, sizeof in, &bytes, NULL)) | ||||||
| 		    debug_printf ("Sending eid credentials failed: %E"); | 		    debug_printf ("Sending eid credentials failed: %E"); | ||||||
| 		  DisconnectNamedPipe (sec_pipe); | 		  DisconnectNamedPipe (sec_pipe); | ||||||
| @@ -823,6 +830,7 @@ 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 (); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user