delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/04/02:18:17

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 4 Jun 2002 10:16:30 +0400
From: egor duda <deo AT logos-m DOT ru>
Reply-To: egor duda <cygwin AT cygwin DOT com>
Organization: deo
X-Priority: 3 (Normal)
Message-ID: <291438343308.20020604101630@logos-m.ru>
To: David E Euresti <davie AT MIT DOT EDU>
CC: cygwin AT cygwin DOT com
Subject: Re: Duplicating Unix Domain Sockets
In-Reply-To: <Pine.GSO.4.30L.0206031633540.3061-100000@department-of-alchemy.mit.edu>
References:
<Pine DOT GSO DOT 4 DOT 30L DOT 0206031633540 DOT 3061-100000 AT department-of-alchemy DOT mit DOT edu>
MIME-Version: 1.0

Hi!

Tuesday, 04 June, 2002 David E Euresti davie AT MIT DOT 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 AT logos-m DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019