Index: [Article Count Order] [Thread]

Date: Thu, 29 Sep 2005 01:11:42 +0900
From: GOTO Kentaro <gotoken@notwork.org>
Subject: [webricken:153] Re: getting the uid of the incoming browser?
To: webricken@notwork.org
Message-Id: <433AC0BE.8020304@notwork.org>
In-Reply-To: <D3F40990-7B0E-48A0-83F6-97A97594525D@3skel.com>
References: <p06230914bf6051a9c781@[192.168.254.205]> <D3F40990-7B0E-48A0-83F6-97A97594525D@3skel.com>
X-Mail-Count: 00153

Hi Rich,

Maybe lsof helps:

  ruby -e '
    require "webrick"
    h = WEBrick::HTTPServer.new(:Port => 8765)
    h.mount_proc("/"){|q,s|
      s.body = `sudo lsof -i -P`.grep(/:#{q.peeraddr[1]}->/).join("\n")
    }
    trap("INT"){h.shutdown}
    h.start
  '

As Dan said, that is not socket nature however.


Gotoken


On 2005/09/28 23:43 Dan Janowski wrote:
> I do not believe what you are looking for is available. I faintly 
> recall that user information is available in SYSV streams, but not  over
> TCP/IP sockets.
> 
> In any event, something like this coming over the network cannot be 
> trusted as it can be forged. That is why authentication exists.
> 
> Dan
> 
> On Sep 28, 2005, at 10:10, Rich Morin wrote:
> 
>> I'd like to tweak WEBrick so that it will only respond to the user
>> that started it (i.e., the user whose uid matches WEBrick's).  We
>> can assume, for simplicity's sake, that the user is running a web
>> browser on the same (Unixish) machine as WEBrick.
>>
>> I _suspect_ that WEBrick can get the needed information by looking
>> at the incoming socket (e.g., for a pid), than researching which
>> uid that pid has.  Unfortunately, I know little about the innards
>> of sockets and even less about the innards of WEBrick.
>>
>> Comments, clues, and suggestions are all welcome.
>>
>> -r
>> -- 
>> email: rdm@cfcl.com; phone: +1 650-873-7841
>> http://www.cfcl.com        - Canta Forda Computer Laboratory
>> http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.
>>
>>
> 
>