xref: /titanic_44/usr/src/cmd/ypcmd/shared/utils.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved   */
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
32*7c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of
33*7c478bd9Sstevel@tonic-gate  * California.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /*
39*7c478bd9Sstevel@tonic-gate  * DESCRIPTION:	This file contains various functions used by more than one NIS
40*7c478bd9Sstevel@tonic-gate  *		components. A lot of this code started off in ypxfr and then
41*7c478bd9Sstevel@tonic-gate  *		got used by other components. Some of it has become a little
42*7c478bd9Sstevel@tonic-gate  *		'quirky' and should probably be re-worked.
43*7c478bd9Sstevel@tonic-gate  */
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #include <unistd.h>
46*7c478bd9Sstevel@tonic-gate #include <syslog.h>
47*7c478bd9Sstevel@tonic-gate #include <sys/mman.h>
48*7c478bd9Sstevel@tonic-gate #include <thread.h>
49*7c478bd9Sstevel@tonic-gate #include <synch.h>
50*7c478bd9Sstevel@tonic-gate #include <stdarg.h>
51*7c478bd9Sstevel@tonic-gate #include <ndbm.h>
52*7c478bd9Sstevel@tonic-gate #include "../ypsym.h"
53*7c478bd9Sstevel@tonic-gate #include "../ypdefs.h"
54*7c478bd9Sstevel@tonic-gate #include "shim.h"
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate USE_DBM
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /*
59*7c478bd9Sstevel@tonic-gate  * Globals
60*7c478bd9Sstevel@tonic-gate  */
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate /*
63*7c478bd9Sstevel@tonic-gate  * DESCRIPTION : Utility functions used by everything.
64*7c478bd9Sstevel@tonic-gate  */
65*7c478bd9Sstevel@tonic-gate bool check_map_existence(char *);
66*7c478bd9Sstevel@tonic-gate void logprintf2(char *format, ...);
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate /*
69*7c478bd9Sstevel@tonic-gate  * This checks to see if the source map files exist, then renames them to the
70*7c478bd9Sstevel@tonic-gate  * target names.  This is a boolean function.  The file names from.pag and
71*7c478bd9Sstevel@tonic-gate  * from.dir will be changed to to.pag and to.dir in the success case.
72*7c478bd9Sstevel@tonic-gate  *
73*7c478bd9Sstevel@tonic-gate  * Note:  If the second of the two renames fails, yprename_map will try to
74*7c478bd9Sstevel@tonic-gate  * un-rename the first pair, and leave the world in the state it was on entry.
75*7c478bd9Sstevel@tonic-gate  * This might fail, too, though...
76*7c478bd9Sstevel@tonic-gate  *
77*7c478bd9Sstevel@tonic-gate  * GIVEN :	Name of map to copy from
78*7c478bd9Sstevel@tonic-gate  *		Name of map to copy to
79*7c478bd9Sstevel@tonic-gate  *		Flag indicating if map is secure.
80*7c478bd9Sstevel@tonic-gate  */
81*7c478bd9Sstevel@tonic-gate bool
82*7c478bd9Sstevel@tonic-gate rename_map(from, to, secure_map)
83*7c478bd9Sstevel@tonic-gate 	char *from;
84*7c478bd9Sstevel@tonic-gate 	char *to;
85*7c478bd9Sstevel@tonic-gate 	bool_t secure_map;
86*7c478bd9Sstevel@tonic-gate {
87*7c478bd9Sstevel@tonic-gate 	char fromfile[MAXNAMLEN + 1];
88*7c478bd9Sstevel@tonic-gate 	char tofile[MAXNAMLEN + 1];
89*7c478bd9Sstevel@tonic-gate 	char savefile[MAXNAMLEN + 1];
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 	if (!from || !to) {
92*7c478bd9Sstevel@tonic-gate 		return (FALSE);
93*7c478bd9Sstevel@tonic-gate 	}
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate 	if (!check_map_existence(from)) {
96*7c478bd9Sstevel@tonic-gate 		return (FALSE);
97*7c478bd9Sstevel@tonic-gate 	}
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate 	(void) strcpy(fromfile, from);
100*7c478bd9Sstevel@tonic-gate 	(void) strcat(fromfile, dbm_pag);
101*7c478bd9Sstevel@tonic-gate 	(void) strcpy(tofile, to);
102*7c478bd9Sstevel@tonic-gate 	(void) strcat(tofile, dbm_pag);
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate 	if (rename(fromfile, tofile)) {
105*7c478bd9Sstevel@tonic-gate 		logprintf2("Can't mv %s to %s.\n", fromfile,
106*7c478bd9Sstevel@tonic-gate 		    tofile);
107*7c478bd9Sstevel@tonic-gate 		return (FALSE);
108*7c478bd9Sstevel@tonic-gate 	}
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate 	(void) strcpy(savefile, tofile);
111*7c478bd9Sstevel@tonic-gate 	(void) strcpy(fromfile, from);
112*7c478bd9Sstevel@tonic-gate 	(void) strcat(fromfile, dbm_dir);
113*7c478bd9Sstevel@tonic-gate 	(void) strcpy(tofile, to);
114*7c478bd9Sstevel@tonic-gate 	(void) strcat(tofile, dbm_dir);
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate 	if (rename(fromfile, tofile)) {
117*7c478bd9Sstevel@tonic-gate 		logprintf2("Can't mv %s to %s.\n", fromfile,
118*7c478bd9Sstevel@tonic-gate 		    tofile);
119*7c478bd9Sstevel@tonic-gate 		(void) strcpy(fromfile, from);
120*7c478bd9Sstevel@tonic-gate 		(void) strcat(fromfile, dbm_pag);
121*7c478bd9Sstevel@tonic-gate 		(void) strcpy(tofile, to);
122*7c478bd9Sstevel@tonic-gate 		(void) strcat(tofile, dbm_pag);
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 		if (rename(tofile, fromfile)) {
125*7c478bd9Sstevel@tonic-gate 			logprintf2(
126*7c478bd9Sstevel@tonic-gate 			    "Can't recover from rename failure.\n");
127*7c478bd9Sstevel@tonic-gate 			return (FALSE);
128*7c478bd9Sstevel@tonic-gate 		}
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate 		return (FALSE);
131*7c478bd9Sstevel@tonic-gate 	}
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate 	if (!secure_map) {
134*7c478bd9Sstevel@tonic-gate 		chmod(savefile, 0644);
135*7c478bd9Sstevel@tonic-gate 		chmod(tofile, 0644);
136*7c478bd9Sstevel@tonic-gate 	}
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate 	return (TRUE);
139*7c478bd9Sstevel@tonic-gate }
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /*
142*7c478bd9Sstevel@tonic-gate  * Function :	delete_map()
143*7c478bd9Sstevel@tonic-gate  *
144*7c478bd9Sstevel@tonic-gate  * Description:	Deletes a map
145*7c478bd9Sstevel@tonic-gate  *
146*7c478bd9Sstevel@tonic-gate  * Given :	Map name
147*7c478bd9Sstevel@tonic-gate  *
148*7c478bd9Sstevel@tonic-gate  * Return :	TRUE = Map deleted
149*7c478bd9Sstevel@tonic-gate  *		FALSE = Map not completly deleted
150*7c478bd9Sstevel@tonic-gate  */
151*7c478bd9Sstevel@tonic-gate bool
152*7c478bd9Sstevel@tonic-gate delete_map(name)
153*7c478bd9Sstevel@tonic-gate 	char *name;
154*7c478bd9Sstevel@tonic-gate {
155*7c478bd9Sstevel@tonic-gate 	char fromfile[MAXNAMLEN + 1];
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate 	if (!name) {
158*7c478bd9Sstevel@tonic-gate 		return (FALSE);
159*7c478bd9Sstevel@tonic-gate 	}
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate 	if (!check_map_existence(name)) {
162*7c478bd9Sstevel@tonic-gate 		/* Already gone */
163*7c478bd9Sstevel@tonic-gate 		return (TRUE);
164*7c478bd9Sstevel@tonic-gate 	}
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate 	(void) strcpy(fromfile, name);
167*7c478bd9Sstevel@tonic-gate 	(void) strcat(fromfile, dbm_pag);
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate 	if (unlink(fromfile)) {
170*7c478bd9Sstevel@tonic-gate 		logprintf2("Can't unlink %s.\n", fromfile);
171*7c478bd9Sstevel@tonic-gate 		return (FALSE);
172*7c478bd9Sstevel@tonic-gate 	}
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate 	(void) strcpy(fromfile, name);
175*7c478bd9Sstevel@tonic-gate 	(void) strcat(fromfile, dbm_dir);
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate 	if (unlink(fromfile)) {
178*7c478bd9Sstevel@tonic-gate 		logprintf2("Can't unlink %s.\n", fromfile);
179*7c478bd9Sstevel@tonic-gate 		return (FALSE);
180*7c478bd9Sstevel@tonic-gate 	}
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate 	return (TRUE);
183*7c478bd9Sstevel@tonic-gate }
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate /*
186*7c478bd9Sstevel@tonic-gate  * This performs an existence check on the dbm data base files <pname>.pag and
187*7c478bd9Sstevel@tonic-gate  * <pname>.dir.
188*7c478bd9Sstevel@tonic-gate  */
189*7c478bd9Sstevel@tonic-gate bool
190*7c478bd9Sstevel@tonic-gate check_map_existence(pname)
191*7c478bd9Sstevel@tonic-gate 	char *pname;
192*7c478bd9Sstevel@tonic-gate {
193*7c478bd9Sstevel@tonic-gate 	char dbfile[MAXNAMLEN + 1];
194*7c478bd9Sstevel@tonic-gate 	struct stat filestat;
195*7c478bd9Sstevel@tonic-gate 	int len;
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate 	if (!pname || ((len = strlen(pname)) == 0) ||
198*7c478bd9Sstevel@tonic-gate 	    (len + 5) > (MAXNAMLEN + 1)) {
199*7c478bd9Sstevel@tonic-gate 		return (FALSE);
200*7c478bd9Sstevel@tonic-gate 	}
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate 	errno = 0;
203*7c478bd9Sstevel@tonic-gate 	(void) strcpy(dbfile, pname);
204*7c478bd9Sstevel@tonic-gate 	(void) strcat(dbfile, dbm_dir);
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate 	if (stat(dbfile, &filestat) != -1) {
207*7c478bd9Sstevel@tonic-gate 		(void) strcpy(dbfile, pname);
208*7c478bd9Sstevel@tonic-gate 		(void) strcat(dbfile, dbm_pag);
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate 		if (stat(dbfile, &filestat) != -1) {
211*7c478bd9Sstevel@tonic-gate 			return (TRUE);
212*7c478bd9Sstevel@tonic-gate 		} else {
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate 			if (errno != ENOENT) {
215*7c478bd9Sstevel@tonic-gate 				logprintf2(
216*7c478bd9Sstevel@tonic-gate 				    "Stat error on map file %s.\n",
217*7c478bd9Sstevel@tonic-gate 				    dbfile);
218*7c478bd9Sstevel@tonic-gate 			}
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate 			return (FALSE);
221*7c478bd9Sstevel@tonic-gate 		}
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate 	} else {
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate 		if (errno != ENOENT) {
226*7c478bd9Sstevel@tonic-gate 			logprintf2(
227*7c478bd9Sstevel@tonic-gate 			    "Stat error on map file %s.\n",
228*7c478bd9Sstevel@tonic-gate 			    dbfile);
229*7c478bd9Sstevel@tonic-gate 		}
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate 		return (FALSE);
232*7c478bd9Sstevel@tonic-gate 	}
233*7c478bd9Sstevel@tonic-gate }
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate /*
236*7c478bd9Sstevel@tonic-gate  * FUNCTION :	logprintf2()
237*7c478bd9Sstevel@tonic-gate  *
238*7c478bd9Sstevel@tonic-gate  * DESCRIPTION:	The functions in this file were oringinaly shared between
239*7c478bd9Sstevel@tonic-gate  *		ypxfr and ypserv. On error they called logprintf().
240*7c478bd9Sstevel@tonic-gate  *		Unfortunatly this had been implemented differently in the two
241*7c478bd9Sstevel@tonic-gate  *		sources and not at all in some of the NIS components required
242*7c478bd9Sstevel@tonic-gate  *		for N2L.
243*7c478bd9Sstevel@tonic-gate  *
244*7c478bd9Sstevel@tonic-gate  *		This function is simplified version of logprinf() as/when
245*7c478bd9Sstevel@tonic-gate  *		possible the other error calls should be migrated to use this
246*7c478bd9Sstevel@tonic-gate  *		common version. If a common set of functionality can be found
247*7c478bd9Sstevel@tonic-gate  *		this versions should be modified to support it.
248*7c478bd9Sstevel@tonic-gate  */
249*7c478bd9Sstevel@tonic-gate void
250*7c478bd9Sstevel@tonic-gate logprintf2(char *format, ...)
251*7c478bd9Sstevel@tonic-gate {
252*7c478bd9Sstevel@tonic-gate 	va_list ap;
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate 	va_start(ap, format);
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate 	syslog(LOG_ERR, format, ap);
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate 	va_end(ap);
259*7c478bd9Sstevel@tonic-gate }
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate /*
262*7c478bd9Sstevel@tonic-gate  * This performs an existence check on the dbm data base files <name>.pag and
263*7c478bd9Sstevel@tonic-gate  * <name>.dir.  pname is a ptr to the filename.  This should be an absolute
264*7c478bd9Sstevel@tonic-gate  * path.
265*7c478bd9Sstevel@tonic-gate  * Returns TRUE if the map exists and is accessable; else FALSE.
266*7c478bd9Sstevel@tonic-gate  *
267*7c478bd9Sstevel@tonic-gate  * Note:  The file name should be a "base" form, without a file "extension" of
268*7c478bd9Sstevel@tonic-gate  * .dir or .pag appended.  See ypmkfilename for a function which will generate
269*7c478bd9Sstevel@tonic-gate  * the name correctly.  Errors in the stat call will be reported at this level,
270*7c478bd9Sstevel@tonic-gate  * however, the non-existence of a file is not considered an error, and so will
271*7c478bd9Sstevel@tonic-gate  * not be reported.
272*7c478bd9Sstevel@tonic-gate  */
273*7c478bd9Sstevel@tonic-gate bool
274*7c478bd9Sstevel@tonic-gate ypcheck_map_existence(char *pname)
275*7c478bd9Sstevel@tonic-gate {
276*7c478bd9Sstevel@tonic-gate 	char dbfile[MAXNAMLEN + sizeof (TTL_POSTFIX) + 1];
277*7c478bd9Sstevel@tonic-gate 	struct stat filestat;
278*7c478bd9Sstevel@tonic-gate 	int len;
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate 	if (!pname || ((len = (int)strlen(pname)) == 0) ||
281*7c478bd9Sstevel@tonic-gate 		(len + sizeof (dbm_pag)) > (MAXNAMLEN + 1)) {
282*7c478bd9Sstevel@tonic-gate 		return (FALSE);
283*7c478bd9Sstevel@tonic-gate 	}
284*7c478bd9Sstevel@tonic-gate 
285*7c478bd9Sstevel@tonic-gate 	errno = 0;
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate 	/* Check for existance of .dir file */
288*7c478bd9Sstevel@tonic-gate 	(void) strcpy(dbfile, pname);
289*7c478bd9Sstevel@tonic-gate 	(void) strcat(dbfile, dbm_dir);
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate 	if (stat(dbfile, &filestat) == -1) {
292*7c478bd9Sstevel@tonic-gate 		if (errno != ENOENT) {
293*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr,
294*7c478bd9Sstevel@tonic-gate 				"ypserv:  Stat error on map file %s.\n",
295*7c478bd9Sstevel@tonic-gate 									dbfile);
296*7c478bd9Sstevel@tonic-gate 		}
297*7c478bd9Sstevel@tonic-gate 		return (FALSE);
298*7c478bd9Sstevel@tonic-gate 	}
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate 	/* Check for existance of .pag file */
301*7c478bd9Sstevel@tonic-gate 	(void) strcpy(dbfile, pname);
302*7c478bd9Sstevel@tonic-gate 	(void) strcat(dbfile, dbm_pag);
303*7c478bd9Sstevel@tonic-gate 
304*7c478bd9Sstevel@tonic-gate 	if (stat(dbfile, &filestat) == -1) {
305*7c478bd9Sstevel@tonic-gate 		if (errno != ENOENT) {
306*7c478bd9Sstevel@tonic-gate 			(void) fprintf(stderr,
307*7c478bd9Sstevel@tonic-gate 				"ypserv:  Stat error on map file %s.\n",
308*7c478bd9Sstevel@tonic-gate 									dbfile);
309*7c478bd9Sstevel@tonic-gate 		    }
310*7c478bd9Sstevel@tonic-gate 		return (FALSE);
311*7c478bd9Sstevel@tonic-gate 	}
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate 	if (yptol_mode) {
314*7c478bd9Sstevel@tonic-gate 		/* Check for existance of TTL .dir file */
315*7c478bd9Sstevel@tonic-gate 		(void) strcpy(dbfile, pname);
316*7c478bd9Sstevel@tonic-gate 		(void) strcat(dbfile, TTL_POSTFIX);
317*7c478bd9Sstevel@tonic-gate 		(void) strcat(dbfile, dbm_dir);
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate 		if (stat(dbfile, &filestat) == -1) {
320*7c478bd9Sstevel@tonic-gate 			if (errno != ENOENT) {
321*7c478bd9Sstevel@tonic-gate 				(void) fprintf(stderr,
322*7c478bd9Sstevel@tonic-gate 					"ypserv:  Stat error on map file %s.\n",
323*7c478bd9Sstevel@tonic-gate 									dbfile);
324*7c478bd9Sstevel@tonic-gate 			}
325*7c478bd9Sstevel@tonic-gate 			return (FALSE);
326*7c478bd9Sstevel@tonic-gate 		}
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate 		/* Check for existance of TTL .pag file */
329*7c478bd9Sstevel@tonic-gate 		(void) strcpy(dbfile, pname);
330*7c478bd9Sstevel@tonic-gate 		(void) strcat(dbfile, TTL_POSTFIX);
331*7c478bd9Sstevel@tonic-gate 		(void) strcat(dbfile, dbm_pag);
332*7c478bd9Sstevel@tonic-gate 
333*7c478bd9Sstevel@tonic-gate 		if (stat(dbfile, &filestat) == -1) {
334*7c478bd9Sstevel@tonic-gate 			if (errno != ENOENT) {
335*7c478bd9Sstevel@tonic-gate 				(void) fprintf(stderr,
336*7c478bd9Sstevel@tonic-gate 					"ypserv:  Stat error on map file %s.\n",
337*7c478bd9Sstevel@tonic-gate 									dbfile);
338*7c478bd9Sstevel@tonic-gate 			    }
339*7c478bd9Sstevel@tonic-gate 			    return (FALSE);
340*7c478bd9Sstevel@tonic-gate 		}
341*7c478bd9Sstevel@tonic-gate 	}
342*7c478bd9Sstevel@tonic-gate 
343*7c478bd9Sstevel@tonic-gate 	return (TRUE);
344*7c478bd9Sstevel@tonic-gate }
345