summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-05-29 16:16:59 +0000
committerCorinna Vinschen <corinna@vinschen.de>2003-05-29 16:16:59 +0000
commit4e2db52c1c2e4f2121b75d9b075d4779cc3f22e3 (patch)
treedd5706019e2ff7663b542a6bc3f1390bfdf94f79
parent14afd35266d4b10a4ba27fb411a8751d36cc9e7c (diff)
downloadcygnal-4e2db52c1c2e4f2121b75d9b075d4779cc3f22e3.tar.gz
cygnal-4e2db52c1c2e4f2121b75d9b075d4779cc3f22e3.tar.bz2
cygnal-4e2db52c1c2e4f2121b75d9b075d4779cc3f22e3.zip
* fhandler_socket.cc (fhandler_socket::dup): Rearrange. Fix
conditional.
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/fhandler_socket.cc43
2 files changed, 29 insertions, 22 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 978b09c61..9fb7debcc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2003-05-29 Pierre Humblet <pierre.humblet@ieee.org>
+ Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler_socket.cc (fhandler_socket::dup): Rearrange. Fix
+ conditional.
+
2003-05-28 Christopher Faylor <cgf@redhat.com>
* mkvers.sh: Avoid "-dontuse" tags.
@@ -9,7 +15,7 @@
(mount_info::conv_to_win32_path): Use build_win32 to build windows
path.
* path.h (mount_item::fnmunge): Declare new function.
- (mount_item::build_win32): Ditto.
+ (mount_item::build_win32): Ditto.
* sys/mount.h (MOUNT_ENC): Define.
2003-05-28 Corinna Vinschen <corinna@vinschen.de>
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 0858c98a9..23914e47e 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -396,33 +396,34 @@ fhandler_socket::dup (fhandler_base *child)
debug_printf ("here");
fhandler_socket *fhs = (fhandler_socket *) child;
fhs->addr_family = addr_family;
- fhs->set_io_handle (get_io_handle ());
if (get_addr_family () == AF_LOCAL)
fhs->set_sun_path (get_sun_path ());
fhs->set_socket_type (get_socket_type ());
- /* Since WSADuplicateSocket() fails on NT systems when the process
- is currently impersonating a non-privileged account, we revert
- to the original account before calling WSADuplicateSocket() and
- switch back afterwards as it's also in fork().
- If WSADuplicateSocket() still fails for some reason, we fall back
- to DuplicateHandle(). */
-
- WSASetLastError (0);
- if (cygheap->user.issetuid ())
- RevertToSelf ();
- fhs->fixup_before_fork_exec (GetCurrentProcessId ());
- if (cygheap->user.issetuid ())
- ImpersonateLoggedOnUser (cygheap->user.token);
- if (winsock2_active && !WSAGetLastError ())
+ if (winsock2_active)
{
- fhs->fixup_after_fork (hMainProc);
- if (get_io_handle() != (HANDLE) INVALID_SOCKET)
- return 0;
+ /* Since WSADuplicateSocket() fails on NT systems when the process
+ is currently impersonating a non-privileged account, we revert
+ to the original account before calling WSADuplicateSocket() and
+ switch back afterwards as it's also in fork().
+ If WSADuplicateSocket() still fails for some reason, we fall back
+ to DuplicateHandle(). */
+ WSASetLastError (0);
+ if (cygheap->user.issetuid ())
+ RevertToSelf ();
+ fhs->set_io_handle (get_io_handle ());
+ fhs->fixup_before_fork_exec (GetCurrentProcessId ());
+ if (cygheap->user.issetuid ())
+ ImpersonateLoggedOnUser (cygheap->user.token);
+ if (!WSAGetLastError ())
+ {
+ fhs->fixup_after_fork (hMainProc);
+ if (fhs->get_io_handle() != (HANDLE) INVALID_SOCKET)
+ return 0;
+ }
+ debug_printf ("WSADuplicateSocket failed, trying DuplicateHandle");
}
- debug_printf ("WSADuplicateSocket failed, trying DuplicateHandle");
-
/* We don't call fhandler_base::dup here since that requires to
have winsock called from fhandler_base and it creates only
inheritable sockets which is wrong for winsock2. */
@@ -435,7 +436,7 @@ fhandler_socket::dup (fhandler_base *child)
__seterrno ();
return -1;
}
- child->set_io_handle (nh);
+ fhs->set_io_handle (nh);
return 0;
}