diff options
author | Darren Tucker <dtucker@zip.com.au> | 2007-03-21 11:39:57 +0100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2007-03-21 11:39:57 +0100 |
commit | 164aa30e4604672f688b5c51b90e42dfa129821b (patch) | |
tree | 4ce05465abbf23eb557d9f9ef4841a6be23c2365 /openbsd-compat/bsd-getpeereid.c | |
parent | - jmc@cvs.openbsd.org 2007/03/20 15:57:15 (diff) | |
download | openssh-164aa30e4604672f688b5c51b90e42dfa129821b.tar.xz openssh-164aa30e4604672f688b5c51b90e42dfa129821b.zip |
- (dtucker) [configure.ac openbsd-compat/bsd-getpeereid.c] Bug #1287: Use
getpeerucred to implement getpeereid (currently only Solaris 10 and up).
Patch by Jan.Pechanec at Sun.
Diffstat (limited to '')
-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) return (0); } +#elif defined(HAVE_GETPEERUCRED) + +#ifdef HAVE_UCRED_H +# include <ucred.h> +#endif + +int +getpeereid(int s, uid_t *euid, gid_t *gid) +{ + ucred_t *ucred = NULL; + + if (getpeerucred(s, &ucred) == -1) + return (-1); + if ((*euid = ucred_geteuid(ucred)) == -1) + return (-1); + if ((*gid = ucred_getrgid(ucred)) == -1) + return (-1); + + ucred_free(ucred); + + return (0); +} #else int getpeereid(int s, uid_t *euid, gid_t *gid) |