Index: [Article Count Order] [Thread]

Date: Wed, 28 Sep 2005 09:44:06 -0700
From: Rich Morin <rdm@cfcl.com>
Subject: [webricken:154] Re: getting the uid of the incoming browser?
To: webricken@notwork.org
Message-Id: <p0623091cbf607814c88b@[192.168.254.205]>
In-Reply-To: <p06230914bf6051a9c781@[192.168.254.205]>
References: <p06230914bf6051a9c781@[192.168.254.205]>
X-Mail-Count: 00154

"man 4 unix" says:

      The effective credentials (i.e., the user ID and group list) of a
      peer on a SOCK_STREAM socket may be obtained using the LOCAL_PEERCRED
      socket option.  This may be used by a server to obtain and verify the
      credentials of its client, and vice versa by the client to verify the
      credentials of the server.  These will arrive in the form of a filled in
      struct xucred (defined in sys/ucred.h).  The credentials presented to the
      server (the listen(2) caller) are those of the client when it called
      connect(2); the credentials presented to the client (the connect(2)
      caller) are those of the server when it called listen(2).  This mechanism
      is reliable; there is no way for either party to influence the creden-
      tials presented to its peer except by calling the appropriate system call
      (e.g., connect(2) or listen(2)) under different effective credentials.

So, it looks like I can augment the WEBrick socket code slightly and get
the effect I want.  Can anyone point me to the right file(s) or offer
other useful hints?

-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.