diff options
Diffstat (limited to 'openbsd-compat/bsd-getpeereid.c')
-rw-r--r-- | openbsd-compat/bsd-getpeereid.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-getpeereid.c b/openbsd-compat/bsd-getpeereid.c index bdae8b637..5f7e677e5 100644 --- a/openbsd-compat/bsd-getpeereid.c +++ b/openbsd-compat/bsd-getpeereid.c | |||
@@ -37,6 +37,28 @@ getpeereid(int s, uid_t *euid, gid_t *gid) | |||
37 | 37 | ||
38 | return (0); | 38 | return (0); |
39 | } | 39 | } |
40 | #elif defined(HAVE_GETPEERUCRED) | ||
41 | |||
42 | #ifdef HAVE_UCRED_H | ||
43 | # include <ucred.h> | ||
44 | #endif | ||
45 | |||
46 | int | ||
47 | getpeereid(int s, uid_t *euid, gid_t *gid) | ||
48 | { | ||
49 | ucred_t *ucred = NULL; | ||
50 | |||
51 | if (getpeerucred(s, &ucred) == -1) | ||
52 | return (-1); | ||
53 | if ((*euid = ucred_geteuid(ucred)) == -1) | ||
54 | return (-1); | ||
55 | if ((*gid = ucred_getrgid(ucred)) == -1) | ||
56 | return (-1); | ||
57 | |||
58 | ucred_free(ucred); | ||
59 | |||
60 | return (0); | ||
61 | } | ||
40 | #else | 62 | #else |
41 | int | 63 | int |
42 | getpeereid(int s, uid_t *euid, gid_t *gid) | 64 | getpeereid(int s, uid_t *euid, gid_t *gid) |