ReactOS 0.4.15-dev-8339-g4028de8
getpeereid.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2001 Dima Dorfman.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27//#include <sys/cdefs.h>
28#include <wintirpc.h>
29#include <rpc/types.h>
30//#include <sys/param.h>
31//#include <sys/socket.h>
32//#include <sys/un.h>
33
34#include <errno.h>
35//#include <unistd.h>
36
37#ifdef _WIN32
38int
39getpeereid(SOCKET s, uid_t *euid, gid_t *egid)
40{
41 // XXX Need to figure out what to do here for Windows!
42 return -1;
43}
44#else
45int
46getpeereid(int s, uid_t *euid, gid_t *egid)
47{
48 struct ucred uc;
49 socklen_t uclen;
50 int error;
51
52 uclen = sizeof(uc);
53 error = getsockopt(s, SOL_SOCKET, SO_PEERCRED, &uc, &uclen); /* SCM_CREDENTIALS */
54 if (error != 0)
55 return (error);
56 // if (uc.cr_version != XUCRED_VERSION)
57 // return (EINVAL);
58 *euid = uc.uid;
59 *egid = uc.gid;
60 return (0);
61 }
62#endif
long uid_t
Definition: various.h:8
UINT gid_t
Definition: types.h:89
int getpeereid(int s, uid_t *euid, gid_t *egid)
Definition: getpeereid.c:46
GLdouble s
Definition: gl.h:2039
#define error(str)
Definition: mkdosfs.c:1605
int socklen_t
Definition: tcp.c:35
INT WSAAPI getsockopt(IN SOCKET s, IN INT level, IN INT optname, OUT CHAR FAR *optval, IN OUT INT FAR *optlen)
Definition: sockctrl.c:271
UINT_PTR SOCKET
Definition: winsock.h:47
#define SOL_SOCKET
Definition: winsock.h:398