Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com Subject: AF_UNIX on win95? From: Robert Collins To: cygwin-developers AT cygwin DOT com Content-Type: multipart/mixed; boundary="=-eReoAr509nKoCXpP9F4G" X-Mailer: Evolution/0.13 (Preview Release) Date: 13 Sep 2001 01:56:12 +1000 Message-Id: <1000310173.30375.137.camel@lifelesswks> Mime-Version: 1.0 X-OriginalArrivalTime: 12 Sep 2001 15:43:02.0796 (UTC) FILETIME=[9B83BCC0:01C13BA1] --=-eReoAr509nKoCXpP9F4G Content-Type: text/plain Content-Transfer-Encoding: 7bit Egor's magic cookie on win95 is failing for me... "accept from unauthorized server". I'm attaching the current daemon state. I can't get past a failure on connect, due to the above :[. I'm about to disable that cookie completely in my sandbox, but I was wondering if a) it's meant to work on 95, and b) the best way to go about debugging it. FWIW waitforsingleobject in fhandler_scoket::check_peer_secret_event is returning 258. Chris - if this is better on cygwin@ let me know, I suspect its developer only fodder though). Rob --=-eReoAr509nKoCXpP9F4G Content-Type: text/plain Content-Disposition: attachment; filename=daemon2.patch Content-ID: <1000309397 DOT 30340 DOT 123 DOT camel AT lifelesswks> Content-Transfer-Encoding: 7bit ? currentstate.patch ? cygserver.cc ? cygserver.cygwin.ChangeLog ? cygserver.diff ? cygserver.utils.ChangeLog ? cygserver_client.cc ? daemon.patch ? daemon2.patch ? fhandler_ums.cc ? host_dependent.cc ? mutexsviacriticalsections.patch ? pthchange ? umsdos_gen.h ? virtualquery.patch ? include/cygwin/cygserver.h Index: Makefile.in =================================================================== RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v retrieving revision 1.60 diff -u -p -r1.60 Makefile.in --- Makefile.in 2001/09/11 20:01:00 1.60 +++ Makefile.in 2001/09/12 15:41:38 @@ -116,13 +116,13 @@ MALLOC_OFILES=@MALLOC_OFILES@ DLL_IMPORTS:=$(w32api_lib)/libkernel32.a -DLL_OFILES:=assert.o autoload.o cygheap.o dcrt0.o debug.o delqueue.o dir.o \ +DLL_OFILES:=assert.o autoload.o cygheap.o cygserver_client.o dcrt0.o debug.o delqueue.o dir.o \ dlfcn.o dll_init.o dtable.o environ.o errno.o exceptions.o exec.o \ external.o fcntl.o fhandler.o fhandler_clipboard.o fhandler_console.o \ fhandler_dsp.o fhandler_floppy.o fhandler_mem.o fhandler_random.o \ fhandler_raw.o fhandler_serial.o fhandler_socket.o fhandler_tape.o \ fhandler_termios.o fhandler_tty.o fhandler_windows.o fhandler_zero.o \ - fork.o glob.o grp.o heap.o init.o ioctl.o localtime.o malloc.o \ + fork.o glob.o grp.o heap.o host_dependent.o init.o ioctl.o localtime.o malloc.o \ miscfuncs.o mmap.o net.o ntea.o passwd.o path.o pinfo.o pipe.o poll.o \ pthread.o regexp.o regerror.o regsub.o registry.o resource.o scandir.o \ sched.o sec_acl.o sec_helper.o security.o select.o shared.o shortcut.o signal.o sigproc.o \ @@ -144,14 +144,17 @@ install_host=@install_host@ all: new-$(DLL_NAME) $(all_host) all_target -all_target: $(LIBGMON_A) $(LIB_NAME) automode.o binmode.o textmode.o +all_target: $(LIBGMON_A) $(LIB_NAME) automode.o binmode.o textmode.o cygserver.exe all_host: new-$(LIB_NAME) cygrun.exe force: -install: install-libs install-headers $(install_host) $(install_target) +install: install-bin install-libs install-headers $(install_host) $(install_target) +install-bin: cygserver.exe + $(INSTALL_PROGRAM) cygserver.exe $(bindir)/cygserver.exe + install-libs: $(LIB_NAME) $(INSTALL_DATA) new-$(DLL_NAME) $(bindir)/$(DLL_NAME); \ for i in $(LIB_NAME) $(GMON_START) $(LIBGMON_A) automode.o binmode.o textmode.o ; do \ @@ -213,11 +216,20 @@ winver_stamp: mkvers.sh include/cygwin/v @echo "Making version.o and winver.o";\ $(SHELL) ${word 1,$^} ${word 2,$^} ${word 3,$^} $(WINDRES) && \ touch $@ && \ - $(COMPILE_CXX) -o version.o version.cc + $(CXX) -o version.o version.cc cygrun.exe : cygrun.o $(LIB_NAME) $(w32api_lib)/libuser32.a \ $(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a $(CC) -nodefaultlibs -o $@ $^ + +cygserver.exe: cygserver.o host_dependent.o smallprint.o + $(CXX) -o $@ $^ +#ifdef VERBOSE +# $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,3,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS) +#else +# @echo $(CXX) -o $@ ${wordlist 1,3,$^} ${filter-out -B%, $(MINGW_CXXFLAGS) $(MINGW_LDFLAGS)};\ +# $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,3,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS) +#endif # Index: dcrt0.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/dcrt0.cc,v retrieving revision 1.108 diff -u -p -r1.108 dcrt0.cc --- dcrt0.cc 2001/09/11 08:15:39 1.108 +++ dcrt0.cc 2001/09/12 15:41:41 @@ -35,6 +35,7 @@ details. */ #include "cygwin_version.h" #include "dll_init.h" #include "host_dependent.h" +#include "cygwin/cygserver.h" #define MAX_AT_FILE_LEVEL 10 @@ -155,94 +156,8 @@ do_global_ctors (void (**in_pfunc)(), in atexit (do_global_dtors); } -/* remember the type of Win32 OS being run for future use. */ -os_type NO_COPY os_being_run; -char NO_COPY osname[40]; -bool iswinnt; - -/* set_os_type: Set global variable os_being_run with type of Win32 - operating system being run. This information is used internally - to manage the inconsistency in Win32 API calls between Win32 OSes. */ -/* Cygwin internal */ -static void -set_os_type () -{ - OSVERSIONINFO os_version_info; - const char *os; - - memset (&os_version_info, 0, sizeof os_version_info); - os_version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - GetVersionEx (&os_version_info); - - iswinnt = 0; - switch (os_version_info.dwPlatformId) - { - case VER_PLATFORM_WIN32_NT: - os_being_run = winNT; - os = "NT"; - iswinnt = 1; - break; - case VER_PLATFORM_WIN32_WINDOWS: - if (os_version_info.dwMinorVersion == 0) - { - os_being_run = win95; - os = "95"; - } - else if (os_version_info.dwMinorVersion < 90) - { - os_being_run = win98; - os = "98"; - } - else /* os_version_info.dwMinorVersion == 90 */ - { - os_being_run = winME; - os = "ME"; - } - break; - default: - os_being_run = unknown; - os = "??"; - break; - } - __small_sprintf (osname, "%s-%d.%d", os, os_version_info.dwMajorVersion, - os_version_info.dwMinorVersion); -} - host_dependent_constants NO_COPY host_dependent; -/* Constructor for host_dependent_constants. */ - -void -host_dependent_constants::init () -{ - extern DWORD chunksize; - /* fhandler_disk_file::lock needs a platform specific upper word - value for locking entire files. - - fhandler_base::open requires host dependent file sharing - attributes. */ - - switch (os_being_run) - { - case winNT: - win32_upper = 0xffffffff; - shared = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - break; - - case winME: - case win98: - case win95: - case win32s: - win32_upper = 0x00000000; - shared = FILE_SHARE_READ | FILE_SHARE_WRITE; - chunksize = 32 * 1024 * 1024; - break; - - default: - api_fatal ("unrecognized system type"); - } -} - /* * Replaces -@file in the command line with the contents of the file. * There may be multiple -@file's in a single command line @@ -777,6 +692,8 @@ dll_crt0_1 () /* Initialize signal/subprocess handling. */ sigproc_init (); + + cygserver_init (); /* Connect to tty. */ tty_init (); Index: fhandler.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler.h,v retrieving revision 1.76 diff -u -p -r1.76 fhandler.h --- fhandler.h 2001/09/11 20:01:00 1.76 +++ fhandler.h 2001/09/12 15:41:43 @@ -832,6 +832,8 @@ public: off_t lseek (off_t, int) { return 0; } select_record *select_read (select_record *s); int ready_for_read (int fd, DWORD howlong, int ignra); + + int cygserver_attach_tty (HANDLE*, HANDLE*); }; class fhandler_pty_master: public fhandler_tty_common Index: fhandler_socket.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_socket.cc,v retrieving revision 1.21 diff -u -p -r1.21 fhandler_socket.cc --- fhandler_socket.cc 2001/09/07 21:32:04 1.21 +++ fhandler_socket.cc 2001/09/12 15:41:44 @@ -148,7 +148,7 @@ fhandler_socket::check_peer_secret_event if (ev) { DWORD rc = WaitForSingleObject (ev, 10000); - debug_printf ("WFSO rc=%d", rc); + debug_printf ("WFSO rc=%d;", rc); CloseHandle (ev); return (rc == WAIT_OBJECT_0 ? 1 : 0 ); } Index: fhandler_tty.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_tty.cc,v retrieving revision 1.47 diff -u -p -r1.47 fhandler_tty.cc --- fhandler_tty.cc 2001/09/07 21:32:04 1.47 +++ fhandler_tty.cc 2001/09/12 15:41:46 @@ -25,6 +25,7 @@ details. */ #include "pinfo.h" #include "cygheap.h" #include "shared_info.h" +#include "cygwin/cygserver.h" /* Tty master stuff */ @@ -523,42 +524,74 @@ fhandler_tty_slave::open (const char *, return 0; } - HANDLE tty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, - get_ttyp ()->master_pid); - if (tty_owner == NULL) - { - termios_printf ("can't open tty (%d) handle process %d", - ttynum, get_ttyp ()->master_pid); - __seterrno (); - return 0; - } + HANDLE from_master_local, to_master_local; - HANDLE nh; - if (!DuplicateHandle (tty_owner, get_ttyp ()->from_master, hMainProc, &nh, 0, TRUE, - DUPLICATE_SAME_ACCESS)) + if (!cygserver_running || !cygserver_attach_tty ( &from_master_local, &to_master_local)) { - termios_printf ("can't duplicate input, %E"); - __seterrno (); - return 0; - } - set_io_handle (nh); - ProtectHandle1 (nh, from_pty); - termios_printf ("duplicated from_master %p->%p from tty_owner %p", - get_ttyp ()->from_master, nh, tty_owner); - if (!DuplicateHandle (tty_owner, get_ttyp ()->to_master, hMainProc, &nh, 0, TRUE, - DUPLICATE_SAME_ACCESS)) - { - termios_printf ("can't duplicate output, %E"); - __seterrno (); - return 0; - } - set_output_handle (nh); - ProtectHandle1 (nh, to_pty); - CloseHandle (tty_owner); + termios_printf ("cannot dup handles via server. using old method."); + HANDLE tty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, + get_ttyp ()->master_pid); + if (tty_owner == NULL) + { + termios_printf ("can't open tty (%d) handle process %d", + ttynum, get_ttyp ()->master_pid); + __seterrno (); + return 0; + } + + if (!DuplicateHandle (tty_owner, get_ttyp ()->from_master, + hMainProc, &from_master_local, 0, TRUE, + DUPLICATE_SAME_ACCESS)) + { + termios_printf ("can't duplicate input, %E"); + __seterrno (); + return 0; + } + termios_printf ("duplicated from_master %p->%p from tty_owner %p", + get_ttyp ()->from_master, from_master_local, tty_owner); + + if (!DuplicateHandle (tty_owner, get_ttyp ()->to_master, + hMainProc, &to_master_local, 0, TRUE, + DUPLICATE_SAME_ACCESS)) + { + termios_printf ("can't duplicate output, %E"); + __seterrno (); + return 0; + } + termios_printf ("duplicated to_master %p->%p from tty_owner %p", + get_ttyp ()->to_master, to_master_local, tty_owner); + CloseHandle (tty_owner); + } + + set_io_handle (from_master_local); + ProtectHandle1 (from_master_local, from_pty); + set_output_handle (to_master_local); + ProtectHandle1 (to_master_local, to_pty); + set_open_status (); termios_printf ("tty%d opened", ttynum); + return 1; +} + +int +fhandler_tty_slave::cygserver_attach_tty (HANDLE* from_master_ptr, + HANDLE* to_master_ptr) +{ + if (!from_master_ptr || !to_master_ptr) + return 0; + + struct request_attach_tty req; + INIT_REQUEST (req, CYGSERVER_REQUEST_ATTACH_TTY); + req.pid = GetCurrentProcessId (); + req.master_pid = get_ttyp ()->master_pid; + req.from_master = get_ttyp ()->from_master; + req.to_master = get_ttyp ()->to_master; + if (cygserver_request ((struct request_header*) &req) != 0) + return 0; + *from_master_ptr = req.from_master; + *to_master_ptr = req.to_master; return 1; } Index: fork.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fork.cc,v retrieving revision 1.62 diff -u -p -r1.62 fork.cc --- fork.cc 2001/09/11 08:15:39 1.62 +++ fork.cc 2001/09/12 15:41:48 @@ -35,7 +35,7 @@ static int npid_max; static pid_t fork_pids[100]; #endif -DWORD NO_COPY chunksize = 0; +extern DWORD chunksize; /* Timeout to wait for child to start, parent to init child, etc. */ /* FIXME: Once things stabilize, bump up to a few minutes. */ #define FORK_WAIT_TIMEOUT (300 * 1000) /* 300 seconds */ Index: host_dependent.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/host_dependent.h,v retrieving revision 1.2 diff -u -p -r1.2 host_dependent.h --- host_dependent.h 2001/06/24 22:26:51 1.2 +++ host_dependent.h 2001/09/12 15:41:48 @@ -28,3 +28,4 @@ class host_dependent_constants }; extern host_dependent_constants host_dependent; +extern void set_os_type(); Index: tty.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/tty.cc,v retrieving revision 1.28 diff -u -p -r1.28 tty.cc --- tty.cc 2001/09/06 04:41:59 1.28 +++ tty.cc 2001/09/12 15:41:49 @@ -23,6 +23,7 @@ details. */ #include "sync.h" #include "sigproc.h" #include "pinfo.h" +#include "cygwin/cygserver.h" #include "shared_info.h" extern fhandler_tty_master *tty_master; @@ -393,6 +394,7 @@ tty::common_init (fhandler_pty_master *p /* Allow the others to open us (for handle duplication) */ if ((iswinnt) && + !cygserver_running && (SetKernelObjectSecurity (hMainProc, DACL_SECURITY_INFORMATION, get_null_sd ()) == FALSE)) small_printf ("Can't set process security, %E"); Index: winsup.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v retrieving revision 1.68 diff -u -p -r1.68 winsup.h --- winsup.h 2001/09/09 16:52:37 1.68 +++ winsup.h 2001/09/12 15:41:50 @@ -72,6 +72,8 @@ extern bool iswinnt; enum codepage_type {ansi_cp, oem_cp}; extern codepage_type current_codepage; +extern int cygserver_running; + /* Used to check if Cygwin DLL is dynamically loaded. */ extern int dynamically_loaded; --=-eReoAr509nKoCXpP9F4G--