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 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * Portions of this source code were derived from Berkeley 4.3 BSD
32 * under license from the Regents of the University of California.
35 #pragma ident "%Z%%M% %I% %E% SMI"
38 static char sccsid
[] = "@(#)ypserv_ancil.c 1.13 88/02/08 Copyr 1984 Sun Micro";
47 #include "shim_hooks.h"
51 extern unsigned int strlen();
53 extern int isvar_sysv();
54 extern char *strncpy();
55 extern int yp_getkey();
58 * This generates a list of the maps in a domain.
61 yplist_maps(domain
, list
)
63 struct ypmaplist
**list
;
67 char domdir
[MAXNAMLEN
+ 1];
68 char path
[MAXNAMLEN
+ 1];
69 char map_key
[YPMAXMAP
+ 1];
72 struct ypmaplist
*map
;
76 *list
= (struct ypmaplist
*)NULL
;
78 if (!ypcheck_domain(domain
)) {
82 (void) strcpy(domdir
, ypdbpath
);
83 (void) strcat(domdir
, "/");
84 (void) strcat(domdir
, domain
);
86 if ((dirp
= opendir(domdir
)) == NULL
) {
92 for (dp
= readdir(dirp
); error
== YP_TRUE
&& dp
!= NULL
;
95 * If it's possible that the file name is one of the two files
96 * implementing a map, remove the extension (dbm_pag or dbm_dir)
98 namesz
= (int)strlen(dp
->d_name
);
100 if (namesz
< sizeof (dbm_pag
) - 1)
101 continue; /* Too Short */
103 ext
= &(dp
->d_name
[namesz
- (sizeof (dbm_pag
) - 1)]);
105 if (strcmp(ext
, dbm_pag
) != 0)
106 continue; /* No dbm file extension */
112 * In yptol mode look at LDAP_ prefixed maps. In non yptol mode
116 if (0 != strncmp(dp
->d_name
, NTOL_PREFIX
,
117 strlen(NTOL_PREFIX
)))
121 * Already have an LDAP_ prefix. Don't want to add it
124 mapname
= dp
->d_name
+ strlen(NTOL_PREFIX
);
126 if (0 == strncmp(dp
->d_name
, NTOL_PREFIX
,
127 strlen(NTOL_PREFIX
)))
129 mapname
= dp
->d_name
;
132 ypmkfilename(domain
, mapname
, path
);
135 * At this point, path holds the map file base name (no dbm
136 * file extension), and mapname holds the map name.
138 if (ypcheck_map_existence(path
) &&
139 !onmaplist(mapname
, *list
)) {
141 if ((map
= (struct ypmaplist
*)malloc(
142 sizeof (struct ypmaplist
))) == NULL
) {
147 map
->ypml_next
= *list
;
149 namesz
= (int)strlen(mapname
);
151 if (namesz
<= YPMAXMAP
) {
152 if (yp_getkey(mapname
, map_key
,
156 "yplist_maps: getkey failed for %s\n",
161 (void) strcpy(map
->ypml_name
, map_key
);
163 if (yp_getkey(mapname
, map_key
,
166 "yplist_maps: getkey failed for %s\n",
170 } else if (strcmp(mapname
, map_key
) == 0) {
171 (void) strncpy(map
->ypml_name
,
173 (unsigned int) namesz
);
174 map
->ypml_name
[YPMAXMAP
] = '\0';
176 (void) strcpy(map
->ypml_name
, map_key
);