]> sourceware.org Git - newlib-cygwin.git/commitdiff
* transport_pipes.h (PIPE_NAME_PREFIX): New define.
authorCorinna Vinschen <corinna@vinschen.de>
Sat, 31 Oct 2009 13:24:43 +0000 (13:24 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Sat, 31 Oct 2009 13:24:43 +0000 (13:24 +0000)
(PIPE_NAME_SUFFIX): Ditto.
(class transport_layer_pipes): Convert _pipe_name from char pointer
to wchar_t array.
* transport_pipes.cc (transport_layer_pipes::transport_layer_pipes):
Accommodate the fact that _pipe_name is a wchar_t array, rather than
a char pointer.
(transport_layer_pipes::transport_layer_pipes): Initialize _pipe_name
with variable pipe name based in installation key fetched from Cygwin
DLL.
(transport_layer_pipes::accept): Call CreateNamedPipeW explicitely.
(transport_layer_pipes::connect): Call CreateFileW and WaitNamedPipeW
explicitely.

winsup/cygserver/ChangeLog
winsup/cygserver/transport_pipes.cc
winsup/cygserver/transport_pipes.h

index d7c7ed9d92985d73ce43213b70061b8f9ad118d9..dbc28ba544e83a702551ed43a4d39d56d9876d38 100644 (file)
@@ -1,3 +1,19 @@
+2009-10-31  Corinna Vinschen  <corinna@vinschen.de>
+
+       * transport_pipes.h (PIPE_NAME_PREFIX): New define.
+       (PIPE_NAME_SUFFIX): Ditto.
+       (class transport_layer_pipes): Convert _pipe_name from char pointer
+       to wchar_t array.
+       * transport_pipes.cc (transport_layer_pipes::transport_layer_pipes):
+       Accommodate the fact that _pipe_name is a wchar_t array, rather than
+       a char pointer.
+       (transport_layer_pipes::transport_layer_pipes): Initialize _pipe_name
+       with variable pipe name based in installation key fetched from Cygwin
+       DLL.
+       (transport_layer_pipes::accept): Call CreateNamedPipeW explicitely.
+       (transport_layer_pipes::connect): Call CreateFileW and WaitNamedPipeW
+       explicitely.
+
 2009-08-18  Corinna Vinschen  <corinna@vinschen.de>
 
        * Makefile.in (CXXFLAGS): Allow override.
index 9fdf75899a71e8864b9db33c2bedd5f5333046f0..1a67d2044113c8e834ff8f950e15020ac183918d 100644 (file)
@@ -1,6 +1,6 @@
 /* transport_pipes.cc
 
-   Copyright 2001, 2002, 2003, 2004 Red Hat Inc.
+   Copyright 2001, 2002, 2003, 2004, 2009 Red Hat Inc.
 
    Written by Robert Collins <rbtcollins@hotmail.com>
 
@@ -23,6 +23,8 @@ details. */
 #include <netdb.h>
 #include <pthread.h>
 #include <unistd.h>
+#include <wchar.h>
+#include <sys/cygwin.h>
 
 #include "cygerrno.h"
 #include "transport.h"
@@ -65,24 +67,33 @@ initialise_pipe_instance_lock ()
 #ifndef __INSIDE_CYGWIN__
 
 transport_layer_pipes::transport_layer_pipes (const HANDLE hPipe)
-  : _pipe_name (""),
-    _hPipe (hPipe),
+  : _hPipe (hPipe),
     _is_accepted_endpoint (true),
     _is_listening_endpoint (false)
 {
   assert (_hPipe);
   assert (_hPipe != INVALID_HANDLE_VALUE);
-
+  _pipe_name[0] = L'\0';
 }
 
 #endif /* !__INSIDE_CYGWIN__ */
 
 transport_layer_pipes::transport_layer_pipes ()
-  : _pipe_name ("\\\\.\\pipe\\cygwin_lpc"),
-    _hPipe (NULL),
+  : _hPipe (NULL),
     _is_accepted_endpoint (false),
     _is_listening_endpoint (false)
 {
+#ifdef __INSIDE_CYGWIN__
+  extern WCHAR installation_key_buf[18];
+  wcpcpy (wcpcpy (wcpcpy (_pipe_name, PIPE_NAME_PREFIX), installation_key_buf),
+         PIPE_NAME_SUFFIX);
+#else
+  wchar_t cyg_instkey[18];
+
+  wchar_t *p = wcpcpy (_pipe_name, PIPE_NAME_PREFIX);
+  if (cygwin_internal (CW_GET_INSTKEY, cyg_instkey))
+    wcpcpy (wcpcpy (p, cyg_instkey), PIPE_NAME_SUFFIX);
+#endif
 }
 
 transport_layer_pipes::~transport_layer_pipes ()
@@ -124,7 +135,7 @@ transport_layer_pipes::accept (bool *const recoverable)
   const bool first_instance = (pipe_instance == 0);
 
   const HANDLE accept_pipe =
-    CreateNamedPipe (_pipe_name,
+    CreateNamedPipeW (_pipe_name,
                     (PIPE_ACCESS_DUPLEX
                      | (first_instance ? FILE_FLAG_FIRST_PIPE_INSTANCE : 0)),
                     (PIPE_TYPE_BYTE | PIPE_WAIT),
@@ -270,13 +281,13 @@ transport_layer_pipes::connect ()
 
   while (rc)
     {
-      _hPipe = CreateFile (_pipe_name,
-                          GENERIC_READ | GENERIC_WRITE,
-                          FILE_SHARE_READ | FILE_SHARE_WRITE,
-                          &sec_all_nih,
-                          OPEN_EXISTING,
-                          SECURITY_IMPERSONATION,
-                          NULL);
+      _hPipe = CreateFileW (_pipe_name,
+                           GENERIC_READ | GENERIC_WRITE,
+                           FILE_SHARE_READ | FILE_SHARE_WRITE,
+                           &sec_all_nih,
+                           OPEN_EXISTING,
+                           SECURITY_IMPERSONATION,
+                           NULL);
 
       if (_hPipe != INVALID_HANDLE_VALUE)
        {
@@ -302,7 +313,7 @@ transport_layer_pipes::connect ()
        * with ERROR_FILE_NOT_FOUND.
        */
       while (retries != MAX_WAIT_NAMED_PIPE_RETRY
-            && !(rc = WaitNamedPipe (_pipe_name, WAIT_NAMED_PIPE_TIMEOUT)))
+            && !(rc = WaitNamedPipeW (_pipe_name, WAIT_NAMED_PIPE_TIMEOUT)))
        {
          if (GetLastError () == ERROR_FILE_NOT_FOUND)
            Sleep (0);          // Give the server a chance.
index 7265a88f818b3c042ad9b279ec36e4bccf82cf6f..1368121067fd1f095a83321d132c85d3c6570415 100644 (file)
@@ -13,6 +13,9 @@ details. */
 #ifndef _TRANSPORT_PIPES_H
 #define _TRANSPORT_PIPES_H
 
+#define PIPE_NAME_PREFIX       L"\\\\.\\pipe\\cygwin-"
+#define PIPE_NAME_SUFFIX       L"-lpc"
+
 /* Named pipes based transport, for security on NT */
 class transport_layer_pipes : public transport_layer_base
 {
@@ -36,7 +39,7 @@ public:
   virtual ~transport_layer_pipes ();
 
 private:
-  const char *const _pipe_name;
+  wchar_t _pipe_name[40];
   HANDLE _hPipe;
   const bool _is_accepted_endpoint;
   bool _is_listening_endpoint;
This page took 0.036038 seconds and 5 git commands to generate.