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]
22 * Copyright 1996 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
27 /* All Rights Reserved */
30 * Portions of this source code were derived from Berkeley
31 * under license from the Regents of the University of
35 #pragma ident "%Z%%M% %I% %E% SMI"
39 #include <sys/types.h>
40 #include <sys/statvfs.h>
42 /* this is 14 less the space for temps pids and .pag more or less */
45 #define YPDBDIR "/var/ypnew"
46 #define ALIASLIST "/var/ypnew/aliases"
48 #define YPDBDIR "/var/yp"
49 #define ALIASLIST "/var/yp/aliases"
51 #define issep(c) (c == ' ' || c == '\t')
54 #define isvar_sysv() (wasitsysv)
56 static int wasitsysv
= TRUE
;
57 static int first_time
= TRUE
;
58 static listofnames
*list
= NULL
;
62 extern listofnames
*names();
64 extern void free_listofnames();
67 * Setup alias file, check /var/yp filesystem type
68 * Note: The *never* checks for aliases under Solaris, so there is no need
69 * for this function. As of 1.1 beta 4, I will ifdef it out (cause
70 * you never know...). Should go away completely soon.
77 struct statvfs statbuf
;
79 sigset(SIGCHLD
, SIG_IGN
);
81 * if neccesary free previous list, then read in aliaslist
85 free_listofnames(list
);
89 list
= names(ALIASLIST
);
92 * Check if YP database directory is in a system v filesystem
95 if (statvfs(YPDBDIR
, &statbuf
) != 0) {
96 fprintf(stderr
, "Cannot stat %s\n", YPDBDIR
);
99 /* if (strcmp(statbuf.f_basetype,"s5")) (doesn't work in k13) */
100 if (statbuf
.f_namemax
== 14)
105 sigset(SIGCHLD
, (void (*)())sysvconfig
);
113 yp_getalias(key
, key_alias
, maxlen
)
124 strcpy(key_alias
, key
);
127 /* sysvconfig must be run before this routine */
128 if (key
== NULL
|| first_time
)
132 strcpy(key_alias
, key
);
136 for (entry
= list
, strcpy(name
, entry
->name
); entry
;
137 entry
= entry
->nextname
, strcpy(name
, entry
->name
)) {
139 longname
= strtok(name
, " \t");
140 alias
= strtok(NULL
, " \t\n");
141 if (longname
== NULL
|| alias
== NULL
) {
144 if (strcmp(longname
, key
) == 0) {
145 if ((int)strlen(alias
) > (maxlen
)) {
146 strncpy(key_alias
, alias
, (maxlen
));
147 key_alias
[maxlen
] = '\0';
149 strcpy(key_alias
, alias
);
154 /* alias not found */
163 yp_getkey(key_alias
, key
, maxlen
)
174 strcpy(key
, key_alias
);
177 if (key_alias
== NULL
|| first_time
) {
182 strcpy(key
, key_alias
);
186 for (entry
= list
, strcpy(name
, entry
->name
);
187 entry
; entry
= entry
->nextname
, strcpy(name
, entry
->name
)) {
189 longname
= strtok(name
, " \t");
190 alias
= strtok(NULL
, " \t\n");
191 if (alias
== NULL
|| longname
== NULL
) {
194 if ((strcmp(alias
, key_alias
) == 0) ||
195 (strncmp(alias
, key_alias
, maxlen
) == 0)) {
196 strcpy(key
, longname
);