Focus on Linux
How to check UID of process on the other side of local TCP/UDP connection Nov 24 2006 06:11PM
rainmailbox2001-ola yahoo ca (6 replies)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 28 2006 02:31AM
Greg Metcalfe (metcalfegreg qwest net)
RE: How to check UID of process on the other side of local TCP/UDP connection Nov 27 2006 08:48PM
Bond Masuda (bond masuda jlbond com)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 27 2006 08:06PM
Luciano Miguel Ferreira Rocha (strange nsk no-ip org) (1 replies)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 28 2006 05:17PM
Filipe Varela (fcv dev6 com) (3 replies)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 29 2006 08:57PM
Luciano Miguel Ferreira Rocha (strange nsk no-ip org) (1 replies)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 30 2006 06:02PM
Filipe Varela (fcv dev6 com) (2 replies)
Re: How to check UID of process on the other side of local TCP/UDP connection Dec 01 2006 11:31PM
Glynn Clements (glynn gclements plus com)
Re: How to check UID of process on the other side of local TCP/UDP connection Dec 01 2006 09:38PM
Luciano Miguel Ferreira Rocha (strange nsk no-ip org)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 29 2006 08:13PM
Glynn Clements (glynn gclements plus com)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 29 2006 07:24PM
Vladimir Mitiouchev (vovcia gmail com)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 27 2006 08:06PM
Vladimir Mitiouchev (vovcia gmail com) (2 replies)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 29 2006 06:29AM
Greg Metcalfe (metcalfegreg qwest net)
Re: How to check UID of process on the other side of local TCP/UDP connection Nov 28 2006 05:05PM
Michael Bacarella (mbac netgraft com)
/*
* On Mon, Nov 27, 2006 at 09:06:30PM +0100, Vladimir Mitiouchev wrote:
* > On 11/24/06, rainmailbox2001-ola (at) yahoo (dot) ca [email concealed] <rainmailbox2001-ola (at) yahoo (dot) ca [email concealed]>
* > wrote:
* > >Do you have any ideas how this local
* > >authentication can be achieved in some
* > >different way?
* > identd
* > fstat (BSD)
* > lsof(Linux)
* >
* > >Unix sockets (unless of course Unix sockets are
* > >the only good way to
* > >resolve my problems).
* > SCM_CREDS (BSD)
* > SO_PEERCRED (Linux)
*
* Use getpeereuid()
*
* Here's an implementation if your system doesn't provide it libc.
*/

#include <sys/socket.h>

uid_t getpeereuid(int sd)
{
struct ucred cred;
int len = sizeof (cred);

if (getsockopt(sd,SOL_SOCKET,SO_PEERCRED,&cred,&len))
return -1;

return cred.uid;
}

/*
*
* --
* Michael Bacarella <mbac (at) netgraft (dot) com [email concealed]>
*
* 1-646-641-8662 (cell)
*
* 545 Eighth Avenue * Suite 401
* New York, NY 10018
*
* http://michael.bacarella.com/
* http://netgraft.com/
*
*/

[ reply ]


 

Privacy Statement
Copyright 2010, SecurityFocus