From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6774 invoked by alias); 4 Jun 2002 06:17:53 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 6767 invoked from network); 4 Jun 2002 06:17:52 -0000 Received: from unknown (HELO ns.logos-m.ru) (195.7.187.66) by sources.redhat.com with SMTP; 4 Jun 2002 06:17:52 -0000 Received: from gibe.logos-m.ru (gibe.logos-m.ru [195.7.187.101]) by ns.logos-m.ru (8.12.1/8.12.1) with ESMTP id g546b6DH065865; Tue, 4 Jun 2002 10:37:11 +0400 (MSD) Date: Mon, 03 Jun 2002 23:17:00 -0000 From: egor duda Reply-To: egor duda Organization: deo X-Priority: 3 (Normal) Message-ID: <291438343308.20020604101630@logos-m.ru> To: David E Euresti CC: cygwin@cygwin.com Subject: Re: Duplicating Unix Domain Sockets In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-06/txt/msg00128.txt.bz2 Hi! Tuesday, 04 June, 2002 David E Euresti davie@MIT.EDU wrote: DEE> Allright. So I have two solutions. DEE> (And tell me if I should direct this to the folks at cygwin-devel) I believe most, if not all subscribers of cygwin-developers@ are reading cygwin@ mailing list. DEE> #1 DEE> Make cygwin be able to implement the Ancillary data as in 4.3+BSD as DEE> described in section 15.3.3 in Advanced Programming in the Unix DEE> Environment. DEE> To implement this, I would tag all messages sent on Unix domain sockets DEE> with a tag like this: DEE> struct tag { DEE> int adatalen; // Length of ancillary data DEE> int rdatalen; // Length of real data DEE> } DEE> Then when you receive it your first read the tag and if there is ancillary DEE> data read it and do what you need to do (convert the info into an fd) and DEE> then read the rdatalen. If there is more rdatalen than the length of DEE> buffer sent to you, you return what you can, and remember how much is DEE> left. DEE> This is obviously a big task, and opinions would be quite welcome. DEE> #2 DEE> Just add a function that says, create_fd_from_handle_plus were I can DEE> pass in all the parameters that the sending process could send, and so DEE> that the same file descriptor gets created. The problem with this is that DEE> getting the info from one process to another (IPC?) is up to the DEE> programmer. It's not enough to just pass numerical value of descriptor between processes. Each cygwin fd has several win32 handles associated with it, which are used to actually do the job, to read or write the data, to perform synchronization, etc. If you want to pass fd1 from proc1 to proc2, you have to duplicate all win32 handles associated with fd1 into address space of proc2. This can be done by DuplicateHandle () function, but if you take a look on its docs on msdn, you'll see that it requires process handles of proc1 and proc2 to work. Given that proc1 and proc2 can be absolutely unrelated and run from different accounts, there's no secure way to obtain those process handles without help from some mediator process which run at high enough level of privileges. That's what cygwin daemon is for -- to provide a services that require high privileges to normal non-privileged processes. After such handle duplication service (with appropriate security checks) is implemented in cygwin daemon, it would be simple to augment AF_UNIX sockets protocol to be able to pass auxiliary information such as fds. Egor. mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/