xref: /onnv-gate/usr/src/cmd/sgs/crle/common/print.c (revision 1618:8c9a4f31d225)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1618Srie  * Common Development and Distribution License (the "License").
6*1618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*1618Srie 
220Sstevel@tonic-gate /*
23*1618Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include	<sys/types.h>
290Sstevel@tonic-gate #include	<sys/stat.h>
300Sstevel@tonic-gate #include	<sys/mman.h>
310Sstevel@tonic-gate #include	<fcntl.h>
320Sstevel@tonic-gate #include	<stdio.h>
330Sstevel@tonic-gate #include	<string.h>
340Sstevel@tonic-gate #include	<unistd.h>
350Sstevel@tonic-gate #include	<errno.h>
360Sstevel@tonic-gate #include	<limits.h>
370Sstevel@tonic-gate #include	<alloca.h>
380Sstevel@tonic-gate #include	"sgs.h"
390Sstevel@tonic-gate #include	"rtc.h"
400Sstevel@tonic-gate #include	"conv.h"
410Sstevel@tonic-gate #include	"_crle.h"
420Sstevel@tonic-gate #include	"msg.h"
430Sstevel@tonic-gate 
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * Display the command line required to regenerate the configuration file.
470Sstevel@tonic-gate  *
480Sstevel@tonic-gate  * Under normal mode the command is printed on one line to make it more
490Sstevel@tonic-gate  * available for grep(1) use.  Under verbose mode the command is separated
500Sstevel@tonic-gate  * into each argument (a little more readable perhaps when the arguments are
510Sstevel@tonic-gate  * numerous of have long pathnames).
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * Note that for version 1 configuration files we never used to generate any
540Sstevel@tonic-gate  * command-line information, and as the attempt to do so is only a best effort
550Sstevel@tonic-gate  * don't bother printing anything.
560Sstevel@tonic-gate  */
570Sstevel@tonic-gate static void
580Sstevel@tonic-gate printcmd(Crle_desc * crle, Rtc_head * head, List * cmdline)
590Sstevel@tonic-gate {
600Sstevel@tonic-gate 	Listnode	*lnp;
610Sstevel@tonic-gate 	const char	*fmto, *fmtb, *fmtm, *fmte;
620Sstevel@tonic-gate 	char		*cmd;
630Sstevel@tonic-gate 	int		output = 0;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate 	if (crle->c_flags & CRLE_VERBOSE) {
660Sstevel@tonic-gate 		fmto = MSG_INTL(MSG_DMP_CMD_ONE_V);
670Sstevel@tonic-gate 		fmtb = MSG_INTL(MSG_DMP_CMD_BGN_V);
680Sstevel@tonic-gate 		fmtm = MSG_INTL(MSG_DMP_CMD_MID_V);
690Sstevel@tonic-gate 		fmte = MSG_INTL(MSG_DMP_CMD_END_V);
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 	} else if (head->ch_version > RTC_VER_ONE) {
720Sstevel@tonic-gate 		fmto = MSG_INTL(MSG_DMP_CMD_ONE);
730Sstevel@tonic-gate 		fmtb = MSG_INTL(MSG_DMP_CMD_BGN);
740Sstevel@tonic-gate 		fmtm = MSG_INTL(MSG_DMP_CMD_MID);
750Sstevel@tonic-gate 		fmte = MSG_INTL(MSG_DMP_CMD_END);
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 	} else {
780Sstevel@tonic-gate 		(void) printf(MSG_ORIG(MSG_STR_NL));
790Sstevel@tonic-gate 		return;
800Sstevel@tonic-gate 	}
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	(void) printf(MSG_INTL(MSG_DMP_CMD_TITLE));
830Sstevel@tonic-gate 	for (LIST_TRAVERSE(cmdline, lnp, cmd)) {
840Sstevel@tonic-gate 		if (output++ == 0) {
850Sstevel@tonic-gate 			if (lnp->next)
860Sstevel@tonic-gate 				(void) printf(fmtb, cmd);
870Sstevel@tonic-gate 			else
880Sstevel@tonic-gate 				(void) printf(fmto, cmd);
890Sstevel@tonic-gate 		} else {
900Sstevel@tonic-gate 			if (lnp->next)
910Sstevel@tonic-gate 				(void) printf(fmtm, cmd);
920Sstevel@tonic-gate 			else
930Sstevel@tonic-gate 				(void) printf(fmte, cmd);
940Sstevel@tonic-gate 		}
950Sstevel@tonic-gate 	}
960Sstevel@tonic-gate }
970Sstevel@tonic-gate 
980Sstevel@tonic-gate /*
990Sstevel@tonic-gate  * Establish the argument required to generate the associated object.
1000Sstevel@tonic-gate  */
1010Sstevel@tonic-gate static const char *
1020Sstevel@tonic-gate getformat(Half flags)
1030Sstevel@tonic-gate {
1040Sstevel@tonic-gate 	if (flags & RTC_OBJ_ALTER) {
1050Sstevel@tonic-gate 		if (flags & RTC_OBJ_DUMP) {
1060Sstevel@tonic-gate 			if (flags & RTC_OBJ_GROUP)
1070Sstevel@tonic-gate 				return (MSG_ORIG(MSG_CMD_DUMPGRP));
1080Sstevel@tonic-gate 			else
1090Sstevel@tonic-gate 				return (MSG_ORIG(MSG_CMD_DUMPIND));
1100Sstevel@tonic-gate 		} else {
1110Sstevel@tonic-gate 			if (flags & RTC_OBJ_OPTINAL)
1120Sstevel@tonic-gate 				return (MSG_ORIG(MSG_CMD_OPTIONAL));
1130Sstevel@tonic-gate 			else
1140Sstevel@tonic-gate 				return (MSG_ORIG(MSG_CMD_ALTER));
1150Sstevel@tonic-gate 		}
1160Sstevel@tonic-gate 	} else {
1170Sstevel@tonic-gate 		if (flags & RTC_OBJ_GROUP)
1180Sstevel@tonic-gate 			return (MSG_ORIG(MSG_CMD_GRP));
1190Sstevel@tonic-gate 		else
1200Sstevel@tonic-gate 			return (MSG_ORIG(MSG_CMD_IND));
1210Sstevel@tonic-gate 	}
1220Sstevel@tonic-gate }
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * Fabricate a system default search path.  If an update is requested, and
1260Sstevel@tonic-gate  * new search paths are specified while no configuration file exists, or if a
1270Sstevel@tonic-gate  * configuration file does exist but doesn't specify this particular search
1280Sstevel@tonic-gate  * path, create any system defaults.  The intent is to allow
1290Sstevel@tonic-gate  * "crle -u -l/usr/local/lib" and have this append the search path to the
1300Sstevel@tonic-gate  * system default, rather than have the user have to determine and specify
1310Sstevel@tonic-gate  * this default themselves.
1320Sstevel@tonic-gate  */
1330Sstevel@tonic-gate static int
1340Sstevel@tonic-gate fablib(Crle_desc * crle, int flag)
1350Sstevel@tonic-gate {
1360Sstevel@tonic-gate 	const char	*path;
1370Sstevel@tonic-gate 	char		**list;
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate 	switch (flag) {
1400Sstevel@tonic-gate 	case CRLE_EDLIB:
1410Sstevel@tonic-gate 		if (crle->c_class == ELFCLASS64) {
1420Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
1430Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_NEWDLP_64);
1440Sstevel@tonic-gate #else
1450Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_OLDDLP_64);
1460Sstevel@tonic-gate #endif
1470Sstevel@tonic-gate 		} else {
1480Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
1490Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_NEWDLP);
1500Sstevel@tonic-gate #else
1510Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_OLDDLP);
1520Sstevel@tonic-gate #endif
1530Sstevel@tonic-gate 		}
1540Sstevel@tonic-gate 		list = &crle->c_edlibpath;
1550Sstevel@tonic-gate 		break;
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate 	case CRLE_ESLIB:
1580Sstevel@tonic-gate 		if (crle->c_class == ELFCLASS64) {
1590Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
1600Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_NEWTD_64);
1610Sstevel@tonic-gate #else
1620Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_OLDTD_64);
1630Sstevel@tonic-gate #endif
1640Sstevel@tonic-gate 		} else {
1650Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
1660Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_NEWTD);
1670Sstevel@tonic-gate #else
1680Sstevel@tonic-gate 			path = MSG_ORIG(MSG_PTH_OLDTD);
1690Sstevel@tonic-gate #endif
1700Sstevel@tonic-gate 		}
1710Sstevel@tonic-gate 		list = &crle->c_eslibpath;
1720Sstevel@tonic-gate 		break;
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate 	case CRLE_ADLIB:
1750Sstevel@tonic-gate 		path = MSG_ORIG(MSG_PTH_AOUTDLP);
1760Sstevel@tonic-gate 		list = &crle->c_adlibpath;
1770Sstevel@tonic-gate 		break;
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate 	case CRLE_ASLIB:
1800Sstevel@tonic-gate 		path = MSG_ORIG(MSG_PTH_AOUTTD);
1810Sstevel@tonic-gate 		list = &crle->c_aslibpath;
1820Sstevel@tonic-gate 		break;
1830Sstevel@tonic-gate 
1840Sstevel@tonic-gate 	default:
1850Sstevel@tonic-gate 		return (1);
1860Sstevel@tonic-gate 	}
1870Sstevel@tonic-gate 
1880Sstevel@tonic-gate 	return (addlib(crle, list, path));
1890Sstevel@tonic-gate }
1900Sstevel@tonic-gate 
1910Sstevel@tonic-gate /*
1920Sstevel@tonic-gate  * Establish the flags required to generate the associated object.  Actually
1930Sstevel@tonic-gate  * the flags are already part of the object being inspected from the present
1940Sstevel@tonic-gate  * configuration file, but instead of using them all, which can cause some
1950Sstevel@tonic-gate  * unsuspected propagation down the inspect() family, only use those flags that
1960Sstevel@tonic-gate  * would have been contributed from crle()'s calls to inspect.
1970Sstevel@tonic-gate  */
1980Sstevel@tonic-gate static Half
1990Sstevel@tonic-gate getflags(Half flags)
2000Sstevel@tonic-gate {
2010Sstevel@tonic-gate 	flags &=
2020Sstevel@tonic-gate 	    (RTC_OBJ_ALTER | RTC_OBJ_DUMP | RTC_OBJ_GROUP | RTC_OBJ_OPTINAL);
2030Sstevel@tonic-gate 	return (flags | RTC_OBJ_CMDLINE);
2040Sstevel@tonic-gate }
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate /*
2070Sstevel@tonic-gate  * Dump a configuration files information.  This routine is very close to the
2080Sstevel@tonic-gate  * scanconfig() in libcrle.
2090Sstevel@tonic-gate  */
2100Sstevel@tonic-gate static int
2110Sstevel@tonic-gate scanconfig(Crle_desc * crle, Addr addr)
2120Sstevel@tonic-gate {
2130Sstevel@tonic-gate 	Rtc_head	*head = (Rtc_head *)addr;
2140Sstevel@tonic-gate 	Rtc_dir		*dirtbl;
2150Sstevel@tonic-gate 	Rtc_file	*filetbl;
2160Sstevel@tonic-gate 	Rtc_obj		*objtbl, * obj;
2170Sstevel@tonic-gate 	Word		*hash, * chain;
2180Sstevel@tonic-gate 	const char	*strtbl;
2190Sstevel@tonic-gate 	int		ndx, bkts;
2200Sstevel@tonic-gate 	List		cmdline = { 0 };
2210Sstevel@tonic-gate 	char		_cmd[PATH_MAX], * cmd;
2220Sstevel@tonic-gate 	char		_objdir[PATH_MAX], * objdir = 0;
2230Sstevel@tonic-gate 
2240Sstevel@tonic-gate 	/* LINTED */
2250Sstevel@tonic-gate 	objtbl = (Rtc_obj *)((char *)head->ch_obj + addr);
2260Sstevel@tonic-gate 	strtbl = (const char *)((char *)head->ch_str + addr);
2270Sstevel@tonic-gate 
2280Sstevel@tonic-gate 	/*
2290Sstevel@tonic-gate 	 * If this is a version 1 configuration file we can't generate accurate
2300Sstevel@tonic-gate 	 * update information, or the command-line used to create the file.
2310Sstevel@tonic-gate 	 */
2320Sstevel@tonic-gate 	if (head->ch_version == RTC_VER_ONE) {
2330Sstevel@tonic-gate 		(void) printf(MSG_INTL(MSG_ARG_UPDATE), crle->c_name,
2340Sstevel@tonic-gate 		    crle->c_confil, head->ch_version);
2350Sstevel@tonic-gate 	}
2360Sstevel@tonic-gate 
2370Sstevel@tonic-gate 	/*
2380Sstevel@tonic-gate 	 * If we're updating an existing configuration file make sure we're
2390Sstevel@tonic-gate 	 * dealing with the same class of file.
2400Sstevel@tonic-gate 	 */
2410Sstevel@tonic-gate 	if (crle->c_flags & CRLE_UPDATE) {
2420Sstevel@tonic-gate 		if (head->ch_cnflags & RTC_HDR_64)
2430Sstevel@tonic-gate 			crle->c_class = ELFCLASS64;
2440Sstevel@tonic-gate 		else if (crle->c_class == ELFCLASS64) {
2450Sstevel@tonic-gate 		    (void) fprintf(stderr, MSG_INTL(MSG_ARG_CLASS),
2460Sstevel@tonic-gate 			crle->c_name, crle->c_confil);
2470Sstevel@tonic-gate 			return (1);
2480Sstevel@tonic-gate 		}
2490Sstevel@tonic-gate 	} else {
2500Sstevel@tonic-gate 		if (head->ch_cnflags & RTC_HDR_64) {
2510Sstevel@tonic-gate 			/*
2520Sstevel@tonic-gate 			 * Construct the original command line argument.
2530Sstevel@tonic-gate 			 */
2540Sstevel@tonic-gate 			cmd = strcpy(alloca(MSG_CMD_64_SIZE + 1),
2550Sstevel@tonic-gate 			    MSG_ORIG(MSG_CMD_64));
2560Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
2570Sstevel@tonic-gate 				return (1);
2580Sstevel@tonic-gate 		}
2590Sstevel@tonic-gate 	}
2600Sstevel@tonic-gate 
2610Sstevel@tonic-gate 	/*
2620Sstevel@tonic-gate 	 * Start analyzing the configuration files header information.
2630Sstevel@tonic-gate 	 */
2640Sstevel@tonic-gate 	if ((crle->c_flags & CRLE_UPDATE) == 0) {
2650Sstevel@tonic-gate 		const char	*fmt;
2660Sstevel@tonic-gate 
2670Sstevel@tonic-gate 		if (head->ch_dlflags)
268*1618Srie 			fmt = conv_dl_flag(head->ch_dlflags, 0);
2690Sstevel@tonic-gate 		else
2700Sstevel@tonic-gate 			fmt = MSG_ORIG(MSG_STR_EMPTY);
2710Sstevel@tonic-gate 
2720Sstevel@tonic-gate 		(void) printf(MSG_INTL(MSG_DMP_HEAD), head->ch_version,
2730Sstevel@tonic-gate 		    crle->c_confil, fmt);
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate 		/*
2760Sstevel@tonic-gate 		 * Construct the original command line argument.
2770Sstevel@tonic-gate 		 */
2780Sstevel@tonic-gate 		(void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_CONF),
2790Sstevel@tonic-gate 		    crle->c_confil);
2800Sstevel@tonic-gate 		cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
2810Sstevel@tonic-gate 		if (list_append(&cmdline, cmd) == 0)
2820Sstevel@tonic-gate 			return (1);
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 		/*
2850Sstevel@tonic-gate 		 * Construct any -f usage.
2860Sstevel@tonic-gate 		 */
2870Sstevel@tonic-gate 		if (head->ch_dlflags &&
2880Sstevel@tonic-gate 		    (head->ch_dlflags != RTLD_REL_RELATIVE)) {
2890Sstevel@tonic-gate 			(void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_FLAGS),
290*1618Srie 			    conv_dl_flag(head->ch_dlflags, 1));
2910Sstevel@tonic-gate 			cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
2920Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
2930Sstevel@tonic-gate 				return (1);
2940Sstevel@tonic-gate 		}
2950Sstevel@tonic-gate 	} else {
2960Sstevel@tonic-gate 		/*
2970Sstevel@tonic-gate 		 * Establish any -f usage.
2980Sstevel@tonic-gate 		 */
2990Sstevel@tonic-gate 		if (head->ch_dlflags &&
3000Sstevel@tonic-gate 		    (head->ch_dlflags != RTLD_REL_RELATIVE))
3010Sstevel@tonic-gate 			crle->c_dlflags = head->ch_dlflags;
3020Sstevel@tonic-gate 	}
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate 	/*
3060Sstevel@tonic-gate 	 * Determine if this configuration file is only applicable to a specific
3070Sstevel@tonic-gate 	 * application.
3080Sstevel@tonic-gate 	 */
3090Sstevel@tonic-gate 	if (head->ch_app) {
3100Sstevel@tonic-gate 		char	*alter;
3110Sstevel@tonic-gate 
3120Sstevel@tonic-gate 		obj = (Rtc_obj *)(head->ch_app + addr);
3130Sstevel@tonic-gate 
3140Sstevel@tonic-gate 		/*
3150Sstevel@tonic-gate 		 * Determine the output directory for the files
3160Sstevel@tonic-gate 		 * alternative name.
3170Sstevel@tonic-gate 		 */
3180Sstevel@tonic-gate 		alter = (char *)(strtbl + obj->co_alter);
3190Sstevel@tonic-gate 		(void) strcpy(_objdir, alter);
3200Sstevel@tonic-gate 		alter = strrchr(_objdir, '/');
3210Sstevel@tonic-gate 		*alter = '\0';
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate 		crle->c_objdir = objdir = _objdir;
3240Sstevel@tonic-gate 
3250Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
3260Sstevel@tonic-gate 			if (inspect(crle, (strtbl + obj->co_name),
3270Sstevel@tonic-gate 			    (RTC_OBJ_DUMP | RTC_OBJ_ALTER |
3280Sstevel@tonic-gate 			    RTC_OBJ_GROUP | RTC_OBJ_CMDLINE)) != 0)
3290Sstevel@tonic-gate 				return (1);
3300Sstevel@tonic-gate 		} else {
3310Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DMP_APP),
3320Sstevel@tonic-gate 			    (strtbl + obj->co_alter), (strtbl + obj->co_name));
3330Sstevel@tonic-gate 
3340Sstevel@tonic-gate 			/*
3350Sstevel@tonic-gate 			 * Construct the original command line arguments.
3360Sstevel@tonic-gate 			 */
3370Sstevel@tonic-gate 			(void) snprintf(_cmd, PATH_MAX,
3380Sstevel@tonic-gate 			    MSG_ORIG(MSG_CMD_OUTPUT), crle->c_objdir);
3390Sstevel@tonic-gate 			cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
3400Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
3410Sstevel@tonic-gate 				return (1);
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate 			(void) snprintf(_cmd, PATH_MAX,
3440Sstevel@tonic-gate 			    MSG_ORIG(MSG_CMD_DUMPGRP), (strtbl + obj->co_name));
3450Sstevel@tonic-gate 			cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
3460Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
3470Sstevel@tonic-gate 				return (1);
3480Sstevel@tonic-gate 		}
3490Sstevel@tonic-gate 	}
3500Sstevel@tonic-gate 
3510Sstevel@tonic-gate 	/*
3520Sstevel@tonic-gate 	 * Analyze any alternative library path and trusted directory entries.
3530Sstevel@tonic-gate 	 */
3540Sstevel@tonic-gate 	if (head->ch_edlibpath) {
3550Sstevel@tonic-gate 		const char	*str;
3560Sstevel@tonic-gate 
3570Sstevel@tonic-gate 		str = (const char *)(head->ch_edlibpath + addr);
3580Sstevel@tonic-gate 
3590Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
3600Sstevel@tonic-gate 			crle->c_flags &= ~CRLE_AOUT;
3610Sstevel@tonic-gate 
3620Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
3630Sstevel@tonic-gate 			if ((head->ch_cnflags & RTC_HDR_UPM) == 0) {
3640Sstevel@tonic-gate 				if (head->ch_cnflags & RTC_HDR_64)
365*1618Srie 					str = conv_config_upm(str,
3660Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_OLDDLP_64),
3670Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_UPDLP_64),
3680Sstevel@tonic-gate 					    MSG_PTH_UPDLP_64_SIZE);
3690Sstevel@tonic-gate 				else
370*1618Srie 					str = conv_config_upm(str,
3710Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_OLDDLP),
3720Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_UPDLP),
3730Sstevel@tonic-gate 					    MSG_PTH_UPDLP_SIZE);
3740Sstevel@tonic-gate 			}
3750Sstevel@tonic-gate #endif
3760Sstevel@tonic-gate 			if (addlib(crle, &crle->c_edlibpath, str) != 0)
3770Sstevel@tonic-gate 				return (1);
3780Sstevel@tonic-gate 		} else {
3790Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DMP_DLIBPTH),
3800Sstevel@tonic-gate 			    MSG_ORIG(MSG_STR_ELF), str);
3810Sstevel@tonic-gate 
3820Sstevel@tonic-gate 			(void) snprintf(_cmd, PATH_MAX,
3830Sstevel@tonic-gate 			    MSG_ORIG(MSG_CMD_EDLIB), str);
3840Sstevel@tonic-gate 			cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
3850Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
3860Sstevel@tonic-gate 				return (1);
3870Sstevel@tonic-gate 		}
3880Sstevel@tonic-gate 	} else {
3890Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
3900Sstevel@tonic-gate 			if (crle->c_flags & CRLE_EDLIB) {
3910Sstevel@tonic-gate 				/*
3920Sstevel@tonic-gate 				 * If we've been asked to update a configuration
3930Sstevel@tonic-gate 				 * file, and no existing default ELF search
3940Sstevel@tonic-gate 				 * path exists, but the user is going to add new
3950Sstevel@tonic-gate 				 * entries, fabricate the system defaults so
3960Sstevel@tonic-gate 				 * that the users get added to them.
3970Sstevel@tonic-gate 				 */
3980Sstevel@tonic-gate 				if (fablib(crle, CRLE_EDLIB) != 0)
3990Sstevel@tonic-gate 					return (1);
4000Sstevel@tonic-gate 			}
4010Sstevel@tonic-gate 		} else {
4020Sstevel@tonic-gate 			/*
4030Sstevel@tonic-gate 			 * Indicate any system default.
4040Sstevel@tonic-gate 			 */
4050Sstevel@tonic-gate 			if (crle->c_class == ELFCLASS64) {
4060Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
4070Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_NEWDLP_64));
4080Sstevel@tonic-gate #else
4090Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_OLDDLP_64));
4100Sstevel@tonic-gate #endif
4110Sstevel@tonic-gate 			} else {
4120Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
4130Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_NEWDLP));
4140Sstevel@tonic-gate #else
4150Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_OLDDLP));
4160Sstevel@tonic-gate #endif
4170Sstevel@tonic-gate 			}
4180Sstevel@tonic-gate 		}
4190Sstevel@tonic-gate 	}
4200Sstevel@tonic-gate 
4210Sstevel@tonic-gate 	if (head->ch_eslibpath) {
4220Sstevel@tonic-gate 		const char	*str;
4230Sstevel@tonic-gate 
4240Sstevel@tonic-gate 		str = (const char *)(head->ch_eslibpath + addr);
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
4270Sstevel@tonic-gate 			crle->c_flags &= ~CRLE_AOUT;
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
4300Sstevel@tonic-gate 			if ((head->ch_cnflags & RTC_HDR_UPM) == 0) {
4310Sstevel@tonic-gate 				if (head->ch_cnflags & RTC_HDR_64)
432*1618Srie 					str = conv_config_upm(str,
4330Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_OLDTD_64),
4340Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_UPTD_64),
4350Sstevel@tonic-gate 					    MSG_PTH_UPTD_64_SIZE);
4360Sstevel@tonic-gate 				else
437*1618Srie 					str = conv_config_upm(str,
4380Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_OLDTD),
4390Sstevel@tonic-gate 					    MSG_ORIG(MSG_PTH_UPTD),
4400Sstevel@tonic-gate 					    MSG_PTH_UPTD_SIZE);
4410Sstevel@tonic-gate 			}
4420Sstevel@tonic-gate #endif
4430Sstevel@tonic-gate 			if (addlib(crle, &crle->c_eslibpath, str) != 0)
4440Sstevel@tonic-gate 				return (1);
4450Sstevel@tonic-gate 		} else {
4460Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DMP_TLIBPTH),
4470Sstevel@tonic-gate 			    MSG_ORIG(MSG_STR_ELF), str);
4480Sstevel@tonic-gate 
4490Sstevel@tonic-gate 			(void) snprintf(_cmd, PATH_MAX,
4500Sstevel@tonic-gate 			    MSG_ORIG(MSG_CMD_ESLIB), str);
4510Sstevel@tonic-gate 			cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
4520Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
4530Sstevel@tonic-gate 				return (1);
4540Sstevel@tonic-gate 		}
4550Sstevel@tonic-gate 	} else {
4560Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
4570Sstevel@tonic-gate 			if (crle->c_flags & CRLE_ESLIB) {
4580Sstevel@tonic-gate 				/*
4590Sstevel@tonic-gate 				 * If we've been asked to update a configuration
4600Sstevel@tonic-gate 				 * file, and no existing default ELF secure
4610Sstevel@tonic-gate 				 * path exists, but the user is going to add new
4620Sstevel@tonic-gate 				 * entries, fabricate the system defaults so
4630Sstevel@tonic-gate 				 * that the users get added to them.
4640Sstevel@tonic-gate 				 */
4650Sstevel@tonic-gate 				if (fablib(crle, CRLE_ESLIB) != 0)
4660Sstevel@tonic-gate 					return (1);
4670Sstevel@tonic-gate 			}
4680Sstevel@tonic-gate 		} else {
4690Sstevel@tonic-gate 			/*
4700Sstevel@tonic-gate 			 * Indicate any system default.
4710Sstevel@tonic-gate 			 */
4720Sstevel@tonic-gate 			if (crle->c_class == ELFCLASS64) {
4730Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
4740Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_NEWTD_64));
4750Sstevel@tonic-gate #else
4760Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_OLDTD_64));
4770Sstevel@tonic-gate #endif
4780Sstevel@tonic-gate 			} else {
4790Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
4800Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_NEWTD));
4810Sstevel@tonic-gate #else
4820Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_OLDTD));
4830Sstevel@tonic-gate #endif
4840Sstevel@tonic-gate 			}
4850Sstevel@tonic-gate 		}
4860Sstevel@tonic-gate 	}
4870Sstevel@tonic-gate 
4880Sstevel@tonic-gate 	if (head->ch_adlibpath) {
4890Sstevel@tonic-gate 		const char	*str;
4900Sstevel@tonic-gate 
4910Sstevel@tonic-gate 		str = (const char *)(head->ch_adlibpath + addr);
4920Sstevel@tonic-gate 
4930Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
4940Sstevel@tonic-gate 			crle->c_flags |= CRLE_AOUT;
4950Sstevel@tonic-gate 			if (addlib(crle, &crle->c_adlibpath, str) != 0)
4960Sstevel@tonic-gate 				return (1);
4970Sstevel@tonic-gate 		} else {
4980Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DMP_DLIBPTH),
4990Sstevel@tonic-gate 			    MSG_ORIG(MSG_STR_AOUT), str);
5000Sstevel@tonic-gate 
5010Sstevel@tonic-gate 			(void) snprintf(_cmd, PATH_MAX,
5020Sstevel@tonic-gate 			    MSG_ORIG(MSG_CMD_ADLIB), str);
5030Sstevel@tonic-gate 			cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
5040Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
5050Sstevel@tonic-gate 				return (1);
5060Sstevel@tonic-gate 		}
5070Sstevel@tonic-gate 	} else {
5080Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
5090Sstevel@tonic-gate 			if (crle->c_flags & CRLE_ADLIB) {
5100Sstevel@tonic-gate 				/*
5110Sstevel@tonic-gate 				 * If we've been asked to update a configuration
5120Sstevel@tonic-gate 				 * file, and no existing default AOUT search
5130Sstevel@tonic-gate 				 * path exists, but the user is going to add new
5140Sstevel@tonic-gate 				 * entries, fabricate the system defaults so
5150Sstevel@tonic-gate 				 * that the users get added to them.
5160Sstevel@tonic-gate 				 */
5170Sstevel@tonic-gate 				if (fablib(crle, CRLE_ADLIB) != 0)
5180Sstevel@tonic-gate 					return (1);
5190Sstevel@tonic-gate 			}
5200Sstevel@tonic-gate 		} else if (crle->c_flags & CRLE_AOUT) {
5210Sstevel@tonic-gate 			/*
5220Sstevel@tonic-gate 			 * Indicate any system default.
5230Sstevel@tonic-gate 			 */
5240Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DEF_AOUTDLP));
5250Sstevel@tonic-gate 		}
5260Sstevel@tonic-gate 	}
5270Sstevel@tonic-gate 
5280Sstevel@tonic-gate 	if (head->ch_aslibpath) {
5290Sstevel@tonic-gate 		const char	*str;
5300Sstevel@tonic-gate 
5310Sstevel@tonic-gate 		str = (const char *)(head->ch_aslibpath + addr);
5320Sstevel@tonic-gate 
5330Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
5340Sstevel@tonic-gate 			crle->c_flags |= CRLE_AOUT;
5350Sstevel@tonic-gate 			if (addlib(crle, &crle->c_aslibpath, str) != 0)
5360Sstevel@tonic-gate 				return (1);
5370Sstevel@tonic-gate 		} else {
5380Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DMP_TLIBPTH),
5390Sstevel@tonic-gate 			    MSG_ORIG(MSG_STR_AOUT), str);
5400Sstevel@tonic-gate 
5410Sstevel@tonic-gate 			(void) snprintf(_cmd, PATH_MAX,
5420Sstevel@tonic-gate 			    MSG_ORIG(MSG_CMD_ASLIB), str);
5430Sstevel@tonic-gate 			cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
5440Sstevel@tonic-gate 			if (list_append(&cmdline, cmd) == 0)
5450Sstevel@tonic-gate 				return (1);
5460Sstevel@tonic-gate 		}
5470Sstevel@tonic-gate 	} else {
5480Sstevel@tonic-gate 		if (crle->c_flags & CRLE_UPDATE) {
5490Sstevel@tonic-gate 			if (crle->c_flags & CRLE_ASLIB) {
5500Sstevel@tonic-gate 				/*
5510Sstevel@tonic-gate 				 * If we've been asked to update a configuration
5520Sstevel@tonic-gate 				 * file, and no existing default AOUT secure
5530Sstevel@tonic-gate 				 * path exists, but the user is going to add new
5540Sstevel@tonic-gate 				 * entries, fabricate the system defaults so
5550Sstevel@tonic-gate 				 * that the users get added to them.
5560Sstevel@tonic-gate 				 */
5570Sstevel@tonic-gate 				if (fablib(crle, CRLE_ASLIB) != 0)
5580Sstevel@tonic-gate 					return (1);
5590Sstevel@tonic-gate 			}
5600Sstevel@tonic-gate 		} else if (crle->c_flags & CRLE_AOUT) {
5610Sstevel@tonic-gate 			/*
5620Sstevel@tonic-gate 			 * Indicate any system default.
5630Sstevel@tonic-gate 			 */
5640Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DEF_AOUTTD));
5650Sstevel@tonic-gate 		}
5660Sstevel@tonic-gate 	}
5670Sstevel@tonic-gate 
5680Sstevel@tonic-gate 	/*
5690Sstevel@tonic-gate 	 * Display any environment variables.
5700Sstevel@tonic-gate 	 */
5710Sstevel@tonic-gate 	if ((head->ch_version >= RTC_VER_THREE) && head->ch_env) {
5720Sstevel@tonic-gate 		Rtc_env *	envtbl;
5730Sstevel@tonic-gate 
5740Sstevel@tonic-gate 		if ((crle->c_flags & CRLE_UPDATE) == 0)
5750Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_ENV_TITLE));
5760Sstevel@tonic-gate 
5770Sstevel@tonic-gate 		for (envtbl = (Rtc_env *)(head->ch_env + addr);
5780Sstevel@tonic-gate 		    envtbl->env_str; envtbl++) {
5790Sstevel@tonic-gate 			const char	*str;
5800Sstevel@tonic-gate 
5810Sstevel@tonic-gate 			str = (const char *)(envtbl->env_str + addr);
5820Sstevel@tonic-gate 
5830Sstevel@tonic-gate 			if (crle->c_flags & CRLE_UPDATE) {
5840Sstevel@tonic-gate 				if (addenv(crle, str,
5850Sstevel@tonic-gate 				    (envtbl->env_flags | RTC_ENV_CONFIG)) == 0)
5860Sstevel@tonic-gate 					return (1);
5870Sstevel@tonic-gate 			} else {
5880Sstevel@tonic-gate 				const char	*pfmt, *sfmt;
5890Sstevel@tonic-gate 
5900Sstevel@tonic-gate 				if (envtbl->env_flags & RTC_ENV_PERMANT) {
5910Sstevel@tonic-gate 					pfmt = MSG_INTL(MSG_ENV_PRM);
5920Sstevel@tonic-gate 					sfmt = MSG_ORIG(MSG_CMD_PRMENV);
5930Sstevel@tonic-gate 				} else {
5940Sstevel@tonic-gate 					pfmt = MSG_INTL(MSG_ENV_RPL);
5950Sstevel@tonic-gate 					sfmt = MSG_ORIG(MSG_CMD_RPLENV);
5960Sstevel@tonic-gate 				}
5970Sstevel@tonic-gate 				(void) printf(pfmt, str);
5980Sstevel@tonic-gate 				(void) snprintf(_cmd, PATH_MAX, sfmt, str);
5990Sstevel@tonic-gate 				cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
6000Sstevel@tonic-gate 				if (list_append(&cmdline, cmd) == 0)
6010Sstevel@tonic-gate 					return (1);
6020Sstevel@tonic-gate 			}
6030Sstevel@tonic-gate 		}
6040Sstevel@tonic-gate 	}
6050Sstevel@tonic-gate 
6060Sstevel@tonic-gate 	/*
6070Sstevel@tonic-gate 	 * Display any filter/filtee associations.
6080Sstevel@tonic-gate 	 */
6090Sstevel@tonic-gate 	if ((head->ch_version >= RTC_VER_FOUR) && head->ch_fltr) {
6100Sstevel@tonic-gate 		if ((crle->c_flags & CRLE_UPDATE) == 0) {
6110Sstevel@tonic-gate 			Rtc_fltr *	fltrtbl;
6120Sstevel@tonic-gate 			Rtc_flte *	fltetbl;
6130Sstevel@tonic-gate 
6140Sstevel@tonic-gate 			/* LINTED */
6150Sstevel@tonic-gate 			fltrtbl = (Rtc_fltr *)((char *)head->ch_fltr + addr);
6160Sstevel@tonic-gate 			/* LINTED */
6170Sstevel@tonic-gate 			fltetbl = (Rtc_flte *)((char *)head->ch_flte + addr);
6180Sstevel@tonic-gate 
6190Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_FLT_TITLE));
6200Sstevel@tonic-gate 
6210Sstevel@tonic-gate 			while (fltrtbl->fr_filter) {
6220Sstevel@tonic-gate 				Rtc_flte	*_fltetbl;
6230Sstevel@tonic-gate 
6240Sstevel@tonic-gate 				/*
6250Sstevel@tonic-gate 				 * Print the filter and filtee string pair.
6260Sstevel@tonic-gate 				 */
6270Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_FLT_FILTER),
6280Sstevel@tonic-gate 				    (strtbl + fltrtbl->fr_filter),
6290Sstevel@tonic-gate 				    (strtbl + fltrtbl->fr_string));
6300Sstevel@tonic-gate 
6310Sstevel@tonic-gate 				/*
6320Sstevel@tonic-gate 				 * Print each filtee.
6330Sstevel@tonic-gate 				 */
6340Sstevel@tonic-gate 				/* LINTED */
6350Sstevel@tonic-gate 				for (_fltetbl = (Rtc_flte *)((char *)fltetbl +
6360Sstevel@tonic-gate 				    fltrtbl->fr_filtee); _fltetbl->fe_filtee;
6370Sstevel@tonic-gate 				    _fltetbl++) {
6380Sstevel@tonic-gate 					(void) printf(MSG_INTL(MSG_FLT_FILTEE),
6390Sstevel@tonic-gate 					    (strtbl + _fltetbl->fe_filtee));
6400Sstevel@tonic-gate 				}
6410Sstevel@tonic-gate 				fltrtbl++;
6420Sstevel@tonic-gate 			}
6430Sstevel@tonic-gate 		}
6440Sstevel@tonic-gate 	}
6450Sstevel@tonic-gate 
6460Sstevel@tonic-gate 	/*
6470Sstevel@tonic-gate 	 * Display any memory reservations required for any alternative
6480Sstevel@tonic-gate 	 * objects.
6490Sstevel@tonic-gate 	 */
6500Sstevel@tonic-gate 	if (head->ch_resbgn && ((crle->c_flags & CRLE_UPDATE) == 0))
6510Sstevel@tonic-gate 		(void) printf(MSG_INTL(MSG_DMP_RESV), head->ch_resbgn,
6520Sstevel@tonic-gate 		    head->ch_resend, (head->ch_resend - head->ch_resbgn));
6530Sstevel@tonic-gate 
6540Sstevel@tonic-gate 	/*
6550Sstevel@tonic-gate 	 * If there's no hash table there's nothing else to process.
6560Sstevel@tonic-gate 	 */
6570Sstevel@tonic-gate 	if (head->ch_hash == 0) {
6580Sstevel@tonic-gate 		if ((crle->c_flags & CRLE_UPDATE) == 0)
6590Sstevel@tonic-gate 			printcmd(crle, head, &cmdline);
6600Sstevel@tonic-gate 		return (0);
6610Sstevel@tonic-gate 	}
6620Sstevel@tonic-gate 
6630Sstevel@tonic-gate 	/*
6640Sstevel@tonic-gate 	 * Traverse the directory and filename arrays.
6650Sstevel@tonic-gate 	 */
6660Sstevel@tonic-gate 	for (dirtbl = (Rtc_dir *)(head->ch_dir + addr);
6670Sstevel@tonic-gate 	    dirtbl->cd_obj; dirtbl++) {
6680Sstevel@tonic-gate 		struct stat	status;
6690Sstevel@tonic-gate 		Rtc_obj		*dobj;
6700Sstevel@tonic-gate 		const char	*str;
6710Sstevel@tonic-gate 
6720Sstevel@tonic-gate 		dobj = (Rtc_obj *)(dirtbl->cd_obj + addr);
6730Sstevel@tonic-gate 		filetbl = (Rtc_file *)(dirtbl->cd_file + addr);
6740Sstevel@tonic-gate 		str = strtbl + dobj->co_name;
6750Sstevel@tonic-gate 
6760Sstevel@tonic-gate 		/*
6770Sstevel@tonic-gate 		 * Simplify recreation by using any command-line directories.
6780Sstevel@tonic-gate 		 * If we're dealing with a version 1 configuration file use
6790Sstevel@tonic-gate 		 * every directory.
6800Sstevel@tonic-gate 		 */
6810Sstevel@tonic-gate 		if ((dobj->co_flags & RTC_OBJ_CMDLINE) ||
6820Sstevel@tonic-gate 		    (head->ch_version == RTC_VER_ONE)) {
6830Sstevel@tonic-gate 			if (crle->c_flags & CRLE_UPDATE) {
6840Sstevel@tonic-gate 				if (inspect(crle, str,
6850Sstevel@tonic-gate 				    getflags(dobj->co_flags)) != 0)
6860Sstevel@tonic-gate 					return (1);
6870Sstevel@tonic-gate 				if ((dobj->co_flags &
6880Sstevel@tonic-gate 				    (RTC_OBJ_NOEXIST | RTC_OBJ_ALTER)) ==
6890Sstevel@tonic-gate 				    RTC_OBJ_NOEXIST)
6900Sstevel@tonic-gate 					continue;
6910Sstevel@tonic-gate 			} else {
6920Sstevel@tonic-gate 				/* LINTED */
6930Sstevel@tonic-gate 				(void) snprintf(_cmd, PATH_MAX,
6940Sstevel@tonic-gate 				    getformat(dobj->co_flags), str);
6950Sstevel@tonic-gate 				cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
6960Sstevel@tonic-gate 				if (list_append(&cmdline, cmd) == 0)
6970Sstevel@tonic-gate 					return (1);
6980Sstevel@tonic-gate 			}
6990Sstevel@tonic-gate 		}
7000Sstevel@tonic-gate 
7010Sstevel@tonic-gate 		/*
7020Sstevel@tonic-gate 		 * If this isn't an update print the directory name.  If the
7030Sstevel@tonic-gate 		 * directory has no entries (possible if the directory is a
7040Sstevel@tonic-gate 		 * symlink to another directory, in which case we record the
7050Sstevel@tonic-gate 		 * real path also), don't bother printing it unless we're in
7060Sstevel@tonic-gate 		 * verbose mode.
7070Sstevel@tonic-gate 		 */
7080Sstevel@tonic-gate 		if ((crle->c_flags & CRLE_UPDATE) == 0) {
7090Sstevel@tonic-gate 			if ((dobj->co_flags &
7100Sstevel@tonic-gate 			    (RTC_OBJ_NOEXIST | RTC_OBJ_ALTER)) ==
7110Sstevel@tonic-gate 			    RTC_OBJ_NOEXIST) {
7120Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DMP_DIR_2), str);
7130Sstevel@tonic-gate 				continue;
7140Sstevel@tonic-gate 			} else if (filetbl->cf_obj ||
7150Sstevel@tonic-gate 			    (crle->c_flags & CRLE_VERBOSE))
7160Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DMP_DIR_1), str);
7170Sstevel@tonic-gate 		}
7180Sstevel@tonic-gate 
7190Sstevel@tonic-gate 		/*
7200Sstevel@tonic-gate 		 * Under verbose mode validate any real directory entry - the
7210Sstevel@tonic-gate 		 * same test will be carried out by ld.so.1.
7220Sstevel@tonic-gate 		 */
7230Sstevel@tonic-gate 		if (((crle->c_flags & CRLE_UPDATE) == 0) &&
7240Sstevel@tonic-gate 		    (crle->c_flags & CRLE_VERBOSE) &&
7250Sstevel@tonic-gate 		    (dobj->co_flags & RTC_OBJ_REALPTH)) {
7260Sstevel@tonic-gate 			if (stat(str, &status) != 0) {
7270Sstevel@tonic-gate 				int err = errno;
7280Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DMP_STAT), str,
7290Sstevel@tonic-gate 				    strerror(err));
7300Sstevel@tonic-gate 			} else if (status.st_mtime != dobj->co_info) {
7310Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DMP_DCMP), str);
7320Sstevel@tonic-gate 			}
7330Sstevel@tonic-gate 		}
7340Sstevel@tonic-gate 
7350Sstevel@tonic-gate 		for (; filetbl->cf_obj; filetbl++) {
7360Sstevel@tonic-gate 			Rtc_obj *	fobj;
7370Sstevel@tonic-gate 			Half		flags;
7380Sstevel@tonic-gate 
7390Sstevel@tonic-gate 			fobj = (Rtc_obj *)(filetbl->cf_obj + addr);
7400Sstevel@tonic-gate 			str = strtbl + fobj->co_name;
7410Sstevel@tonic-gate 			flags = fobj->co_flags;
7420Sstevel@tonic-gate 
7430Sstevel@tonic-gate 			/*
7440Sstevel@tonic-gate 			 * Only update individual files that were originally
7450Sstevel@tonic-gate 			 * specified on the command-line.  Or, if this is a
7460Sstevel@tonic-gate 			 * version 1 configuration file use every file that
7470Sstevel@tonic-gate 			 * isn't part of an all-entries directory.
7480Sstevel@tonic-gate 			 */
7490Sstevel@tonic-gate 			if (((flags & RTC_OBJ_CMDLINE) &&
7500Sstevel@tonic-gate 			    ((fobj->co_flags & RTC_OBJ_APP) == 0)) ||
7510Sstevel@tonic-gate 			    ((head->ch_version == RTC_VER_ONE) &&
7520Sstevel@tonic-gate 			    ((dobj->co_flags & RTC_OBJ_ALLENTS) == 0))) {
7530Sstevel@tonic-gate 				char	*alter = 0, altdir[PATH_MAX];
7540Sstevel@tonic-gate 
7550Sstevel@tonic-gate 				/*
7560Sstevel@tonic-gate 				 * Determine whether this file requires an
7570Sstevel@tonic-gate 				 * alternative, and if so, and we haven't
7580Sstevel@tonic-gate 				 * already an alternative in affect, create one.
7590Sstevel@tonic-gate 				 */
7600Sstevel@tonic-gate 				if (fobj->co_flags & RTC_OBJ_ALTER) {
7610Sstevel@tonic-gate 					alter = (char *)(strtbl +
7620Sstevel@tonic-gate 					    fobj->co_alter);
7630Sstevel@tonic-gate 					(void) strcpy(altdir, alter);
7640Sstevel@tonic-gate 					alter = strrchr(altdir, '/');
7650Sstevel@tonic-gate 					*alter = '\0';
7660Sstevel@tonic-gate 
7670Sstevel@tonic-gate 					if ((objdir == 0) ||
7680Sstevel@tonic-gate 					    (strcmp(objdir, altdir) != 0)) {
7690Sstevel@tonic-gate 						(void) strcpy(_objdir, altdir);
7700Sstevel@tonic-gate 						crle->c_objdir = alter =
7710Sstevel@tonic-gate 						    objdir = _objdir;
7720Sstevel@tonic-gate 					} else
7730Sstevel@tonic-gate 						alter = 0;
7740Sstevel@tonic-gate 				}
7750Sstevel@tonic-gate 
7760Sstevel@tonic-gate 				if (crle->c_flags & CRLE_UPDATE) {
7770Sstevel@tonic-gate 					if (inspect(crle, str,
7780Sstevel@tonic-gate 					    getflags(flags)) != 0)
7790Sstevel@tonic-gate 						return (1);
7800Sstevel@tonic-gate 					continue;
7810Sstevel@tonic-gate 				}
7820Sstevel@tonic-gate 
7830Sstevel@tonic-gate 				if (alter) {
7840Sstevel@tonic-gate 					(void) snprintf(_cmd, PATH_MAX,
7850Sstevel@tonic-gate 					    MSG_ORIG(MSG_CMD_OUTPUT),
7860Sstevel@tonic-gate 					    crle->c_objdir);
7870Sstevel@tonic-gate 					cmd = strcpy(alloca(strlen(_cmd) + 1),
7880Sstevel@tonic-gate 					    _cmd);
7890Sstevel@tonic-gate 					if (list_append(&cmdline, cmd) == 0)
7900Sstevel@tonic-gate 						return (1);
7910Sstevel@tonic-gate 				}
7920Sstevel@tonic-gate 
7930Sstevel@tonic-gate 				/* LINTED */
7940Sstevel@tonic-gate 				(void) snprintf(_cmd, PATH_MAX,
7950Sstevel@tonic-gate 				    getformat(flags), str);
7960Sstevel@tonic-gate 				cmd = strcpy(alloca(strlen(_cmd) + 1), _cmd);
7970Sstevel@tonic-gate 				if (list_append(&cmdline, cmd) == 0)
7980Sstevel@tonic-gate 					return (1);
7990Sstevel@tonic-gate 			}
8000Sstevel@tonic-gate 
8010Sstevel@tonic-gate 			if (crle->c_flags & CRLE_UPDATE)
8020Sstevel@tonic-gate 				continue;
8030Sstevel@tonic-gate 
8040Sstevel@tonic-gate 			/*
8050Sstevel@tonic-gate 			 * Although we record both full pathnames and their
8060Sstevel@tonic-gate 			 * simple filenames (basename), only print the simple
8070Sstevel@tonic-gate 			 * names unless we're under verbose mode.
8080Sstevel@tonic-gate 			 */
8090Sstevel@tonic-gate 			if ((strchr(str, '/') == 0) ||
8100Sstevel@tonic-gate 			    (crle->c_flags & CRLE_VERBOSE)) {
8110Sstevel@tonic-gate 				if (fobj->co_flags & RTC_OBJ_ALTER)
8120Sstevel@tonic-gate 					(void) printf(MSG_INTL(MSG_DMP_FILE_2),
8130Sstevel@tonic-gate 					    str, (strtbl + fobj->co_alter));
8140Sstevel@tonic-gate 				else
8150Sstevel@tonic-gate 					(void) printf(MSG_INTL(MSG_DMP_FILE_1),
8160Sstevel@tonic-gate 					    str);
8170Sstevel@tonic-gate 			}
8180Sstevel@tonic-gate 
8190Sstevel@tonic-gate 			/*
8200Sstevel@tonic-gate 			 * Under verbose mode validate any real file entry - the
8210Sstevel@tonic-gate 			 * same test will be carried out by ld.so.1.
8220Sstevel@tonic-gate 			 */
8230Sstevel@tonic-gate 			if ((crle->c_flags & CRLE_VERBOSE) &&
8240Sstevel@tonic-gate 			    (fobj->co_flags & RTC_OBJ_REALPTH)) {
8250Sstevel@tonic-gate 				if (stat(str, &status) != 0) {
8260Sstevel@tonic-gate 					int err = errno;
8270Sstevel@tonic-gate 					(void) printf(MSG_INTL(MSG_DMP_STAT),
8280Sstevel@tonic-gate 					    str, strerror(err));
8290Sstevel@tonic-gate 				} else if (status.st_size != fobj->co_info) {
8300Sstevel@tonic-gate 					(void) printf(MSG_INTL(MSG_DMP_FCMP),
8310Sstevel@tonic-gate 					    str);
8320Sstevel@tonic-gate 				}
8330Sstevel@tonic-gate 			}
8340Sstevel@tonic-gate 		}
8350Sstevel@tonic-gate 	}
8360Sstevel@tonic-gate 
8370Sstevel@tonic-gate 	if ((crle->c_flags & CRLE_UPDATE) == 0)
8380Sstevel@tonic-gate 		printcmd(crle, head, &cmdline);
8390Sstevel@tonic-gate 
8400Sstevel@tonic-gate 	if ((crle->c_flags & CRLE_VERBOSE) == 0)
8410Sstevel@tonic-gate 		return (0);
8420Sstevel@tonic-gate 
8430Sstevel@tonic-gate 	/*
8440Sstevel@tonic-gate 	 * If we've in verbose mode scan the hash list.
8450Sstevel@tonic-gate 	 */
8460Sstevel@tonic-gate 	/* LINTED */
8470Sstevel@tonic-gate 	hash = (Word *)((char *)head->ch_hash + addr);
8480Sstevel@tonic-gate 	bkts = hash[0];
8490Sstevel@tonic-gate 	chain = &hash[2 + bkts];
8500Sstevel@tonic-gate 	hash += 2;
8510Sstevel@tonic-gate 
8520Sstevel@tonic-gate 	(void) printf(MSG_INTL(MSG_DMP_HASH));
8530Sstevel@tonic-gate 
8540Sstevel@tonic-gate 	/*
8550Sstevel@tonic-gate 	 * Scan the hash buckets looking for valid entries.
8560Sstevel@tonic-gate 	 */
8570Sstevel@tonic-gate 	for (ndx = 0; ndx < bkts; ndx++, hash++) {
8580Sstevel@tonic-gate 		Rtc_obj		*obj;
8590Sstevel@tonic-gate 		const char	*str;
8600Sstevel@tonic-gate 		Word		_ndx;
8610Sstevel@tonic-gate 
8620Sstevel@tonic-gate 		if (*hash == 0)
8630Sstevel@tonic-gate 			continue;
8640Sstevel@tonic-gate 
8650Sstevel@tonic-gate 		obj = objtbl + *hash;
8660Sstevel@tonic-gate 		str = strtbl + obj->co_name;
8670Sstevel@tonic-gate 
8680Sstevel@tonic-gate 		(void) printf(MSG_INTL(MSG_DMP_HASHENT_1), obj->co_id, ndx,
8690Sstevel@tonic-gate 			str, conv_config_obj(obj->co_flags));
8700Sstevel@tonic-gate 
8710Sstevel@tonic-gate 		/*
8720Sstevel@tonic-gate 		 * Determine whether there are other objects chained to this
8730Sstevel@tonic-gate 		 * bucket.
8740Sstevel@tonic-gate 		 */
8750Sstevel@tonic-gate 		for (_ndx = chain[*hash]; _ndx; _ndx = chain[_ndx]) {
8760Sstevel@tonic-gate 			obj = objtbl + _ndx;
8770Sstevel@tonic-gate 			str = strtbl + obj->co_name;
8780Sstevel@tonic-gate 
8790Sstevel@tonic-gate 			(void) printf(MSG_INTL(MSG_DMP_HASHENT_2), obj->co_id,
8800Sstevel@tonic-gate 			    str, conv_config_obj(obj->co_flags));
8810Sstevel@tonic-gate 		}
8820Sstevel@tonic-gate 	}
8830Sstevel@tonic-gate 	(void) printf(MSG_ORIG(MSG_STR_NL));
8840Sstevel@tonic-gate 
8850Sstevel@tonic-gate 	return (0);
8860Sstevel@tonic-gate }
8870Sstevel@tonic-gate 
8880Sstevel@tonic-gate 
8890Sstevel@tonic-gate int
8900Sstevel@tonic-gate inspectconfig(Crle_desc * crle)
8910Sstevel@tonic-gate {
8920Sstevel@tonic-gate 	int		error, fd;
8930Sstevel@tonic-gate 	Addr		addr;
8940Sstevel@tonic-gate 	struct stat	status;
8950Sstevel@tonic-gate 	const char	*caller = crle->c_name, *file = crle->c_confil;
8960Sstevel@tonic-gate 
8970Sstevel@tonic-gate 	/*
8980Sstevel@tonic-gate 	 * Open the configuration file, determine its size and map it in.
8990Sstevel@tonic-gate 	 */
9000Sstevel@tonic-gate 	if ((fd = open(file, O_RDONLY, 0)) == -1) {
9010Sstevel@tonic-gate 		int	err = errno;
9020Sstevel@tonic-gate 
9030Sstevel@tonic-gate 		if ((err == ENOENT)) {
9040Sstevel@tonic-gate 			/*
9050Sstevel@tonic-gate 			 * To allow an update (-u) from scratch, fabricate any
9060Sstevel@tonic-gate 			 * default search and secure paths that the user
9070Sstevel@tonic-gate 			 * intends to add to.
9080Sstevel@tonic-gate 			 */
9090Sstevel@tonic-gate 			if (crle->c_flags & CRLE_UPDATE) {
9100Sstevel@tonic-gate 				if (crle->c_flags & CRLE_EDLIB) {
9110Sstevel@tonic-gate 					if (fablib(crle, CRLE_EDLIB))
9120Sstevel@tonic-gate 						return (1);
9130Sstevel@tonic-gate 				}
9140Sstevel@tonic-gate 				if (crle->c_flags & CRLE_ESLIB) {
9150Sstevel@tonic-gate 					if (fablib(crle, CRLE_ESLIB))
9160Sstevel@tonic-gate 						return (1);
9170Sstevel@tonic-gate 				}
9180Sstevel@tonic-gate 				if (crle->c_flags & CRLE_ADLIB) {
9190Sstevel@tonic-gate 					if (fablib(crle, CRLE_ADLIB))
9200Sstevel@tonic-gate 						return (1);
9210Sstevel@tonic-gate 				}
9220Sstevel@tonic-gate 				if (crle->c_flags & CRLE_ASLIB) {
9230Sstevel@tonic-gate 					if (fablib(crle, CRLE_ASLIB))
9240Sstevel@tonic-gate 						return (1);
9250Sstevel@tonic-gate 				}
9260Sstevel@tonic-gate 				return (0);
9270Sstevel@tonic-gate 
9280Sstevel@tonic-gate 			} else if (crle->c_flags & CRLE_CONFDEF) {
9290Sstevel@tonic-gate 				const char	*fmt1, *fmt2;
9300Sstevel@tonic-gate 
9310Sstevel@tonic-gate 				/*
9320Sstevel@tonic-gate 				 * Otherwise if the user is inspecting a default
9330Sstevel@tonic-gate 				 * configuration file that doesn't exist inform
9340Sstevel@tonic-gate 				 * them and display the ELF defaults.
9350Sstevel@tonic-gate 				 */
9360Sstevel@tonic-gate 				(void) printf(MSG_INTL(MSG_DEF_NOCONF), file);
9370Sstevel@tonic-gate 
9380Sstevel@tonic-gate 				if (crle->c_flags & CRLE_AOUT) {
9390Sstevel@tonic-gate 					fmt1 = MSG_INTL(MSG_DEF_AOUTDLP);
9400Sstevel@tonic-gate 					fmt2 = MSG_INTL(MSG_DEF_AOUTTD);
9410Sstevel@tonic-gate 				} else {
9420Sstevel@tonic-gate 					if (crle->c_class == ELFCLASS64) {
9430Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
9440Sstevel@tonic-gate 					    fmt1 = MSG_INTL(MSG_DEF_NEWDLP_64);
9450Sstevel@tonic-gate 					    fmt2 = MSG_INTL(MSG_DEF_NEWTD_64);
9460Sstevel@tonic-gate #else
9470Sstevel@tonic-gate 					    fmt1 = MSG_INTL(MSG_DEF_OLDDLP_64);
9480Sstevel@tonic-gate 					    fmt2 = MSG_INTL(MSG_DEF_OLDTD_64);
9490Sstevel@tonic-gate #endif
9500Sstevel@tonic-gate 					} else {
9510Sstevel@tonic-gate #ifndef	SGS_PRE_UNIFIED_PROCESS
9520Sstevel@tonic-gate 					    fmt1 = MSG_INTL(MSG_DEF_NEWDLP);
9530Sstevel@tonic-gate 					    fmt2 = MSG_INTL(MSG_DEF_NEWTD);
9540Sstevel@tonic-gate #else
9550Sstevel@tonic-gate 					    fmt1 = MSG_INTL(MSG_DEF_OLDDLP);
9560Sstevel@tonic-gate 					    fmt2 = MSG_INTL(MSG_DEF_OLDTD);
9570Sstevel@tonic-gate #endif
9580Sstevel@tonic-gate 					}
9590Sstevel@tonic-gate 				}
9600Sstevel@tonic-gate 				(void) printf(fmt1);
9610Sstevel@tonic-gate 				(void) printf(fmt2);
9620Sstevel@tonic-gate 
9630Sstevel@tonic-gate 				return (0);
9640Sstevel@tonic-gate 			}
9650Sstevel@tonic-gate 		}
9660Sstevel@tonic-gate 
9670Sstevel@tonic-gate 		/*
9680Sstevel@tonic-gate 		 * Otherwise there's an error condition in accessing the file.
9690Sstevel@tonic-gate 		 */
9700Sstevel@tonic-gate 		(void) fprintf(stderr, MSG_INTL(MSG_SYS_OPEN), caller, file,
9710Sstevel@tonic-gate 		    strerror(err));
9720Sstevel@tonic-gate 
9730Sstevel@tonic-gate 		return (1);
9740Sstevel@tonic-gate 	}
9750Sstevel@tonic-gate 
9760Sstevel@tonic-gate 	(void) fstat(fd, &status);
9770Sstevel@tonic-gate 	if (status.st_size < sizeof (Rtc_head)) {
9780Sstevel@tonic-gate 		(void) close(fd);
9790Sstevel@tonic-gate 		(void) fprintf(stderr, MSG_INTL(MSG_COR_TRUNC), caller, file);
9800Sstevel@tonic-gate 		return (1);
9810Sstevel@tonic-gate 	}
9820Sstevel@tonic-gate 	if ((addr = (Addr)mmap(0, status.st_size, PROT_READ, MAP_SHARED,
9830Sstevel@tonic-gate 	    fd, 0)) == (Addr)MAP_FAILED) {
9840Sstevel@tonic-gate 		int err = errno;
9850Sstevel@tonic-gate 		(void) fprintf(stderr, MSG_INTL(MSG_SYS_MMAP), caller, file,
9860Sstevel@tonic-gate 		    strerror(err));
9870Sstevel@tonic-gate 		(void) close(fd);
9880Sstevel@tonic-gate 		return (1);
9890Sstevel@tonic-gate 	}
9900Sstevel@tonic-gate 	(void) close(fd);
9910Sstevel@tonic-gate 
9920Sstevel@tonic-gate 	/*
9930Sstevel@tonic-gate 	 * Print the contents of the configuration file.
9940Sstevel@tonic-gate 	 */
9950Sstevel@tonic-gate 	error = scanconfig(crle, addr);
9960Sstevel@tonic-gate 
9970Sstevel@tonic-gate 	(void) munmap((void *)addr, status.st_size);
9980Sstevel@tonic-gate 	return (error);
9990Sstevel@tonic-gate }
1000