]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Fix getpeereid() compilation on Solaris
authorCasper Dik <casper.dik@oracle.com>
Fri, 15 Mar 2013 00:13:58 +0000 (01:13 +0100)
committerGuillem Jover <guillem@hadrons.org>
Mon, 27 May 2013 02:05:17 +0000 (04:05 +0200)
The code in getpeereid() is unlikely to compile as ucred_t is an opaque
struct (ucred_t * works but ucred_t does not). Either you need to give
a pointer initialized to NULL and getpeerucred() allocates a new ucred
or you call it with an allocated ucred as in this patch.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
src/getpeereid.c

index 36942193afe3737b9bbf0131be45e78b0db10184..193f366d60b2d4d12e36e2b14ec92f54d62a63eb 100644 (file)
@@ -99,11 +99,13 @@ getpeereid(int s, uid_t *euid, gid_t *egid)
 }
 #elif defined(__sun)
 /* Solaris */
+#include <alloca.h>
+#include <ucred.h>
+
 int
 getpeereid(int s, uid_t *euid, gid_t *egid)
 {
-       ucred_t cred_inst;
-       ucred_t *cred = &cred_inst;
+       ucred_t *cred = alloca(ucred_size());
        int ret;
 
        ret = getpeerucred(s, &cred);