Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/compat
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2008-01-30 22:13:57 +0100
committerArthur de Jong <arthur@arthurdejong.org>2008-01-30 22:13:57 +0100
commitd6a369d9b0f9b189a64e68d6808ed8e642ae26c2 (patch)
treef59971b765731e0d741c1b24894d0b9da8c53695 /compat
parent04c3a59ee074da655c0afafcccd52b1eab7b2de0 (diff)
some fixes for LOCAL_PEERCRED (still untested)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@577 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'compat')
-rw-r--r--compat/getpeercred.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/compat/getpeercred.c b/compat/getpeercred.c
index e36c907..0de6f75 100644
--- a/compat/getpeercred.c
+++ b/compat/getpeercred.c
@@ -61,13 +61,9 @@ int getpeercred(int sock,uid_t *uid,gid_t *gid,pid_t *pid)
#elif defined(LOCAL_PEERCRED)
socklen_t l;
struct xucred cred;
- /* initialize client information (in case getsockopt() breaks) */
- cred.pid=(pid_t)0;
- cred.uid=(uid_t)-1;
- cred.gid=(gid_t)-1;
/* look up process information from peer */
l=(socklen_t)sizeof(struct xucred);
- if (getsockopt(sock,SOL_SOCKET,LOCAL_PEERCRED,&cred,&l) < 0)
+ if (getsockopt(sock,0,LOCAL_PEERCRED,&cred,&l) < 0)
return -1; /* errno already set */
if (cred.cr_version!=XUCRED_VERSION)
{
@@ -77,7 +73,7 @@ int getpeercred(int sock,uid_t *uid,gid_t *gid,pid_t *pid)
/* return the data */
if (uid!=NULL) *uid=cred.uid;
if (gid!=NULL) *gid=cred.gid;
- if (pid!=NULL) *pid=cred.pid;
+ if (pid!=NULL) *pid=(pid_t)-1;
return 0;
#elif defined(HAVE_GETPEERUCRED)
ucred_t *cred=NULL;