From d6a369d9b0f9b189a64e68d6808ed8e642ae26c2 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Wed, 30 Jan 2008 21:13:57 +0000 Subject: 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 --- compat/getpeercred.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'compat') 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; -- cgit v1.2.3