From d4f3ce316cf6c5e3f1d7a6af1a2721f851be8879 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 20 May 2003 15:22:09 +0000 Subject: * fhandler_socket.cc (SECRET_EVENT_NAME): Remove. (ENTROPY_SOURCE_NAME): Ditto. (secret_event_name): New static function. Create shared event name with "Global\" prefix on systems supporting terminal services. (fhandler_socket::set_connect_secret): Fix conditional. (fhandler_socket::create_secret_event): Create secret event using secret_event_name(). (fhandler_socket::close_secret_event): Ditto. * shared.cc (shared_name): Create shared object name with "Global\" prefix on systems supporting terminal services. * wincap.cc: Set has_terminal_services capability throughout. (wincap_2003): New global object representing Windows 2003 Server capabilities. (wincapc::init): Accomodate Windows 2003 Server. * wincap.h (struct wincaps): Add has_terminal_services capability. --- winsup/cygwin/ChangeLog | 18 ++++++++ winsup/cygwin/fhandler_socket.cc | 43 ++++++++++--------- winsup/cygwin/shared.cc | 4 +- winsup/cygwin/wincap.cc | 91 +++++++++++++++++++++++++++++++++------- winsup/cygwin/wincap.h | 2 + 5 files changed, 122 insertions(+), 36 deletions(-) (limited to 'winsup/cygwin') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 98a2652..1438afb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,21 @@ +2003-05-20 Corinna Vinschen + + * fhandler_socket.cc (SECRET_EVENT_NAME): Remove. + (ENTROPY_SOURCE_NAME): Ditto. + (secret_event_name): New static function. Create shared event name + with "Global\" prefix on systems supporting terminal services. + (fhandler_socket::set_connect_secret): Fix conditional. + (fhandler_socket::create_secret_event): Create secret event using + secret_event_name(). + (fhandler_socket::close_secret_event): Ditto. + * shared.cc (shared_name): Create shared object name with "Global\" + prefix on systems supporting terminal services. + * wincap.cc: Set has_terminal_services capability throughout. + (wincap_2003): New global object representing Windows 2003 Server + capabilities. + (wincapc::init): Accomodate Windows 2003 Server. + * wincap.h (struct wincaps): Add has_terminal_services capability. + 2003-05-20 Charles Wilson * winsup/cygwin/include/cygwin/version.h: Bump API minor version. diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index c53c3b5..452299b 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -34,8 +34,6 @@ #include "wsock_event.h" #include -#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 extern fhandler_socket *fdsock (int& fd, const char *name, SOCKET soc); @@ -45,6 +43,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, @@ -211,7 +222,7 @@ fhandler_socket::set_connect_secret () delete entropy_source; entropy_source = NULL; } - if (!entropy_source) + if (entropy_source) { size_t len = sizeof (connect_secret); entropy_source->read (connect_secret, len); @@ -231,8 +242,6 @@ fhandler_socket::get_connect_secret (char* buf) 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 +251,12 @@ fhandler_socket::create_secret_event (int* secret) 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 +291,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 (); diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc index ae30e73..2a6ae90 100644 --- a/winsup/cygwin/shared.cc +++ b/winsup/cygwin/shared.cc @@ -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; diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index b5385f2..37ec6ef 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -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 = "??"; diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h index 066374f..b1f43d6 100644 --- a/winsup/cygwin/wincap.h +++ b/winsup/cygwin/wincap.h @@ -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 }; -- cgit v1.1