17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55aefb655Srie * Common Development and Distribution License (the "License"). 65aefb655Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 215aefb655Srie 227c478bd9Sstevel@tonic-gate /* 23*23a1cceaSRoger A. Faulkner * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #include <sys/types.h> 277c478bd9Sstevel@tonic-gate #include <sys/stat.h> 287c478bd9Sstevel@tonic-gate #include <sys/mman.h> 297c478bd9Sstevel@tonic-gate #include <fcntl.h> 307c478bd9Sstevel@tonic-gate #include <stdio.h> 317c478bd9Sstevel@tonic-gate #include <string.h> 327c478bd9Sstevel@tonic-gate #include <unistd.h> 337c478bd9Sstevel@tonic-gate #include <errno.h> 347c478bd9Sstevel@tonic-gate #include <limits.h> 357c478bd9Sstevel@tonic-gate #include "sgs.h" 367c478bd9Sstevel@tonic-gate #include "rtc.h" 377c478bd9Sstevel@tonic-gate #include "conv.h" 387c478bd9Sstevel@tonic-gate #include "_crle.h" 397c478bd9Sstevel@tonic-gate #include "msg.h" 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Display the command line required to regenerate the configuration file. 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * Under normal mode the command is printed on one line to make it more 467c478bd9Sstevel@tonic-gate * available for grep(1) use. Under verbose mode the command is separated 477c478bd9Sstevel@tonic-gate * into each argument (a little more readable perhaps when the arguments are 487c478bd9Sstevel@tonic-gate * numerous of have long pathnames). 497c478bd9Sstevel@tonic-gate * 507c478bd9Sstevel@tonic-gate * Note that for version 1 configuration files we never used to generate any 517c478bd9Sstevel@tonic-gate * command-line information, and as the attempt to do so is only a best effort 527c478bd9Sstevel@tonic-gate * don't bother printing anything. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate static void 5557ef7aa9SRod Evans printcmd(Crle_desc *crle, Rtc_head * head, APlist *cmdline) 567c478bd9Sstevel@tonic-gate { 5757ef7aa9SRod Evans Aliste idx, lidx; 587c478bd9Sstevel@tonic-gate const char *fmto, *fmtb, *fmtm, *fmte; 597c478bd9Sstevel@tonic-gate char *cmd; 607c478bd9Sstevel@tonic-gate int output = 0; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_VERBOSE) { 637c478bd9Sstevel@tonic-gate fmto = MSG_INTL(MSG_DMP_CMD_ONE_V); 647c478bd9Sstevel@tonic-gate fmtb = MSG_INTL(MSG_DMP_CMD_BGN_V); 657c478bd9Sstevel@tonic-gate fmtm = MSG_INTL(MSG_DMP_CMD_MID_V); 667c478bd9Sstevel@tonic-gate fmte = MSG_INTL(MSG_DMP_CMD_END_V); 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate } else if (head->ch_version > RTC_VER_ONE) { 697c478bd9Sstevel@tonic-gate fmto = MSG_INTL(MSG_DMP_CMD_ONE); 707c478bd9Sstevel@tonic-gate fmtb = MSG_INTL(MSG_DMP_CMD_BGN); 717c478bd9Sstevel@tonic-gate fmtm = MSG_INTL(MSG_DMP_CMD_MID); 727c478bd9Sstevel@tonic-gate fmte = MSG_INTL(MSG_DMP_CMD_END); 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate } else { 757c478bd9Sstevel@tonic-gate (void) printf(MSG_ORIG(MSG_STR_NL)); 767c478bd9Sstevel@tonic-gate return; 777c478bd9Sstevel@tonic-gate } 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_CMD_TITLE)); 8057ef7aa9SRod Evans 8157ef7aa9SRod Evans lidx = aplist_nitems(cmdline) - 1; 8257ef7aa9SRod Evans for (APLIST_TRAVERSE(cmdline, idx, cmd)) { 837c478bd9Sstevel@tonic-gate if (output++ == 0) { 8457ef7aa9SRod Evans if (idx < lidx) 857c478bd9Sstevel@tonic-gate (void) printf(fmtb, cmd); 867c478bd9Sstevel@tonic-gate else 877c478bd9Sstevel@tonic-gate (void) printf(fmto, cmd); 887c478bd9Sstevel@tonic-gate } else { 8957ef7aa9SRod Evans if (idx < lidx) 907c478bd9Sstevel@tonic-gate (void) printf(fmtm, cmd); 917c478bd9Sstevel@tonic-gate else 927c478bd9Sstevel@tonic-gate (void) printf(fmte, cmd); 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate } 957c478bd9Sstevel@tonic-gate } 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Establish the argument required to generate the associated object. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate static const char * 1017c478bd9Sstevel@tonic-gate getformat(Half flags) 1027c478bd9Sstevel@tonic-gate { 1037c478bd9Sstevel@tonic-gate if (flags & RTC_OBJ_ALTER) { 1047c478bd9Sstevel@tonic-gate if (flags & RTC_OBJ_DUMP) { 1057c478bd9Sstevel@tonic-gate if (flags & RTC_OBJ_GROUP) 1067c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_CMD_DUMPGRP)); 1077c478bd9Sstevel@tonic-gate else 1087c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_CMD_DUMPIND)); 1097c478bd9Sstevel@tonic-gate } else { 1107c478bd9Sstevel@tonic-gate if (flags & RTC_OBJ_OPTINAL) 1117c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_CMD_OPTIONAL)); 1127c478bd9Sstevel@tonic-gate else 1137c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_CMD_ALTER)); 1147c478bd9Sstevel@tonic-gate } 1157c478bd9Sstevel@tonic-gate } else { 1167c478bd9Sstevel@tonic-gate if (flags & RTC_OBJ_GROUP) 1177c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_CMD_GRP)); 1187c478bd9Sstevel@tonic-gate else 1197c478bd9Sstevel@tonic-gate return (MSG_ORIG(MSG_CMD_IND)); 1207c478bd9Sstevel@tonic-gate } 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * Fabricate a system default search path. If an update is requested, and 1257c478bd9Sstevel@tonic-gate * new search paths are specified while no configuration file exists, or if a 1267c478bd9Sstevel@tonic-gate * configuration file does exist but doesn't specify this particular search 1277c478bd9Sstevel@tonic-gate * path, create any system defaults. The intent is to allow 1287c478bd9Sstevel@tonic-gate * "crle -u -l/usr/local/lib" and have this append the search path to the 1297c478bd9Sstevel@tonic-gate * system default, rather than have the user have to determine and specify 1307c478bd9Sstevel@tonic-gate * this default themselves. 1317c478bd9Sstevel@tonic-gate */ 1327c478bd9Sstevel@tonic-gate static int 1337c478bd9Sstevel@tonic-gate fablib(Crle_desc * crle, int flag) 1347c478bd9Sstevel@tonic-gate { 1357c478bd9Sstevel@tonic-gate const char *path; 1367c478bd9Sstevel@tonic-gate char **list; 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate switch (flag) { 1397c478bd9Sstevel@tonic-gate case CRLE_EDLIB: 140c13de8f6Sab196087 #if M_CLASS == ELFCLASS64 1417c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 1427c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_NEWDLP_64); 1437c478bd9Sstevel@tonic-gate #else 1447c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_OLDDLP_64); 1457c478bd9Sstevel@tonic-gate #endif 146c13de8f6Sab196087 #else 1477c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 1487c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_NEWDLP); 1497c478bd9Sstevel@tonic-gate #else 1507c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_OLDDLP); 1517c478bd9Sstevel@tonic-gate #endif 152c13de8f6Sab196087 #endif 1537c478bd9Sstevel@tonic-gate list = &crle->c_edlibpath; 1547c478bd9Sstevel@tonic-gate break; 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate case CRLE_ESLIB: 157c13de8f6Sab196087 #if M_CLASS == ELFCLASS64 1587c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 1597c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_NEWTD_64); 1607c478bd9Sstevel@tonic-gate #else 1617c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_OLDTD_64); 1627c478bd9Sstevel@tonic-gate #endif 163c13de8f6Sab196087 #else 1647c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 1657c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_NEWTD); 1667c478bd9Sstevel@tonic-gate #else 1677c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_OLDTD); 1687c478bd9Sstevel@tonic-gate #endif 169c13de8f6Sab196087 #endif 1707c478bd9Sstevel@tonic-gate list = &crle->c_eslibpath; 1717c478bd9Sstevel@tonic-gate break; 1727c478bd9Sstevel@tonic-gate 1737c478bd9Sstevel@tonic-gate case CRLE_ADLIB: 1747c478bd9Sstevel@tonic-gate path = MSG_ORIG(MSG_PTH_AOUTDLP); 1757c478bd9Sstevel@tonic-gate list = &crle->c_adlibpath; 1767c478bd9Sstevel@tonic-gate break; 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate case CRLE_ASLIB: 179ba7962c0SRod Evans #ifndef SGS_PRE_UNIFIED_PROCESS 180ba7962c0SRod Evans path = MSG_ORIG(MSG_PTH_NEWTD); 181ba7962c0SRod Evans #else 182ba7962c0SRod Evans path = MSG_ORIG(MSG_PTH_OLDTD); 183ba7962c0SRod Evans #endif 1847c478bd9Sstevel@tonic-gate list = &crle->c_aslibpath; 1857c478bd9Sstevel@tonic-gate break; 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate default: 1887c478bd9Sstevel@tonic-gate return (1); 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate return (addlib(crle, list, path)); 1927c478bd9Sstevel@tonic-gate } 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate /* 1957c478bd9Sstevel@tonic-gate * Establish the flags required to generate the associated object. Actually 1967c478bd9Sstevel@tonic-gate * the flags are already part of the object being inspected from the present 1977c478bd9Sstevel@tonic-gate * configuration file, but instead of using them all, which can cause some 1987c478bd9Sstevel@tonic-gate * unsuspected propagation down the inspect() family, only use those flags that 1997c478bd9Sstevel@tonic-gate * would have been contributed from crle()'s calls to inspect. 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate static Half 2027c478bd9Sstevel@tonic-gate getflags(Half flags) 2037c478bd9Sstevel@tonic-gate { 2047c478bd9Sstevel@tonic-gate flags &= 2057c478bd9Sstevel@tonic-gate (RTC_OBJ_ALTER | RTC_OBJ_DUMP | RTC_OBJ_GROUP | RTC_OBJ_OPTINAL); 2067c478bd9Sstevel@tonic-gate return (flags | RTC_OBJ_CMDLINE); 2077c478bd9Sstevel@tonic-gate } 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * Dump a configuration files information. This routine is very close to the 2117c478bd9Sstevel@tonic-gate * scanconfig() in libcrle. 2127c478bd9Sstevel@tonic-gate */ 213587032cfSab196087 /*ARGSUSED2*/ 214c13de8f6Sab196087 static INSCFG_RET 215587032cfSab196087 scanconfig(Crle_desc * crle, Addr addr, int c_class) 2167c478bd9Sstevel@tonic-gate { 217de777a60Sab196087 Conv_inv_buf_t inv_buf1, inv_buf2, inv_buf3, inv_buf4; 218de777a60Sab196087 Conv_dl_flag_buf_t dl_flag_buf; 219c13de8f6Sab196087 Rtc_id *id; 220c13de8f6Sab196087 Rtc_head *head; 2217c478bd9Sstevel@tonic-gate Rtc_dir *dirtbl; 2227c478bd9Sstevel@tonic-gate Rtc_file *filetbl; 2237c478bd9Sstevel@tonic-gate Rtc_obj *objtbl, *obj; 2247c478bd9Sstevel@tonic-gate Word *hash, *chain; 2257c478bd9Sstevel@tonic-gate const char *strtbl; 2267c478bd9Sstevel@tonic-gate int ndx, bkts; 22757ef7aa9SRod Evans APlist *cmdline = NULL; 2287c478bd9Sstevel@tonic-gate char _cmd[PATH_MAX], *cmd; 22957ef7aa9SRod Evans char _objdir[PATH_MAX], *objdir = NULL; 230c13de8f6Sab196087 231c13de8f6Sab196087 /* 232c13de8f6Sab196087 * If there is an Rtc_id present, the Rtc_head follows it. 233c13de8f6Sab196087 * Otherwise, it is at the top. 234c13de8f6Sab196087 */ 235c13de8f6Sab196087 if (RTC_ID_TEST(addr)) { 236c13de8f6Sab196087 id = (Rtc_id *) addr; 237c13de8f6Sab196087 addr += sizeof (*id); /* Rtc_head follows */ 238c13de8f6Sab196087 } else { 239c13de8f6Sab196087 id = NULL; 240c13de8f6Sab196087 /* 241c13de8f6Sab196087 * When updating an existing config file that is lacking 242c13de8f6Sab196087 * the Rtc_id block, don't put one into the resulting file. 243c13de8f6Sab196087 */ 244c13de8f6Sab196087 crle->c_flags &= ~CRLE_ADDID; 245c13de8f6Sab196087 } 246c13de8f6Sab196087 head = (Rtc_head *) addr; 247c13de8f6Sab196087 248c13de8f6Sab196087 249c13de8f6Sab196087 /* 250c13de8f6Sab196087 * The rest of the configuration file can only be examined by 251c13de8f6Sab196087 * a program of the same ELFCLASS, byte order, and hardware 252c13de8f6Sab196087 * architecture as the one that created it. 253c13de8f6Sab196087 */ 254c13de8f6Sab196087 #ifdef _ELF64 255c13de8f6Sab196087 /* 64-bit program with an existing 32-bit file? Abort. */ 256c13de8f6Sab196087 if (!(head->ch_cnflags & RTC_HDR_64)) { 257c13de8f6Sab196087 (void) fprintf(stderr, MSG_INTL(MSG_ARG_CLASS), 258c13de8f6Sab196087 crle->c_name, crle->c_confil); 259c13de8f6Sab196087 return (INSCFG_RET_FAIL); 260c13de8f6Sab196087 } 261c13de8f6Sab196087 #else 262c13de8f6Sab196087 /* 32-bit program with an existing 64-bit file? Restart. */ 263c13de8f6Sab196087 if (head->ch_cnflags & RTC_HDR_64) 264c13de8f6Sab196087 return (INSCFG_RET_NEED64); 265587032cfSab196087 266587032cfSab196087 /* 267587032cfSab196087 * 32-bit program with an existing 32-bit file, but the 268587032cfSab196087 * user specified the -64 option? Abort 269587032cfSab196087 */ 270587032cfSab196087 if (c_class != ELFCLASS32) { 271587032cfSab196087 (void) fprintf(stderr, MSG_INTL(MSG_ARG_CLASS), 272587032cfSab196087 crle->c_name, crle->c_confil); 273587032cfSab196087 return (INSCFG_RET_FAIL); 274587032cfSab196087 } 275c13de8f6Sab196087 #endif 276c13de8f6Sab196087 /* 277c13de8f6Sab196087 * Now that the ELFCLASS has been settled, ensure that the 278c13de8f6Sab196087 * byte order and hardware match. Unlike ELFCLASS, where restarting 279c13de8f6Sab196087 * the other version is an option, we cannot work around a mismatch 280c13de8f6Sab196087 * of these attributes. 281c13de8f6Sab196087 */ 282c13de8f6Sab196087 if (id) { /* Rtc_id is present */ 283c13de8f6Sab196087 /* 284c13de8f6Sab196087 * Was the file produced by compatible hardware? 285c13de8f6Sab196087 * ELFCLASS doesn't matter here, because we can 286c13de8f6Sab196087 * adjust for that, but byte order and machine type do. 287c13de8f6Sab196087 */ 288c13de8f6Sab196087 if ((id->id_data != M_DATA) || (id->id_machine != M_MACH)) { 289c13de8f6Sab196087 (void) fprintf(stderr, MSG_INTL(MSG_ARG_WRONGARCH), 290c13de8f6Sab196087 crle->c_name, crle->c_confil, 291d29b2c44Sab196087 conv_ehdr_data(id->id_data, CONV_FMT_ALT_FILE, 292de777a60Sab196087 &inv_buf1), 293d29b2c44Sab196087 conv_ehdr_mach(id->id_machine, CONV_FMT_ALT_FILE, 294de777a60Sab196087 &inv_buf2), 295d29b2c44Sab196087 conv_ehdr_data(M_DATA, CONV_FMT_ALT_FILE, 296d29b2c44Sab196087 &inv_buf3), 297d29b2c44Sab196087 conv_ehdr_mach(M_MACH, CONV_FMT_ALT_FILE, 298de777a60Sab196087 &inv_buf4)); 299c13de8f6Sab196087 return (INSCFG_RET_FAIL); 300c13de8f6Sab196087 } 301c13de8f6Sab196087 } 302c13de8f6Sab196087 303c13de8f6Sab196087 3047c478bd9Sstevel@tonic-gate /* LINTED */ 305c13de8f6Sab196087 objtbl = (Rtc_obj *)(CAST_PTRINT(char *, head->ch_obj) + addr); 306c13de8f6Sab196087 strtbl = (const char *)(CAST_PTRINT(char *, head->ch_str) + addr); 307c13de8f6Sab196087 308c13de8f6Sab196087 /* 309c13de8f6Sab196087 * If the configuration file has a version higher than we 310c13de8f6Sab196087 * recognise, we face two issues: 311c13de8f6Sab196087 * (1) Updates are not possible because we have no 312c13de8f6Sab196087 * way to recognise or propagate the new features. 313c13de8f6Sab196087 * This has to be a fatal error. 314c13de8f6Sab196087 * (2) Printing has the risk that we may have been 315c13de8f6Sab196087 * handed something other than a real config file, as 316c13de8f6Sab196087 * well as the fact that we can't display the information 317c13de8f6Sab196087 * for the new features. So, we print a warning, but 318c13de8f6Sab196087 * continue on to do the best we can with it. 319c13de8f6Sab196087 */ 320c13de8f6Sab196087 if (head->ch_version > RTC_VER_CURRENT) { 321c13de8f6Sab196087 if (crle->c_flags & CRLE_UPDATE) { 322c13de8f6Sab196087 (void) fprintf(stderr, MSG_INTL(MSG_ARG_UPDATEVER), 323c13de8f6Sab196087 crle->c_name, crle->c_confil, 324587032cfSab196087 (int)head->ch_version, RTC_VER_CURRENT); 325c13de8f6Sab196087 return (INSCFG_RET_FAIL); 326c13de8f6Sab196087 } else { 327c13de8f6Sab196087 (void) fprintf(stderr, MSG_INTL(MSG_ARG_PRINTVER), 328c13de8f6Sab196087 crle->c_name, crle->c_confil, 329587032cfSab196087 (int)head->ch_version, RTC_VER_CURRENT); 330c13de8f6Sab196087 } 331c13de8f6Sab196087 } 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate /* 3347c478bd9Sstevel@tonic-gate * If this is a version 1 configuration file we can't generate accurate 3357c478bd9Sstevel@tonic-gate * update information, or the command-line used to create the file. 3367c478bd9Sstevel@tonic-gate */ 3377c478bd9Sstevel@tonic-gate if (head->ch_version == RTC_VER_ONE) { 3387c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_ARG_UPDATE), crle->c_name, 339587032cfSab196087 crle->c_confil, (int)head->ch_version); 3407c478bd9Sstevel@tonic-gate } 3417c478bd9Sstevel@tonic-gate 342c13de8f6Sab196087 343c13de8f6Sab196087 if (!(crle->c_flags & CRLE_UPDATE) && (head->ch_cnflags & RTC_HDR_64)) { 3447c478bd9Sstevel@tonic-gate /* 3457c478bd9Sstevel@tonic-gate * Construct the original command line argument. 3467c478bd9Sstevel@tonic-gate */ 347*23a1cceaSRoger A. Faulkner cmd = strdupa(MSG_ORIG(MSG_CMD_64)); 34857ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 349c13de8f6Sab196087 return (INSCFG_RET_FAIL); 3507c478bd9Sstevel@tonic-gate } 351c13de8f6Sab196087 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate /* 3547c478bd9Sstevel@tonic-gate * Start analyzing the configuration files header information. 3557c478bd9Sstevel@tonic-gate */ 3567c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_UPDATE) == 0) { 3577c478bd9Sstevel@tonic-gate const char *fmt; 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate if (head->ch_dlflags) 360de777a60Sab196087 fmt = conv_dl_flag(head->ch_dlflags, 0, &dl_flag_buf); 3617c478bd9Sstevel@tonic-gate else 3627c478bd9Sstevel@tonic-gate fmt = MSG_ORIG(MSG_STR_EMPTY); 3637c478bd9Sstevel@tonic-gate 364587032cfSab196087 (void) printf(MSG_INTL(MSG_DMP_HEAD), (int)head->ch_version, 3657c478bd9Sstevel@tonic-gate crle->c_confil, fmt); 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate /* 368c13de8f6Sab196087 * If the file has an id block, show the information 369c13de8f6Sab196087 */ 370c13de8f6Sab196087 if (id) 371587032cfSab196087 (void) printf(MSG_INTL(MSG_DMP_PLATFORM), 372d29b2c44Sab196087 conv_ehdr_class(id->id_class, CONV_FMT_ALT_FILE, 373de777a60Sab196087 &inv_buf1), 374d29b2c44Sab196087 conv_ehdr_data(id->id_data, CONV_FMT_ALT_FILE, 375de777a60Sab196087 &inv_buf2), 376d29b2c44Sab196087 conv_ehdr_mach(id->id_machine, CONV_FMT_ALT_FILE, 377de777a60Sab196087 &inv_buf3)); 378c13de8f6Sab196087 379c13de8f6Sab196087 /* 3807c478bd9Sstevel@tonic-gate * Construct the original command line argument. 3817c478bd9Sstevel@tonic-gate */ 3827c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_CONF), 3837c478bd9Sstevel@tonic-gate crle->c_confil); 384*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 38557ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 386c13de8f6Sab196087 return (INSCFG_RET_FAIL); 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate /* 3897c478bd9Sstevel@tonic-gate * Construct any -f usage. 3907c478bd9Sstevel@tonic-gate */ 3917c478bd9Sstevel@tonic-gate if (head->ch_dlflags && 3927c478bd9Sstevel@tonic-gate (head->ch_dlflags != RTLD_REL_RELATIVE)) { 3937c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, MSG_ORIG(MSG_CMD_FLAGS), 394d29b2c44Sab196087 conv_dl_flag(head->ch_dlflags, CONV_FMT_ALT_CRLE, 395de777a60Sab196087 &dl_flag_buf)); 396*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 39757ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 398c13de8f6Sab196087 return (INSCFG_RET_FAIL); 3997c478bd9Sstevel@tonic-gate } 4007c478bd9Sstevel@tonic-gate } else { 4017c478bd9Sstevel@tonic-gate /* 4027c478bd9Sstevel@tonic-gate * Establish any -f usage. 4037c478bd9Sstevel@tonic-gate */ 4047c478bd9Sstevel@tonic-gate if (head->ch_dlflags && 4057c478bd9Sstevel@tonic-gate (head->ch_dlflags != RTLD_REL_RELATIVE)) 4067c478bd9Sstevel@tonic-gate crle->c_dlflags = head->ch_dlflags; 4077c478bd9Sstevel@tonic-gate } 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate /* 4117c478bd9Sstevel@tonic-gate * Determine if this configuration file is only applicable to a specific 4127c478bd9Sstevel@tonic-gate * application. 4137c478bd9Sstevel@tonic-gate */ 4147c478bd9Sstevel@tonic-gate if (head->ch_app) { 4157c478bd9Sstevel@tonic-gate char *alter; 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate obj = (Rtc_obj *)(head->ch_app + addr); 4187c478bd9Sstevel@tonic-gate 4197c478bd9Sstevel@tonic-gate /* 4207c478bd9Sstevel@tonic-gate * Determine the output directory for the files 4217c478bd9Sstevel@tonic-gate * alternative name. 4227c478bd9Sstevel@tonic-gate */ 4237c478bd9Sstevel@tonic-gate alter = (char *)(strtbl + obj->co_alter); 4247c478bd9Sstevel@tonic-gate (void) strcpy(_objdir, alter); 4257c478bd9Sstevel@tonic-gate alter = strrchr(_objdir, '/'); 4267c478bd9Sstevel@tonic-gate *alter = '\0'; 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate crle->c_objdir = objdir = _objdir; 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 4317c478bd9Sstevel@tonic-gate if (inspect(crle, (strtbl + obj->co_name), 4327c478bd9Sstevel@tonic-gate (RTC_OBJ_DUMP | RTC_OBJ_ALTER | 4337c478bd9Sstevel@tonic-gate RTC_OBJ_GROUP | RTC_OBJ_CMDLINE)) != 0) 434c13de8f6Sab196087 return (INSCFG_RET_FAIL); 4357c478bd9Sstevel@tonic-gate } else { 4367c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_APP), 4377c478bd9Sstevel@tonic-gate (strtbl + obj->co_alter), (strtbl + obj->co_name)); 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate /* 4407c478bd9Sstevel@tonic-gate * Construct the original command line arguments. 4417c478bd9Sstevel@tonic-gate */ 4427c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 4437c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_CMD_OUTPUT), crle->c_objdir); 444*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 44557ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 446c13de8f6Sab196087 return (INSCFG_RET_FAIL); 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 4497c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_CMD_DUMPGRP), (strtbl + obj->co_name)); 450*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 45157ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 452c13de8f6Sab196087 return (INSCFG_RET_FAIL); 4537c478bd9Sstevel@tonic-gate } 4547c478bd9Sstevel@tonic-gate } 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate /* 4577c478bd9Sstevel@tonic-gate * Analyze any alternative library path and trusted directory entries. 4587c478bd9Sstevel@tonic-gate */ 4597c478bd9Sstevel@tonic-gate if (head->ch_edlibpath) { 4607c478bd9Sstevel@tonic-gate const char *str; 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate str = (const char *)(head->ch_edlibpath + addr); 4637c478bd9Sstevel@tonic-gate 4647c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 4657c478bd9Sstevel@tonic-gate crle->c_flags &= ~CRLE_AOUT; 4667c478bd9Sstevel@tonic-gate 4677c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 4687c478bd9Sstevel@tonic-gate if ((head->ch_cnflags & RTC_HDR_UPM) == 0) { 4697c478bd9Sstevel@tonic-gate if (head->ch_cnflags & RTC_HDR_64) 4705aefb655Srie str = conv_config_upm(str, 4717c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_OLDDLP_64), 4727c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_UPDLP_64), 4737c478bd9Sstevel@tonic-gate MSG_PTH_UPDLP_64_SIZE); 4747c478bd9Sstevel@tonic-gate else 4755aefb655Srie str = conv_config_upm(str, 4767c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_OLDDLP), 4777c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_UPDLP), 4787c478bd9Sstevel@tonic-gate MSG_PTH_UPDLP_SIZE); 4797c478bd9Sstevel@tonic-gate } 4807c478bd9Sstevel@tonic-gate #endif 4817c478bd9Sstevel@tonic-gate if (addlib(crle, &crle->c_edlibpath, str) != 0) 482c13de8f6Sab196087 return (INSCFG_RET_FAIL); 4837c478bd9Sstevel@tonic-gate } else { 4847c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_DLIBPTH), 4857c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_STR_ELF), str); 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 4887c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_CMD_EDLIB), str); 489*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 49057ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 491c13de8f6Sab196087 return (INSCFG_RET_FAIL); 4927c478bd9Sstevel@tonic-gate } 4937c478bd9Sstevel@tonic-gate } else { 4947c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 4957c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_EDLIB) { 4967c478bd9Sstevel@tonic-gate /* 4977c478bd9Sstevel@tonic-gate * If we've been asked to update a configuration 4987c478bd9Sstevel@tonic-gate * file, and no existing default ELF search 4997c478bd9Sstevel@tonic-gate * path exists, but the user is going to add new 5007c478bd9Sstevel@tonic-gate * entries, fabricate the system defaults so 5017c478bd9Sstevel@tonic-gate * that the users get added to them. 5027c478bd9Sstevel@tonic-gate */ 5037c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_EDLIB) != 0) 504c13de8f6Sab196087 return (INSCFG_RET_FAIL); 5057c478bd9Sstevel@tonic-gate } 5067c478bd9Sstevel@tonic-gate } else { 5077c478bd9Sstevel@tonic-gate /* 5087c478bd9Sstevel@tonic-gate * Indicate any system default. 5097c478bd9Sstevel@tonic-gate */ 510c13de8f6Sab196087 #if M_CLASS == ELFCLASS64 5117c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 5127c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_NEWDLP_64)); 5137c478bd9Sstevel@tonic-gate #else 5147c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_OLDDLP_64)); 5157c478bd9Sstevel@tonic-gate #endif 516c13de8f6Sab196087 #else 5177c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 5187c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_NEWDLP)); 5197c478bd9Sstevel@tonic-gate #else 5207c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_OLDDLP)); 5217c478bd9Sstevel@tonic-gate #endif 522c13de8f6Sab196087 #endif 5237c478bd9Sstevel@tonic-gate } 5247c478bd9Sstevel@tonic-gate } 5257c478bd9Sstevel@tonic-gate 5267c478bd9Sstevel@tonic-gate if (head->ch_eslibpath) { 5277c478bd9Sstevel@tonic-gate const char *str; 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate str = (const char *)(head->ch_eslibpath + addr); 5307c478bd9Sstevel@tonic-gate 5317c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 5327c478bd9Sstevel@tonic-gate crle->c_flags &= ~CRLE_AOUT; 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 5357c478bd9Sstevel@tonic-gate if ((head->ch_cnflags & RTC_HDR_UPM) == 0) { 5367c478bd9Sstevel@tonic-gate if (head->ch_cnflags & RTC_HDR_64) 5375aefb655Srie str = conv_config_upm(str, 5387c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_OLDTD_64), 5397c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_UPTD_64), 5407c478bd9Sstevel@tonic-gate MSG_PTH_UPTD_64_SIZE); 5417c478bd9Sstevel@tonic-gate else 5425aefb655Srie str = conv_config_upm(str, 5437c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_OLDTD), 5447c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PTH_UPTD), 5457c478bd9Sstevel@tonic-gate MSG_PTH_UPTD_SIZE); 5467c478bd9Sstevel@tonic-gate } 5477c478bd9Sstevel@tonic-gate #endif 5487c478bd9Sstevel@tonic-gate if (addlib(crle, &crle->c_eslibpath, str) != 0) 549c13de8f6Sab196087 return (INSCFG_RET_FAIL); 5507c478bd9Sstevel@tonic-gate } else { 5517c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_TLIBPTH), 5527c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_STR_ELF), str); 5537c478bd9Sstevel@tonic-gate 5547c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 5557c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_CMD_ESLIB), str); 556*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 55757ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 558c13de8f6Sab196087 return (INSCFG_RET_FAIL); 5597c478bd9Sstevel@tonic-gate } 5607c478bd9Sstevel@tonic-gate } else { 5617c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 5627c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_ESLIB) { 5637c478bd9Sstevel@tonic-gate /* 5647c478bd9Sstevel@tonic-gate * If we've been asked to update a configuration 5657c478bd9Sstevel@tonic-gate * file, and no existing default ELF secure 5667c478bd9Sstevel@tonic-gate * path exists, but the user is going to add new 5677c478bd9Sstevel@tonic-gate * entries, fabricate the system defaults so 5687c478bd9Sstevel@tonic-gate * that the users get added to them. 5697c478bd9Sstevel@tonic-gate */ 5707c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_ESLIB) != 0) 571c13de8f6Sab196087 return (INSCFG_RET_FAIL); 5727c478bd9Sstevel@tonic-gate } 5737c478bd9Sstevel@tonic-gate } else { 5747c478bd9Sstevel@tonic-gate /* 5757c478bd9Sstevel@tonic-gate * Indicate any system default. 5767c478bd9Sstevel@tonic-gate */ 577c13de8f6Sab196087 #if M_CLASS == ELFCLASS64 5787c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 5797c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_NEWTD_64)); 5807c478bd9Sstevel@tonic-gate #else 5817c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_OLDTD_64)); 5827c478bd9Sstevel@tonic-gate #endif 583c13de8f6Sab196087 #else 5847c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 5857c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_NEWTD)); 5867c478bd9Sstevel@tonic-gate #else 5877c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_OLDTD)); 5887c478bd9Sstevel@tonic-gate #endif 589c13de8f6Sab196087 #endif 5907c478bd9Sstevel@tonic-gate } 5917c478bd9Sstevel@tonic-gate } 5927c478bd9Sstevel@tonic-gate 5937c478bd9Sstevel@tonic-gate if (head->ch_adlibpath) { 5947c478bd9Sstevel@tonic-gate const char *str; 5957c478bd9Sstevel@tonic-gate 5967c478bd9Sstevel@tonic-gate str = (const char *)(head->ch_adlibpath + addr); 5977c478bd9Sstevel@tonic-gate 5987c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 5997c478bd9Sstevel@tonic-gate crle->c_flags |= CRLE_AOUT; 6007c478bd9Sstevel@tonic-gate if (addlib(crle, &crle->c_adlibpath, str) != 0) 601c13de8f6Sab196087 return (INSCFG_RET_FAIL); 6027c478bd9Sstevel@tonic-gate } else { 6037c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_DLIBPTH), 6047c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_STR_AOUT), str); 6057c478bd9Sstevel@tonic-gate 6067c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 6077c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_CMD_ADLIB), str); 608*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 60957ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 610c13de8f6Sab196087 return (INSCFG_RET_FAIL); 6117c478bd9Sstevel@tonic-gate } 6127c478bd9Sstevel@tonic-gate } else { 6137c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 6147c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_ADLIB) { 6157c478bd9Sstevel@tonic-gate /* 6167c478bd9Sstevel@tonic-gate * If we've been asked to update a configuration 6177c478bd9Sstevel@tonic-gate * file, and no existing default AOUT search 6187c478bd9Sstevel@tonic-gate * path exists, but the user is going to add new 6197c478bd9Sstevel@tonic-gate * entries, fabricate the system defaults so 6207c478bd9Sstevel@tonic-gate * that the users get added to them. 6217c478bd9Sstevel@tonic-gate */ 6227c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_ADLIB) != 0) 623c13de8f6Sab196087 return (INSCFG_RET_FAIL); 6247c478bd9Sstevel@tonic-gate } 6257c478bd9Sstevel@tonic-gate } else if (crle->c_flags & CRLE_AOUT) { 6267c478bd9Sstevel@tonic-gate /* 6277c478bd9Sstevel@tonic-gate * Indicate any system default. 6287c478bd9Sstevel@tonic-gate */ 6297c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_AOUTDLP)); 6307c478bd9Sstevel@tonic-gate } 6317c478bd9Sstevel@tonic-gate } 6327c478bd9Sstevel@tonic-gate 6337c478bd9Sstevel@tonic-gate if (head->ch_aslibpath) { 6347c478bd9Sstevel@tonic-gate const char *str; 6357c478bd9Sstevel@tonic-gate 6367c478bd9Sstevel@tonic-gate str = (const char *)(head->ch_aslibpath + addr); 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 6397c478bd9Sstevel@tonic-gate crle->c_flags |= CRLE_AOUT; 6407c478bd9Sstevel@tonic-gate if (addlib(crle, &crle->c_aslibpath, str) != 0) 641c13de8f6Sab196087 return (INSCFG_RET_FAIL); 6427c478bd9Sstevel@tonic-gate } else { 6437c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_TLIBPTH), 6447c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_STR_AOUT), str); 6457c478bd9Sstevel@tonic-gate 6467c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 6477c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_CMD_ASLIB), str); 648*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 64957ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, AL_CNT_CRLE) == NULL) 650c13de8f6Sab196087 return (INSCFG_RET_FAIL); 6517c478bd9Sstevel@tonic-gate } 6527c478bd9Sstevel@tonic-gate } else { 6537c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 6547c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_ASLIB) { 6557c478bd9Sstevel@tonic-gate /* 6567c478bd9Sstevel@tonic-gate * If we've been asked to update a configuration 6577c478bd9Sstevel@tonic-gate * file, and no existing default AOUT secure 6587c478bd9Sstevel@tonic-gate * path exists, but the user is going to add new 6597c478bd9Sstevel@tonic-gate * entries, fabricate the system defaults so 6607c478bd9Sstevel@tonic-gate * that the users get added to them. 6617c478bd9Sstevel@tonic-gate */ 6627c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_ASLIB) != 0) 663c13de8f6Sab196087 return (INSCFG_RET_FAIL); 6647c478bd9Sstevel@tonic-gate } 6657c478bd9Sstevel@tonic-gate } else if (crle->c_flags & CRLE_AOUT) { 6667c478bd9Sstevel@tonic-gate /* 6677c478bd9Sstevel@tonic-gate * Indicate any system default. 6687c478bd9Sstevel@tonic-gate */ 669ba7962c0SRod Evans #ifndef SGS_PRE_UNIFIED_PROCESS 670ba7962c0SRod Evans (void) printf(MSG_INTL(MSG_DEF_AOUTNEWTD)); 671ba7962c0SRod Evans #else 672ba7962c0SRod Evans (void) printf(MSG_INTL(MSG_DEF_AOUTOLDTD)); 673ba7962c0SRod Evans #endif 6747c478bd9Sstevel@tonic-gate } 6757c478bd9Sstevel@tonic-gate } 6767c478bd9Sstevel@tonic-gate 6777c478bd9Sstevel@tonic-gate /* 6787c478bd9Sstevel@tonic-gate * Display any environment variables. 6797c478bd9Sstevel@tonic-gate */ 6807c478bd9Sstevel@tonic-gate if ((head->ch_version >= RTC_VER_THREE) && head->ch_env) { 6817c478bd9Sstevel@tonic-gate Rtc_env *envtbl; 6827c478bd9Sstevel@tonic-gate 6837c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_UPDATE) == 0) 6847c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_ENV_TITLE)); 6857c478bd9Sstevel@tonic-gate 6867c478bd9Sstevel@tonic-gate for (envtbl = (Rtc_env *)(head->ch_env + addr); 6877c478bd9Sstevel@tonic-gate envtbl->env_str; envtbl++) { 6887c478bd9Sstevel@tonic-gate const char *str; 6897c478bd9Sstevel@tonic-gate 6907c478bd9Sstevel@tonic-gate str = (const char *)(envtbl->env_str + addr); 6917c478bd9Sstevel@tonic-gate 6927c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 6937c478bd9Sstevel@tonic-gate if (addenv(crle, str, 6947c478bd9Sstevel@tonic-gate (envtbl->env_flags | RTC_ENV_CONFIG)) == 0) 695c13de8f6Sab196087 return (INSCFG_RET_FAIL); 6967c478bd9Sstevel@tonic-gate } else { 6977c478bd9Sstevel@tonic-gate const char *pfmt, *sfmt; 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate if (envtbl->env_flags & RTC_ENV_PERMANT) { 7007c478bd9Sstevel@tonic-gate pfmt = MSG_INTL(MSG_ENV_PRM); 7017c478bd9Sstevel@tonic-gate sfmt = MSG_ORIG(MSG_CMD_PRMENV); 7027c478bd9Sstevel@tonic-gate } else { 7037c478bd9Sstevel@tonic-gate pfmt = MSG_INTL(MSG_ENV_RPL); 7047c478bd9Sstevel@tonic-gate sfmt = MSG_ORIG(MSG_CMD_RPLENV); 7057c478bd9Sstevel@tonic-gate } 7067c478bd9Sstevel@tonic-gate (void) printf(pfmt, str); 7077c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, sfmt, str); 708*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 70957ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, 71057ef7aa9SRod Evans AL_CNT_CRLE) == NULL) 711c13de8f6Sab196087 return (INSCFG_RET_FAIL); 7127c478bd9Sstevel@tonic-gate } 7137c478bd9Sstevel@tonic-gate } 7147c478bd9Sstevel@tonic-gate } 7157c478bd9Sstevel@tonic-gate 7167c478bd9Sstevel@tonic-gate /* 7177c478bd9Sstevel@tonic-gate * Display any filter/filtee associations. 7187c478bd9Sstevel@tonic-gate */ 7197c478bd9Sstevel@tonic-gate if ((head->ch_version >= RTC_VER_FOUR) && head->ch_fltr) { 7207c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_UPDATE) == 0) { 7217c478bd9Sstevel@tonic-gate Rtc_fltr *fltrtbl; 7227c478bd9Sstevel@tonic-gate Rtc_flte *fltetbl; 7237c478bd9Sstevel@tonic-gate 7247c478bd9Sstevel@tonic-gate /* LINTED */ 725c13de8f6Sab196087 fltrtbl = (Rtc_fltr *) 726c13de8f6Sab196087 (CAST_PTRINT(char *, head->ch_fltr) + addr); 7277c478bd9Sstevel@tonic-gate /* LINTED */ 728c13de8f6Sab196087 fltetbl = (Rtc_flte *) 729c13de8f6Sab196087 (CAST_PTRINT(char *, head->ch_flte) + addr); 7307c478bd9Sstevel@tonic-gate 7317c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_FLT_TITLE)); 7327c478bd9Sstevel@tonic-gate 7337c478bd9Sstevel@tonic-gate while (fltrtbl->fr_filter) { 7347c478bd9Sstevel@tonic-gate Rtc_flte *_fltetbl; 7357c478bd9Sstevel@tonic-gate 7367c478bd9Sstevel@tonic-gate /* 7377c478bd9Sstevel@tonic-gate * Print the filter and filtee string pair. 7387c478bd9Sstevel@tonic-gate */ 7397c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_FLT_FILTER), 7407c478bd9Sstevel@tonic-gate (strtbl + fltrtbl->fr_filter), 7417c478bd9Sstevel@tonic-gate (strtbl + fltrtbl->fr_string)); 7427c478bd9Sstevel@tonic-gate 7437c478bd9Sstevel@tonic-gate /* 7447c478bd9Sstevel@tonic-gate * Print each filtee. 7457c478bd9Sstevel@tonic-gate */ 7467c478bd9Sstevel@tonic-gate /* LINTED */ 7477c478bd9Sstevel@tonic-gate for (_fltetbl = (Rtc_flte *)((char *)fltetbl + 7487c478bd9Sstevel@tonic-gate fltrtbl->fr_filtee); _fltetbl->fe_filtee; 7497c478bd9Sstevel@tonic-gate _fltetbl++) { 7507c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_FLT_FILTEE), 7517c478bd9Sstevel@tonic-gate (strtbl + _fltetbl->fe_filtee)); 7527c478bd9Sstevel@tonic-gate } 7537c478bd9Sstevel@tonic-gate fltrtbl++; 7547c478bd9Sstevel@tonic-gate } 7557c478bd9Sstevel@tonic-gate } 7567c478bd9Sstevel@tonic-gate } 7577c478bd9Sstevel@tonic-gate 7587c478bd9Sstevel@tonic-gate /* 7597c478bd9Sstevel@tonic-gate * Display any memory reservations required for any alternative 7607c478bd9Sstevel@tonic-gate * objects. 7617c478bd9Sstevel@tonic-gate */ 7627c478bd9Sstevel@tonic-gate if (head->ch_resbgn && ((crle->c_flags & CRLE_UPDATE) == 0)) 763587032cfSab196087 (void) printf(MSG_INTL(MSG_DMP_RESV), 764587032cfSab196087 (u_longlong_t)head->ch_resbgn, 765587032cfSab196087 (u_longlong_t)head->ch_resend, 766587032cfSab196087 (u_longlong_t)(head->ch_resend - head->ch_resbgn)); 7677c478bd9Sstevel@tonic-gate 7687c478bd9Sstevel@tonic-gate /* 7697c478bd9Sstevel@tonic-gate * If there's no hash table there's nothing else to process. 7707c478bd9Sstevel@tonic-gate */ 7717c478bd9Sstevel@tonic-gate if (head->ch_hash == 0) { 7727c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_UPDATE) == 0) 77357ef7aa9SRod Evans printcmd(crle, head, cmdline); 774c13de8f6Sab196087 return (INSCFG_RET_OK); 7757c478bd9Sstevel@tonic-gate } 7767c478bd9Sstevel@tonic-gate 7777c478bd9Sstevel@tonic-gate /* 7787c478bd9Sstevel@tonic-gate * Traverse the directory and filename arrays. 7797c478bd9Sstevel@tonic-gate */ 7807c478bd9Sstevel@tonic-gate for (dirtbl = (Rtc_dir *)(head->ch_dir + addr); 7817c478bd9Sstevel@tonic-gate dirtbl->cd_obj; dirtbl++) { 7827c478bd9Sstevel@tonic-gate struct stat status; 7837c478bd9Sstevel@tonic-gate Rtc_obj *dobj; 7847c478bd9Sstevel@tonic-gate const char *str; 7857c478bd9Sstevel@tonic-gate 7867c478bd9Sstevel@tonic-gate dobj = (Rtc_obj *)(dirtbl->cd_obj + addr); 7877c478bd9Sstevel@tonic-gate filetbl = (Rtc_file *)(dirtbl->cd_file + addr); 7887c478bd9Sstevel@tonic-gate str = strtbl + dobj->co_name; 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate /* 7917c478bd9Sstevel@tonic-gate * Simplify recreation by using any command-line directories. 7927c478bd9Sstevel@tonic-gate * If we're dealing with a version 1 configuration file use 7937c478bd9Sstevel@tonic-gate * every directory. 7947c478bd9Sstevel@tonic-gate */ 7957c478bd9Sstevel@tonic-gate if ((dobj->co_flags & RTC_OBJ_CMDLINE) || 7967c478bd9Sstevel@tonic-gate (head->ch_version == RTC_VER_ONE)) { 7977c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 7987c478bd9Sstevel@tonic-gate if (inspect(crle, str, 7997c478bd9Sstevel@tonic-gate getflags(dobj->co_flags)) != 0) 800c13de8f6Sab196087 return (INSCFG_RET_FAIL); 8017c478bd9Sstevel@tonic-gate if ((dobj->co_flags & 8027c478bd9Sstevel@tonic-gate (RTC_OBJ_NOEXIST | RTC_OBJ_ALTER)) == 8037c478bd9Sstevel@tonic-gate RTC_OBJ_NOEXIST) 8047c478bd9Sstevel@tonic-gate continue; 8057c478bd9Sstevel@tonic-gate } else { 8067c478bd9Sstevel@tonic-gate /* LINTED */ 8077c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 8087c478bd9Sstevel@tonic-gate getformat(dobj->co_flags), str); 809*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 81057ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, 81157ef7aa9SRod Evans AL_CNT_CRLE) == NULL) 812c13de8f6Sab196087 return (INSCFG_RET_FAIL); 8137c478bd9Sstevel@tonic-gate } 8147c478bd9Sstevel@tonic-gate } 8157c478bd9Sstevel@tonic-gate 8167c478bd9Sstevel@tonic-gate /* 8177c478bd9Sstevel@tonic-gate * If this isn't an update print the directory name. If the 8187c478bd9Sstevel@tonic-gate * directory has no entries (possible if the directory is a 8197c478bd9Sstevel@tonic-gate * symlink to another directory, in which case we record the 8207c478bd9Sstevel@tonic-gate * real path also), don't bother printing it unless we're in 8217c478bd9Sstevel@tonic-gate * verbose mode. 8227c478bd9Sstevel@tonic-gate */ 8237c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_UPDATE) == 0) { 8247c478bd9Sstevel@tonic-gate if ((dobj->co_flags & 8257c478bd9Sstevel@tonic-gate (RTC_OBJ_NOEXIST | RTC_OBJ_ALTER)) == 8267c478bd9Sstevel@tonic-gate RTC_OBJ_NOEXIST) { 8277c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_DIR_2), str); 8287c478bd9Sstevel@tonic-gate continue; 8297c478bd9Sstevel@tonic-gate } else if (filetbl->cf_obj || 8307c478bd9Sstevel@tonic-gate (crle->c_flags & CRLE_VERBOSE)) 8317c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_DIR_1), str); 8327c478bd9Sstevel@tonic-gate } 8337c478bd9Sstevel@tonic-gate 8347c478bd9Sstevel@tonic-gate /* 8357c478bd9Sstevel@tonic-gate * Under verbose mode validate any real directory entry - the 8367c478bd9Sstevel@tonic-gate * same test will be carried out by ld.so.1. 8377c478bd9Sstevel@tonic-gate */ 8387c478bd9Sstevel@tonic-gate if (((crle->c_flags & CRLE_UPDATE) == 0) && 8397c478bd9Sstevel@tonic-gate (crle->c_flags & CRLE_VERBOSE) && 8407c478bd9Sstevel@tonic-gate (dobj->co_flags & RTC_OBJ_REALPTH)) { 8417c478bd9Sstevel@tonic-gate if (stat(str, &status) != 0) { 8427c478bd9Sstevel@tonic-gate int err = errno; 8437c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_STAT), str, 8447c478bd9Sstevel@tonic-gate strerror(err)); 8457c478bd9Sstevel@tonic-gate } else if (status.st_mtime != dobj->co_info) { 8467c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_DCMP), str); 8477c478bd9Sstevel@tonic-gate } 8487c478bd9Sstevel@tonic-gate } 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate for (; filetbl->cf_obj; filetbl++) { 8517c478bd9Sstevel@tonic-gate Rtc_obj *fobj; 8527c478bd9Sstevel@tonic-gate Half flags; 8537c478bd9Sstevel@tonic-gate 8547c478bd9Sstevel@tonic-gate fobj = (Rtc_obj *)(filetbl->cf_obj + addr); 8557c478bd9Sstevel@tonic-gate str = strtbl + fobj->co_name; 8567c478bd9Sstevel@tonic-gate flags = fobj->co_flags; 8577c478bd9Sstevel@tonic-gate 8587c478bd9Sstevel@tonic-gate /* 8597c478bd9Sstevel@tonic-gate * Only update individual files that were originally 8607c478bd9Sstevel@tonic-gate * specified on the command-line. Or, if this is a 8617c478bd9Sstevel@tonic-gate * version 1 configuration file use every file that 8627c478bd9Sstevel@tonic-gate * isn't part of an all-entries directory. 8637c478bd9Sstevel@tonic-gate */ 8647c478bd9Sstevel@tonic-gate if (((flags & RTC_OBJ_CMDLINE) && 8657c478bd9Sstevel@tonic-gate ((fobj->co_flags & RTC_OBJ_APP) == 0)) || 8667c478bd9Sstevel@tonic-gate ((head->ch_version == RTC_VER_ONE) && 8677c478bd9Sstevel@tonic-gate ((dobj->co_flags & RTC_OBJ_ALLENTS) == 0))) { 86857ef7aa9SRod Evans char *alter = NULL, altdir[PATH_MAX]; 8697c478bd9Sstevel@tonic-gate 8707c478bd9Sstevel@tonic-gate /* 8717c478bd9Sstevel@tonic-gate * Determine whether this file requires an 8727c478bd9Sstevel@tonic-gate * alternative, and if so, and we haven't 8737c478bd9Sstevel@tonic-gate * already an alternative in affect, create one. 8747c478bd9Sstevel@tonic-gate */ 8757c478bd9Sstevel@tonic-gate if (fobj->co_flags & RTC_OBJ_ALTER) { 8767c478bd9Sstevel@tonic-gate alter = (char *)(strtbl + 8777c478bd9Sstevel@tonic-gate fobj->co_alter); 8787c478bd9Sstevel@tonic-gate (void) strcpy(altdir, alter); 8797c478bd9Sstevel@tonic-gate alter = strrchr(altdir, '/'); 8807c478bd9Sstevel@tonic-gate *alter = '\0'; 8817c478bd9Sstevel@tonic-gate 88257ef7aa9SRod Evans if ((objdir == NULL) || 8837c478bd9Sstevel@tonic-gate (strcmp(objdir, altdir) != 0)) { 8847c478bd9Sstevel@tonic-gate (void) strcpy(_objdir, altdir); 8857c478bd9Sstevel@tonic-gate crle->c_objdir = alter = 8867c478bd9Sstevel@tonic-gate objdir = _objdir; 8877c478bd9Sstevel@tonic-gate } else 88857ef7aa9SRod Evans alter = NULL; 8897c478bd9Sstevel@tonic-gate } 8907c478bd9Sstevel@tonic-gate 8917c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 8927c478bd9Sstevel@tonic-gate if (inspect(crle, str, 8937c478bd9Sstevel@tonic-gate getflags(flags)) != 0) 894c13de8f6Sab196087 return (INSCFG_RET_FAIL); 8957c478bd9Sstevel@tonic-gate continue; 8967c478bd9Sstevel@tonic-gate } 8977c478bd9Sstevel@tonic-gate 8987c478bd9Sstevel@tonic-gate if (alter) { 8997c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 9007c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_CMD_OUTPUT), 9017c478bd9Sstevel@tonic-gate crle->c_objdir); 902*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 90357ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, 90457ef7aa9SRod Evans AL_CNT_CRLE) == NULL) 905c13de8f6Sab196087 return (INSCFG_RET_FAIL); 9067c478bd9Sstevel@tonic-gate } 9077c478bd9Sstevel@tonic-gate 9087c478bd9Sstevel@tonic-gate /* LINTED */ 9097c478bd9Sstevel@tonic-gate (void) snprintf(_cmd, PATH_MAX, 9107c478bd9Sstevel@tonic-gate getformat(flags), str); 911*23a1cceaSRoger A. Faulkner cmd = strdupa(_cmd); 91257ef7aa9SRod Evans if (aplist_append(&cmdline, cmd, 91357ef7aa9SRod Evans AL_CNT_CRLE) == NULL) 914c13de8f6Sab196087 return (INSCFG_RET_FAIL); 9157c478bd9Sstevel@tonic-gate } 9167c478bd9Sstevel@tonic-gate 9177c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) 9187c478bd9Sstevel@tonic-gate continue; 9197c478bd9Sstevel@tonic-gate 9207c478bd9Sstevel@tonic-gate /* 9217c478bd9Sstevel@tonic-gate * Although we record both full pathnames and their 9227c478bd9Sstevel@tonic-gate * simple filenames (basename), only print the simple 9237c478bd9Sstevel@tonic-gate * names unless we're under verbose mode. 9247c478bd9Sstevel@tonic-gate */ 9257c478bd9Sstevel@tonic-gate if ((strchr(str, '/') == 0) || 9267c478bd9Sstevel@tonic-gate (crle->c_flags & CRLE_VERBOSE)) { 9277c478bd9Sstevel@tonic-gate if (fobj->co_flags & RTC_OBJ_ALTER) 9287c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_FILE_2), 9297c478bd9Sstevel@tonic-gate str, (strtbl + fobj->co_alter)); 9307c478bd9Sstevel@tonic-gate else 9317c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_FILE_1), 9327c478bd9Sstevel@tonic-gate str); 9337c478bd9Sstevel@tonic-gate } 9347c478bd9Sstevel@tonic-gate 9357c478bd9Sstevel@tonic-gate /* 9367c478bd9Sstevel@tonic-gate * Under verbose mode validate any real file entry - the 9377c478bd9Sstevel@tonic-gate * same test will be carried out by ld.so.1. 9387c478bd9Sstevel@tonic-gate */ 9397c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_VERBOSE) && 9407c478bd9Sstevel@tonic-gate (fobj->co_flags & RTC_OBJ_REALPTH)) { 9417c478bd9Sstevel@tonic-gate if (stat(str, &status) != 0) { 9427c478bd9Sstevel@tonic-gate int err = errno; 9437c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_STAT), 9447c478bd9Sstevel@tonic-gate str, strerror(err)); 9457c478bd9Sstevel@tonic-gate } else if (status.st_size != fobj->co_info) { 9467c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_FCMP), 9477c478bd9Sstevel@tonic-gate str); 9487c478bd9Sstevel@tonic-gate } 9497c478bd9Sstevel@tonic-gate } 9507c478bd9Sstevel@tonic-gate } 9517c478bd9Sstevel@tonic-gate } 9527c478bd9Sstevel@tonic-gate 9537c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_UPDATE) == 0) 95457ef7aa9SRod Evans printcmd(crle, head, cmdline); 9557c478bd9Sstevel@tonic-gate 9567c478bd9Sstevel@tonic-gate if ((crle->c_flags & CRLE_VERBOSE) == 0) 957c13de8f6Sab196087 return (INSCFG_RET_OK); 9587c478bd9Sstevel@tonic-gate 9597c478bd9Sstevel@tonic-gate /* 9607c478bd9Sstevel@tonic-gate * If we've in verbose mode scan the hash list. 9617c478bd9Sstevel@tonic-gate */ 9627c478bd9Sstevel@tonic-gate /* LINTED */ 963c13de8f6Sab196087 hash = (Word *)(CAST_PTRINT(char *, head->ch_hash) + addr); 9647c478bd9Sstevel@tonic-gate bkts = hash[0]; 9657c478bd9Sstevel@tonic-gate chain = &hash[2 + bkts]; 9667c478bd9Sstevel@tonic-gate hash += 2; 9677c478bd9Sstevel@tonic-gate 9687c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_HASH)); 9697c478bd9Sstevel@tonic-gate 9707c478bd9Sstevel@tonic-gate /* 9717c478bd9Sstevel@tonic-gate * Scan the hash buckets looking for valid entries. 9727c478bd9Sstevel@tonic-gate */ 9737c478bd9Sstevel@tonic-gate for (ndx = 0; ndx < bkts; ndx++, hash++) { 974de777a60Sab196087 Conv_config_obj_buf_t config_obj_buf; 9757c478bd9Sstevel@tonic-gate Rtc_obj *obj; 9767c478bd9Sstevel@tonic-gate const char *str; 9777c478bd9Sstevel@tonic-gate Word _ndx; 9787c478bd9Sstevel@tonic-gate 97957ef7aa9SRod Evans if (*hash == NULL) 9807c478bd9Sstevel@tonic-gate continue; 9817c478bd9Sstevel@tonic-gate 9827c478bd9Sstevel@tonic-gate obj = objtbl + *hash; 9837c478bd9Sstevel@tonic-gate str = strtbl + obj->co_name; 9847c478bd9Sstevel@tonic-gate 9857c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_HASHENT_1), obj->co_id, ndx, 986de777a60Sab196087 str, conv_config_obj(obj->co_flags, &config_obj_buf)); 9877c478bd9Sstevel@tonic-gate 9887c478bd9Sstevel@tonic-gate /* 9897c478bd9Sstevel@tonic-gate * Determine whether there are other objects chained to this 9907c478bd9Sstevel@tonic-gate * bucket. 9917c478bd9Sstevel@tonic-gate */ 9927c478bd9Sstevel@tonic-gate for (_ndx = chain[*hash]; _ndx; _ndx = chain[_ndx]) { 9937c478bd9Sstevel@tonic-gate obj = objtbl + _ndx; 9947c478bd9Sstevel@tonic-gate str = strtbl + obj->co_name; 9957c478bd9Sstevel@tonic-gate 9967c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DMP_HASHENT_2), obj->co_id, 997de777a60Sab196087 str, conv_config_obj(obj->co_flags, 998de777a60Sab196087 &config_obj_buf)); 9997c478bd9Sstevel@tonic-gate } 10007c478bd9Sstevel@tonic-gate } 10017c478bd9Sstevel@tonic-gate (void) printf(MSG_ORIG(MSG_STR_NL)); 10027c478bd9Sstevel@tonic-gate 1003c13de8f6Sab196087 return (INSCFG_RET_OK); 10047c478bd9Sstevel@tonic-gate } 10057c478bd9Sstevel@tonic-gate 10067c478bd9Sstevel@tonic-gate 1007c13de8f6Sab196087 INSCFG_RET 1008587032cfSab196087 inspectconfig(Crle_desc * crle, int c_class) 10097c478bd9Sstevel@tonic-gate { 1010c13de8f6Sab196087 INSCFG_RET error; 1011c13de8f6Sab196087 int fd; 10127c478bd9Sstevel@tonic-gate Addr addr; 10137c478bd9Sstevel@tonic-gate struct stat status; 10147c478bd9Sstevel@tonic-gate const char *caller = crle->c_name, *file = crle->c_confil; 1015de777a60Sab196087 Conv_inv_buf_t inv_buf1, inv_buf2, inv_buf3; 10167c478bd9Sstevel@tonic-gate 10177c478bd9Sstevel@tonic-gate /* 10187c478bd9Sstevel@tonic-gate * Open the configuration file, determine its size and map it in. 10197c478bd9Sstevel@tonic-gate */ 10207c478bd9Sstevel@tonic-gate if ((fd = open(file, O_RDONLY, 0)) == -1) { 10217c478bd9Sstevel@tonic-gate int err = errno; 10227c478bd9Sstevel@tonic-gate 1023587032cfSab196087 if (err == ENOENT) { 1024587032cfSab196087 #ifndef _ELF64 1025587032cfSab196087 /* Must restart if user requested a 64-bit file */ 1026587032cfSab196087 if (c_class == ELFCLASS64) 1027587032cfSab196087 return (INSCFG_RET_NEED64); 1028587032cfSab196087 #endif 1029587032cfSab196087 10307c478bd9Sstevel@tonic-gate /* 10317c478bd9Sstevel@tonic-gate * To allow an update (-u) from scratch, fabricate any 10327c478bd9Sstevel@tonic-gate * default search and secure paths that the user 10337c478bd9Sstevel@tonic-gate * intends to add to. 10347c478bd9Sstevel@tonic-gate */ 10357c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_UPDATE) { 10367c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_EDLIB) { 10377c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_EDLIB)) 1038587032cfSab196087 return (INSCFG_RET_FAIL); 10397c478bd9Sstevel@tonic-gate } 10407c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_ESLIB) { 10417c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_ESLIB)) 1042587032cfSab196087 return (INSCFG_RET_FAIL); 10437c478bd9Sstevel@tonic-gate } 10447c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_ADLIB) { 10457c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_ADLIB)) 1046587032cfSab196087 return (INSCFG_RET_FAIL); 10477c478bd9Sstevel@tonic-gate } 10487c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_ASLIB) { 10497c478bd9Sstevel@tonic-gate if (fablib(crle, CRLE_ASLIB)) 1050587032cfSab196087 return (INSCFG_RET_FAIL); 10517c478bd9Sstevel@tonic-gate } 1052587032cfSab196087 return (INSCFG_RET_OK); 10537c478bd9Sstevel@tonic-gate 10547c478bd9Sstevel@tonic-gate } else if (crle->c_flags & CRLE_CONFDEF) { 10557c478bd9Sstevel@tonic-gate const char *fmt1, *fmt2; 10567c478bd9Sstevel@tonic-gate 10577c478bd9Sstevel@tonic-gate /* 10587c478bd9Sstevel@tonic-gate * Otherwise if the user is inspecting a default 10597c478bd9Sstevel@tonic-gate * configuration file that doesn't exist inform 10607c478bd9Sstevel@tonic-gate * them and display the ELF defaults. 10617c478bd9Sstevel@tonic-gate */ 10627c478bd9Sstevel@tonic-gate (void) printf(MSG_INTL(MSG_DEF_NOCONF), file); 1063587032cfSab196087 (void) printf(MSG_INTL(MSG_DMP_PLATFORM), 1064587032cfSab196087 conv_ehdr_class(M_CLASS, 1065d29b2c44Sab196087 CONV_FMT_ALT_FILE, &inv_buf1), 1066587032cfSab196087 conv_ehdr_data(M_DATA, 1067d29b2c44Sab196087 CONV_FMT_ALT_FILE, &inv_buf2), 1068587032cfSab196087 conv_ehdr_mach(M_MACH, 1069d29b2c44Sab196087 CONV_FMT_ALT_FILE, &inv_buf3)); 1070587032cfSab196087 10717c478bd9Sstevel@tonic-gate 10727c478bd9Sstevel@tonic-gate if (crle->c_flags & CRLE_AOUT) { 10737c478bd9Sstevel@tonic-gate fmt1 = MSG_INTL(MSG_DEF_AOUTDLP); 1074ba7962c0SRod Evans #ifndef SGS_PRE_UNIFIED_PROCESS 1075ba7962c0SRod Evans fmt2 = MSG_INTL(MSG_DEF_AOUTNEWTD); 1076ba7962c0SRod Evans #else 1077ba7962c0SRod Evans fmt2 = MSG_INTL(MSG_DEF_AOUTOLDTD); 1078ba7962c0SRod Evans #endif 10797c478bd9Sstevel@tonic-gate } else { 1080c13de8f6Sab196087 #if M_CLASS == ELFCLASS64 10817c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 10827c478bd9Sstevel@tonic-gate fmt1 = MSG_INTL(MSG_DEF_NEWDLP_64); 10837c478bd9Sstevel@tonic-gate fmt2 = MSG_INTL(MSG_DEF_NEWTD_64); 10847c478bd9Sstevel@tonic-gate #else 10857c478bd9Sstevel@tonic-gate fmt1 = MSG_INTL(MSG_DEF_OLDDLP_64); 10867c478bd9Sstevel@tonic-gate fmt2 = MSG_INTL(MSG_DEF_OLDTD_64); 10877c478bd9Sstevel@tonic-gate #endif 1088c13de8f6Sab196087 #else 10897c478bd9Sstevel@tonic-gate #ifndef SGS_PRE_UNIFIED_PROCESS 10907c478bd9Sstevel@tonic-gate fmt1 = MSG_INTL(MSG_DEF_NEWDLP); 10917c478bd9Sstevel@tonic-gate fmt2 = MSG_INTL(MSG_DEF_NEWTD); 10927c478bd9Sstevel@tonic-gate #else 10937c478bd9Sstevel@tonic-gate fmt1 = MSG_INTL(MSG_DEF_OLDDLP); 10947c478bd9Sstevel@tonic-gate fmt2 = MSG_INTL(MSG_DEF_OLDTD); 10957c478bd9Sstevel@tonic-gate #endif 1096c13de8f6Sab196087 #endif 10977c478bd9Sstevel@tonic-gate } 10987c478bd9Sstevel@tonic-gate (void) printf(fmt1); 10997c478bd9Sstevel@tonic-gate (void) printf(fmt2); 11007c478bd9Sstevel@tonic-gate 1101587032cfSab196087 return (INSCFG_RET_OK); 11027c478bd9Sstevel@tonic-gate } 11037c478bd9Sstevel@tonic-gate } 11047c478bd9Sstevel@tonic-gate 11057c478bd9Sstevel@tonic-gate /* 11067c478bd9Sstevel@tonic-gate * Otherwise there's an error condition in accessing the file. 11077c478bd9Sstevel@tonic-gate */ 11087c478bd9Sstevel@tonic-gate (void) fprintf(stderr, MSG_INTL(MSG_SYS_OPEN), caller, file, 11097c478bd9Sstevel@tonic-gate strerror(err)); 11107c478bd9Sstevel@tonic-gate 1111587032cfSab196087 return (INSCFG_RET_FAIL); 11127c478bd9Sstevel@tonic-gate } 11137c478bd9Sstevel@tonic-gate 11147c478bd9Sstevel@tonic-gate (void) fstat(fd, &status); 11157c478bd9Sstevel@tonic-gate if (status.st_size < sizeof (Rtc_head)) { 11167c478bd9Sstevel@tonic-gate (void) close(fd); 11177c478bd9Sstevel@tonic-gate (void) fprintf(stderr, MSG_INTL(MSG_COR_TRUNC), caller, file); 1118587032cfSab196087 return (INSCFG_RET_FAIL); 11197c478bd9Sstevel@tonic-gate } 11207c478bd9Sstevel@tonic-gate if ((addr = (Addr)mmap(0, status.st_size, PROT_READ, MAP_SHARED, 11217c478bd9Sstevel@tonic-gate fd, 0)) == (Addr)MAP_FAILED) { 11227c478bd9Sstevel@tonic-gate int err = errno; 11237c478bd9Sstevel@tonic-gate (void) fprintf(stderr, MSG_INTL(MSG_SYS_MMAP), caller, file, 11247c478bd9Sstevel@tonic-gate strerror(err)); 11257c478bd9Sstevel@tonic-gate (void) close(fd); 1126587032cfSab196087 return (INSCFG_RET_FAIL); 11277c478bd9Sstevel@tonic-gate } 11287c478bd9Sstevel@tonic-gate (void) close(fd); 11297c478bd9Sstevel@tonic-gate 11307c478bd9Sstevel@tonic-gate /* 11317c478bd9Sstevel@tonic-gate * Print the contents of the configuration file. 11327c478bd9Sstevel@tonic-gate */ 1133587032cfSab196087 error = scanconfig(crle, addr, c_class); 11347c478bd9Sstevel@tonic-gate 11357c478bd9Sstevel@tonic-gate (void) munmap((void *)addr, status.st_size); 11367c478bd9Sstevel@tonic-gate return (error); 11377c478bd9Sstevel@tonic-gate } 1138