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 1999-2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Turning DEBUG on for this library opens a potential security hole. If
31 * the library is compiled with DEBUG, it should only be done for internal
38 #include <sys/types.h>
49 int __ldap_debug_file
= 2;
51 int __ldap_debug_ldap
;
52 int __ldap_debug_servers
;
60 static struct option options
[] = {
61 { "debug_file", OPT_FILE
, &__ldap_debug_file
},
62 { "debug_api", OPT_INT
, &__ldap_debug_api
},
63 { "debug_ldap", OPT_INT
, &__ldap_debug_servers
},
68 extern int __ns_ldap_raise_fd(int);
72 set_option(char *name
, char *val
)
79 for (opt
= options
; opt
->name
; opt
++) {
80 if (strcasecmp(name
, opt
->name
) == 0) {
84 *((char **)opt
->address
) = p
;
87 if (val
&& *val
== '\0')
91 *((int *)opt
->address
) = n
;
94 /* this is a potential security risk */
95 /* as setuid programs will create files */
96 /* owned by root. This is only to be */
97 /* used for internal debugging. */
98 fd
= open(val
, O_WRONLY
| O_CREAT
, 0644);
100 fd
= __ns_ldap_raise_fd(fd
);
102 *((int *)opt
->address
) = fd
;
120 p
= getenv("LDAP_OPTIONS");
130 while (*p
&& *p
!= '=' && !isspace(*p
))
132 (void) strncpy(optname
, base
, p
- base
);
133 optname
[p
- base
] = '\0';
137 while (*p
&& !isspace(*p
))
139 (void) strncpy(optval
, base
, p
- base
);
140 optval
[p
- base
] = '\0';
144 set_option(optname
, optval
);
147 (void) fprintf(stderr
, "debug_api: %d\n", __ldap_debug_api
);
148 (void) fprintf(stderr
, "debug_ldap: %d\n", __ldap_debug_ldap
);
149 (void) fprintf(stderr
, "debug_servers: %d\n", __ldap_debug_servers
);
155 __s_api_debug_pause(int priority
, int st
, const char *mesg
)
158 syslog(priority
, "libsldap: Status: %d Mesg: %s", st
, mesg
);