4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <netinet/tcp.h>
34 #include <rpcsvc/nis.h>
36 #include "ldap_util.h"
38 #include "nis_parse_ldap_conf.h"
41 * Interpose socket(3SOCKET), so that we can set the connect timeout.
42 * Obviously, this will affect every socket in the application. However,
43 * NIS+ (or, rather, RPC) uses TLI, not sockets, so the only sockets
44 * should be those used by libldap.
47 socket(int domain
, int type
, int protocol
) {
49 static int (*fptr
)() = 0;
50 int timeout
= 1000 * proxyInfo
.bind_timeout
.tv_sec
+
51 proxyInfo
.bind_timeout
.tv_usec
/ 1000;
54 fptr
= (int (*)())dlsym(RTLD_NEXT
, "socket");
56 logmsg(MSG_NOTIMECHECK
, LOG_ERR
,
57 "socket: load error: %s",
63 ret
= (*fptr
) (domain
, type
, protocol
);
65 if (ret
>= 0 && timeout
> 0) {
66 if (setsockopt(ret
, IPPROTO_TCP
, TCP_CONN_ABORT_THRESHOLD
,
67 &timeout
, sizeof (timeout
)) != 0)
68 logmsg(MSG_NOTIMECHECK
, LOG_ERR
,
69 "setsockopt(IPPROTO_TCP/TCP_CONN_ABORT_THRESHOLD, %d) => errno = %d",