/*
* 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/
*
*/
* 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 ]