/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <wait.h>
#include <limits.h>
#include <gelf.h>
#include "machdep.h"
#include "sgs.h"
#include "conv.h"
#include "_crle.h"
#include "msg.h"
/*
* Establish an association between a filter and filtee. Both the filter and
* filtee already exist in the internal hash table, since auditing registers
* objects (la_objopen()) before it registers filters (la_objfilter()).
*/
static int
{
/*
* Locate the filter. Mark the underlying object as the filter to
* reflect that no matter how it is referenced, it's a filter.
*/
HASH_FND_ENT)) == NULL)
return (1);
HASH_FND_ENT)) == NULL)
return (1);
/*
* Locate the filtee. Mark the referencing object as the filtee, as
* this is the object referenced by the filter.
*/
HASH_FND_ENT)) == NULL)
return (1);
/*
* Traverse the filter list using the filters real name. If ld.so.1
* inspects the resulting configuration file for filters, it's the
* objects real name that will be used (PATHNAME()).
*/
/*
* Determine whether this filter and filtee string pair already
* exist.
*/
continue;
/*
* Add this filtee additional association.
*/
AL_CNT_CRLE) == NULL)
return (1);
return (0);
}
/*
* This is a new filter descriptor. Add this new filtee association.
*/
return (1);
}
return (1);
return (0);
}
/*
* Establish the dependencies of an ELF object and add them to the internal
* configuration information. This information is gathered by using libcrle.so.1
* as an audit library - this is akin to using ldd(1) only simpler.
*/
int
{
const char *exename;
const char *preload;
/*
* If we're dealing with a dynamic executable we'll execute it,
* otherwise we'll preload the shared object with one of the lddstub's.
*/
} else {
}
/*
* Set up a pipe through which the audit library will write the
* dependencies.
*/
return (1);
}
/*
* Fork ourselves to run our executable and collect its dependencies.
*/
return (1);
}
if (pid) {
/*
* Parent. Read each dependency from the audit library. The read
* side of the pipe is attached to stdio to make obtaining the
* individual dependencies easier.
*/
char *str;
/*
* Make sure we recognize the message, remove
* the newline (which allowed fgets() use) and
* register the name;
*/
continue;
*str = '\0';
str, MSG_AUD_DEPEND_SIZE) == 0) {
/*
* Process any dependencies.
*/
(flags & ~RTC_OBJ_GROUP))) != 0)
break;
str, MSG_AUD_FILTER_SIZE) == 0) {
/*
* Process any filters.
*/
str)) != 0)
break;
}
}
} else
;
if (status) {
if (WIFSIGNALED(status)) {
}
}
return (error);
} else {
/*
* Child. Set up environment variables to enable and identify
* auditing. Initialize CRLE_FD and LD_FLAGS strings.
*/
/*
* If asked to dump a group of dependencies make sure any
* lazily-loaded objects get processed - (append loadavail to
* LD_FLAGS=confgen).
*/
if (flags & RTC_OBJ_GROUP)
/*
* Put LD_PRELOAD= in the environment if necessary.
*/
if (preload) {
}
/*
* Put strings in the environment for exec().
* NOTE, use of automatic variables for construction of the
* environment variables is legitimate here, as they are local
* to the child process and are established solely for exec().
*/
return (1);
}
/* NOTREACHED */
}
}
return (0);
}