This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: Cygwin XP Fast User Switching Support?
On Tue, May 20, 2003 at 09:42:26AM -0400, Jason Tishler wrote:
> In the above case, the event created to improve the security of Cygwin's
> AF_UNIX implementation is not visible to psql unless it is running in
> Terminal Session 0. Note this problem affects all client/server apps
> using AF_UNIX sockets when the server runs as a service. I'm concerned
> that there may be other cases too...
There are. More or less all shared objects created in Cygwin are
affected by this. I've created a patch for it. Could you please
apply the below patch and test if it works now?
Basically it adds a new wincap capability (has_terminal_services) which
is true only for 2K, XP, 2003 and then it prepends a "Global\" to the
name of shared objects if we're running on one of these systems.
Corinna
Index: fhandler_socket.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_socket.cc,v
retrieving revision 1.92
diff -u -p -r1.92 fhandler_socket.cc
--- fhandler_socket.cc 11 May 2003 21:52:09 -0000 1.92
+++ fhandler_socket.cc 20 May 2003 14:51:41 -0000
@@ -34,7 +34,6 @@
#include "wsock_event.h"
#include <unistd.h>
-#define SECRET_EVENT_NAME "cygwin.local_socket.secret.%d.%08x-%08x-%08x-%08x"
#define ENTROPY_SOURCE_NAME "/dev/urandom"
#define ENTROPY_SOURCE_DEV_UNIT 9
@@ -45,6 +44,19 @@ int sscanf (const char *, const char *,
fhandler_dev_random* entropy_source;
+static char *
+secret_event_name (short port, int *secret_ptr)
+{
+ static NO_COPY char buf[MAX_PATH] = {0};
+
+ __small_sprintf (buf, "%scygwin.local_socket.secret.%d.%08x-%08x-%08x-%08x",
+ wincap.has_terminal_services () ? "Global\\" : "",
+ port,
+ secret_ptr [0], secret_ptr [1],
+ secret_ptr [2], secret_ptr [3]);
+ return buf;
+}
+
/* cygwin internal: map sockaddr into internet domain address */
static int
get_inet_addr (const struct sockaddr *in, int inlen,
@@ -231,8 +243,6 @@ fhandler_socket::get_connect_secret (cha
HANDLE
fhandler_socket::create_secret_event (int* secret)
{
- char buf [128];
- int* secret_ptr = (secret ? : connect_secret);
struct sockaddr_in sin;
int sin_len = sizeof (sin);
@@ -242,13 +252,12 @@ fhandler_socket::create_secret_event (in
return NULL;
}
- __small_sprintf (buf, SECRET_EVENT_NAME, sin.sin_port,
- secret_ptr [0], secret_ptr [1],
- secret_ptr [2], secret_ptr [3]);
+ char *event_name = secret_event_name (sin.sin_port,
+ secret ?: connect_secret);
LPSECURITY_ATTRIBUTES sec = get_inheritance (true);
- secret_event = CreateEvent (sec, FALSE, FALSE, buf);
+ secret_event = CreateEvent (sec, FALSE, FALSE, event_name);
if (!secret_event && GetLastError () == ERROR_ALREADY_EXISTS)
- secret_event = OpenEvent (EVENT_ALL_ACCESS, FALSE, buf);
+ secret_event = OpenEvent (EVENT_ALL_ACCESS, FALSE, event_name);
if (!secret_event)
/* nothing to do */;
@@ -283,18 +292,13 @@ fhandler_socket::close_secret_event ()
int
fhandler_socket::check_peer_secret_event (struct sockaddr_in* peer, int* secret)
{
- char buf [128];
- HANDLE ev;
- int* secret_ptr = (secret ? : connect_secret);
-
- __small_sprintf (buf, SECRET_EVENT_NAME, peer->sin_port,
- secret_ptr [0], secret_ptr [1],
- secret_ptr [2], secret_ptr [3]);
- ev = CreateEvent (&sec_all_nih, FALSE, FALSE, buf);
+ char *event_name = secret_event_name (peer->sin_port,
+ secret ?: connect_secret);
+ HANDLE ev = CreateEvent (&sec_all_nih, FALSE, FALSE, event_name);
if (!ev && GetLastError () == ERROR_ALREADY_EXISTS)
{
- debug_printf ("event \"%s\" already exists", buf);
- ev = OpenEvent (EVENT_ALL_ACCESS, FALSE, buf);
+ debug_printf ("event \"%s\" already exists", event_name);
+ ev = OpenEvent (EVENT_ALL_ACCESS, FALSE, event_name);
}
signal_secret_event ();
Index: shared.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/shared.cc,v
retrieving revision 1.65
diff -u -p -r1.65 shared.cc
--- shared.cc 31 Jan 2003 15:02:40 -0000 1.65
+++ shared.cc 20 May 2003 14:51:41 -0000
@@ -38,7 +38,9 @@ shared_name (const char *str, int num)
static NO_COPY char buf[MAX_PATH] = {0};
extern bool _cygwin_testing;
- __small_sprintf (buf, "%s.%s.%d", cygwin_version.shared_id, str, num);
+ __small_sprintf (buf, "%s%s.%s.%d",
+ wincap.has_terminal_services () ? "Global\\" : "",
+ cygwin_version.shared_id, str, num);
if (_cygwin_testing)
strcat (buf, cygwin_version.dll_build_date);
return buf;
Index: wincap.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/wincap.cc,v
retrieving revision 1.21
diff -u -p -r1.21 wincap.cc
--- wincap.cc 20 Apr 2003 01:36:15 -0000 1.21
+++ wincap.cc 20 May 2003 14:51:41 -0000
@@ -48,7 +48,8 @@ static NO_COPY wincaps wincap_unknown =
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
needs_memory_protection:false,
- pty_needs_alloc_console:false
+ pty_needs_alloc_console:false,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_95 = {
@@ -88,7 +89,8 @@ static NO_COPY wincaps wincap_95 = {
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
needs_memory_protection:false,
- pty_needs_alloc_console:false
+ pty_needs_alloc_console:false,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_95osr2 = {
@@ -128,7 +130,8 @@ static NO_COPY wincaps wincap_95osr2 = {
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
needs_memory_protection:false,
- pty_needs_alloc_console:false
+ pty_needs_alloc_console:false,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_98 = {
@@ -168,7 +171,8 @@ static NO_COPY wincaps wincap_98 = {
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
needs_memory_protection:false,
- pty_needs_alloc_console:false
+ pty_needs_alloc_console:false,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_98se = {
@@ -208,7 +212,8 @@ static NO_COPY wincaps wincap_98se = {
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
needs_memory_protection:false,
- pty_needs_alloc_console:false
+ pty_needs_alloc_console:false,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_me = {
@@ -248,7 +253,8 @@ static NO_COPY wincaps wincap_me = {
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
needs_memory_protection:false,
- pty_needs_alloc_console:false
+ pty_needs_alloc_console:false,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_nt3 = {
@@ -288,7 +294,8 @@ static NO_COPY wincaps wincap_nt3 = {
has_process_io_counters:false,
supports_reading_modem_output_lines:true,
needs_memory_protection:true,
- pty_needs_alloc_console:true
+ pty_needs_alloc_console:true,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_nt4 = {
@@ -328,7 +335,8 @@ static NO_COPY wincaps wincap_nt4 = {
has_process_io_counters:false,
supports_reading_modem_output_lines:true,
needs_memory_protection:true,
- pty_needs_alloc_console:true
+ pty_needs_alloc_console:true,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_nt4sp4 = {
@@ -368,7 +376,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
has_process_io_counters:false,
supports_reading_modem_output_lines:true,
needs_memory_protection:true,
- pty_needs_alloc_console:true
+ pty_needs_alloc_console:true,
+ has_terminal_services:false
};
static NO_COPY wincaps wincap_2000 = {
@@ -408,7 +417,8 @@ static NO_COPY wincaps wincap_2000 = {
has_process_io_counters:true,
supports_reading_modem_output_lines:true,
needs_memory_protection:true,
- pty_needs_alloc_console:true
+ pty_needs_alloc_console:true,
+ has_terminal_services:true
};
static NO_COPY wincaps wincap_xp = {
@@ -448,7 +458,49 @@ static NO_COPY wincaps wincap_xp = {
has_process_io_counters:true,
supports_reading_modem_output_lines:true,
needs_memory_protection:true,
- pty_needs_alloc_console:true
+ pty_needs_alloc_console:true,
+ has_terminal_services:true
+};
+
+static NO_COPY wincaps wincap_2003 = {
+ lock_file_highword:0xffffffff,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ access_denied_on_delete:false,
+ has_delete_on_close:true,
+ has_page_guard:true,
+ has_security:true,
+ has_security_descriptor_control:true,
+ has_get_process_times:true,
+ has_lseek_bug:false,
+ has_lock_file_ex:true,
+ has_signal_object_and_wait:true,
+ has_eventlog:true,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:true,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:true,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true,
+ has_terminal_services:true
};
wincapc wincap;
@@ -483,10 +535,19 @@ wincapc::init ()
break;
case 5:
os = "NT";
- if (version.dwMinorVersion == 0)
- caps = &wincap_2000;
- else
- caps = &wincap_xp;
+ switch (version.dwMinorVersion)
+ {
+ case 0:
+ caps = &wincap_2000;
+ break;
+
+ case 1:
+ caps = &wincap_xp;
+ break;
+
+ default:
+ caps = &wincap_2003;
+ }
break;
default:
os = "??";
Index: wincap.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/wincap.h,v
retrieving revision 1.17
diff -u -p -r1.17 wincap.h
--- wincap.h 20 Apr 2003 01:36:15 -0000 1.17
+++ wincap.h 20 May 2003 14:51:41 -0000
@@ -50,6 +50,7 @@ struct wincaps
unsigned supports_reading_modem_output_lines : 1;
unsigned needs_memory_protection : 1;
unsigned pty_needs_alloc_console : 1;
+ unsigned has_terminal_services : 1;
};
class wincapc
@@ -104,6 +105,7 @@ public:
bool IMPLEMENT (supports_reading_modem_output_lines)
bool IMPLEMENT (needs_memory_protection)
bool IMPLEMENT (pty_needs_alloc_console)
+ bool IMPLEMENT (has_terminal_services)
#undef IMPLEMENT
};
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.