#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
extern fhandler_socket *fdsock (int& fd, const char *name, SOCKET soc);
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,
delete entropy_source;
entropy_source = NULL;
}
- if (!entropy_source)
+ if (entropy_source)
{
size_t len = sizeof (connect_secret);
entropy_source->read (connect_secret, len);
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);
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 */;
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 ();
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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 = {
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;
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 = "??";