/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <rtc.h>
#include <debug.h>
#include <conv.h>
#include "_rtld.h"
#include "msg.h"
/*
* Validate a configuration file.
*/
static void
{
int err;
/*
* If this configuration file is for a specific application make sure
* we've been invoked by the application. Note that we only check the
* basename component of the application as the original application
* and its cached equivalent are never going to have the same pathnames.
* Also, we use PATHNAME() and not NAME() - this catches things like vi
*/
/*
* It's possible a user is trying to ldd(1) an alternate
* shared object and point to a configuration file that
* the shared object is part of. In this case ignore
* any mismatch name warnings.
*/
_cname);
return;
}
}
/*
* If we have a valid alternative application reset its original
* name for possible $ORIGIN processing.
*/
}
}
/*
* If alternative objects are specified traverse the directories
* specified in the configuration file, if any directory is newer than
* the time it was recorded in the cache then continue to inspect its
* files. Any file determined newer than its configuration recording
* questions the the use of any alternative objects. The intent here
* is to make sure no-one abuses a configuration as a means of static
* linking.
*/
/*
* Skip directories that provide no files - this also catches
* RTC_OBJ_NOEXIST directories.
*/
continue;
/*
* Skip directories that haven't provided real, dumped files.
*/
continue;
continue;
}
continue;
/*
* The system directory is newer than the configuration files
* entry, start checking any dumped files.
*/
/*
* Skip any files that aren't real, dumped files.
*/
(RTC_OBJ_DUMP | RTC_OBJ_REALPTH)) !=
continue;
continue;
}
/*
* If the files size is different somethings been
* changed.
*/
str);
}
}
}
}
/*
* Process a configuration file.
*
* A configuration file can be specified using the LD_CONFIG environment
* variable, from a DT_CONFIG string recorded in the executable (see ld(1) -c),
* or in the case of a crle() dumped image, the file is "fabricated" to a
* configuration file that may have been associated with the dumped image. In
* the absence of any of these techniques, a default configuration file is used.
*
* The LD_CONFIG variable take precedence, unless the application is secure, in
* which case the environment variable is ignored (see ld_generic_env()).
*
* A DT_CONFIG string is honored, even if the application is secure. However,
* the path name follows the same rules as RUNPATH's, which must be a full path
* name with no use of $ORIGIN.
*/
int
{
const char *str;
/*
* If we're dealing with an alternative application, fabricate the need
* for a $ORIGIN/ld.config.app-name configuration file.
*/
if (rtld_flags & RT_FL_CONFAPP) {
str++;
else
} else
/*
* If a configuration file name is known, expand and verify the name.
*/
if (str) {
/*
* Expand any configuration string.
*/
return (0);
/*
* If this is a secure application, validate the configuration
* file path name. Ignore any untrustworthy path name, and
* fall through to pick up the defaults.
*/
if ((rtld_flags & RT_FL_SECURE) &&
else
}
/*
* If a configuration file has not been specified try opening up the
* default.
*/
#if defined(_ELF64)
#else
#endif
}
/*
* If we can't open the configuration file return silently.
*/
return (DBG_CONF_PRCFAIL);
/*
* Determine the configuration file size and map the file.
*/
return (DBG_CONF_CORRUPT);
}
return (DBG_CONF_PRCFAIL);
}
/*
* If we have an Rtc_id block at the beginning, then validate it
* and advance the address to the Rtc_head. If not, then trust
* that the file is compatible with us and move ahead (there is
* some error checking for Rtc_head below as well).
*/
if (RTC_ID_TEST(id)) {
return (DBG_CONF_CORRUPT);
return (DBG_CONF_ABIMISMATCH);
}
/*
* Make sure we can handle this version of the configuration file.
*/
return (DBG_CONF_VERSION);
/*
* When crle(1) creates a temporary configuration file the
* RTC_HDR_IGNORE flag is set. Thus the mapping of the configuration
* file is taken into account but not its content.
*/
return (DBG_CONF_IGNORE);
/*
* Apply any new default library pathname.
*/
if (head->ch_edlibpath) {
#ifndef SGS_PRE_UNIFIED_PROCESS
#if defined(_ELF64)
#else
#endif
}
#endif
}
if (head->ch_eslibpath) {
#ifndef SGS_PRE_UNIFIED_PROCESS
#if defined(_ELF64)
#else
#endif
}
#endif
}
if (head->ch_adlibpath) {
}
if (head->ch_aslibpath) {
}
#endif
/*
* Apply any environment variables. This attribute was added with
* RTC_VER_THREE.
*/
(!(rtld_flags & RT_FL_NOENVCFG))) {
return (-1);
}
/*
*/
(!(rtld_flags2 & RT_FL2_NOFLTCFG))) {
}
/*
* Determine whether directory configuration is available.
*/
features |= CONF_DIRCFG;
}
/*
* Determine whether alternative objects are specified or an object
* reservation area is required. If the reservation can't be completed
* (either because the configuration information is out-of-date, or the
* the reservation can't be allocated), then alternative objects are
* ignored.
*/
features |= CONF_OBJALT;
return (-1);
features |= CONF_MEMRESV;
}
}
return (features);
}
/*
* Determine whether the given file exists in the configuration file.
*/
Rtc_obj *
{
const char *str;
while (ndx) {
continue;
}
return (obj);
}
return (0);
}
/*
* Determine whether a filter and filtee string pair exists in the configuration
* file. If so, return the cached filtees that are associated with this pair as
* an Alist.
*/
void
{
fltrtbl++) {
continue;
/*
* Create a path descriptor for each filtee associated with this
* entries is called for, as any original expansion would have
* been carried out before they were recorded in the
* configuration file.
*/
/* LINTED */
const char *flte;
return;
}
}
}