source: filezilla/trunk/fuentes/src/putty/unix/uxpeer.c @ 130

Last change on this file since 130 was 130, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 596 bytes
Line 
1/*
2 * Unix: wrapper for getsockopt(SO_PEERCRED), conditionalised on
3 * appropriate autoconfery.
4 */
5
6#ifdef HAVE_CONFIG_H
7#include "config.h"
8#endif
9
10#ifdef HAVE_SO_PEERCRED
11#define _GNU_SOURCE
12#include <features.h>
13#endif
14
15#include <sys/socket.h>
16
17#include "putty.h"
18
19int so_peercred(int fd, int *pid, int *uid, int *gid)
20{
21#ifdef HAVE_SO_PEERCRED
22    struct ucred cr;
23    socklen_t crlen = sizeof(cr);
24    if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crlen) == 0) {
25        *pid = cr.pid;
26        *uid = cr.uid;
27        *gid = cr.gid;
28        return TRUE;
29    }
30#endif
31    return FALSE;
32}
Note: See TracBrowser for help on using the repository browser.