Does anyone use nscd?

Artem Belevich art at
Tue Oct 4 17:16:34 UTC 2011

2011/10/4 Dag-Erling Smørgrav <des at>:
> Trond Endrestøl <Trond.Endrestol at> writes:
>> It's in daily use at Gjøvik Technical College (Fagskolen i Gjøvik),
>> here in Norway. Both the mail and web servers authenticates our users
>> by LDAP, and nscd certainly speeds up the lookups.
> OK.  No trouble with clients dying of SIGPIPE?  I could never reproduce
> the bug, but both users who reported problems used ldap, and I don't
> have an LDAP server to test against, so I thought it might be specific
> to LDAP.

I do use nscd at work where we have fairly large NIS database.

And I do have a way to reproduce the SIGPIPE problem. Populate ~30K
entries in NIS passwd database, enable nscd and then run top. In my
case top used to die with SIGPIPE pretty reliably. I've fixed the
issue locally by setting SO_NOSIGPIPE on the socket in
__open_cached_connection() in lib/libc/net/nscachedcli.c and I've been
running with the fix for few months now.


diff --git a/lib/libc/net/nscachedcli.c b/lib/libc/net/nscachedcli.c
index 1323805..cd941db 100644
--- a/lib/libc/net/nscachedcli.c
+++ b/lib/libc/net/nscachedcli.c
@@ -196,6 +196,7 @@ __open_cached_connection(struct
cached_connection_params const *params)
        struct sockaddr_un client_address;
        int client_address_len, client_socket;
        int res;
+       int on = 1;

        assert(params != NULL);

@@ -214,6 +215,8 @@ __open_cached_connection(struct
cached_connection_params const *params)
        _fcntl(client_socket, F_SETFL, O_NONBLOCK);

+       _setsockopt(client_socket, SOL_SOCKET, SO_NOSIGPIPE, (void
*)&on, sizeof(on));
        retval = malloc(sizeof(struct cached_connection_));
        assert(retval != NULL);
        memset(retval, 0, sizeof(struct cached_connection_));

More information about the freebsd-hackers mailing list