]> git.sur5r.net Git - openldap/commitdiff
Support SO_PEERCRED SASL EXTERNAL authorization.
authorLuke Howard <lukeh@openldap.org>
Wed, 4 Dec 2002 04:14:44 +0000 (04:14 +0000)
committerLuke Howard <lukeh@openldap.org>
Wed, 4 Dec 2002 04:14:44 +0000 (04:14 +0000)
servers/slapd/daemon.c

index 6d1ca980bb9a8ba2fad669001097da525d4219eb..ab931923500e932759339554728b08710912f7f1 100644 (file)
@@ -1555,6 +1555,19 @@ slapd_daemon_task(
                        case AF_LOCAL:
                                sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path );
                                ssf = LDAP_PVT_SASL_LOCAL_SSF;
+#   ifdef SO_PEERCRED
+                               {
+                                       struct ucred peercred;
+                                       size_t peercred_len = sizeof(peercred);
+
+                                       if (getsockopt( s, SOL_SOCKET, SO_PEERCRED,
+                                           (void *)&peercred, &peercred_len ) == 0 &&
+                                           peercred_len == sizeof(peercred) ) {
+                                               authid = ch_malloc(sizeof("uidNumber=+gidNumber=+,cn=peercred,cn=external,cn=auth") + 32);
+                                               sprintf(authid, "uidNumber=%d+gidNumber=%d,cn=peercred,cn=external,cn=auth", peercred.uid, peercred.gid);
+                                       }
+                               }
+#   endif /* SO_PEERCRED */
                                dnsname = "local";
                                break;
 #endif /* LDAP_PF_LOCAL */