| 1 |
#!/bin/bash - |
| 2 |
# openscap 'run' programs locally script |
| 3 |
# Copyright (C) 2011-2013 Red Hat Inc. |
| 4 |
# |
| 5 |
# This library is free software; you can redistribute it and/or |
| 6 |
# modify it under the terms of the GNU Lesser General Public |
| 7 |
# License as published by the Free Software Foundation; either |
| 8 |
# version 2 of the License, or (at your option) any later version. |
| 9 |
# |
| 10 |
# This library is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
# Lesser General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU Lesser General Public |
| 16 |
# License along with this library; if not, write to the Free Software |
| 17 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
|
| 19 |
#---------------------------------------------------------------------- |
| 20 |
|
| 21 |
# With this script you can run oscap (or valgrind, gdb, ...) without needing to |
| 22 |
# install the utility first. You just have to do for example: |
| 23 |
# |
| 24 |
# ./run program [program args ...] |
| 25 |
# |
| 26 |
# This works for any C program or test that uses the openscap |
| 27 |
# libraries. |
| 28 |
|
| 29 |
#---------------------------------------------------------------------- |
| 30 |
|
| 31 |
# Build directory |
| 32 |
b=@CMAKE_BINARY_DIR@ |
| 33 |
# Top source directory |
| 34 |
s=@CMAKE_SOURCE_DIR@ |
| 35 |
|
| 36 |
# Set library. |
| 37 |
export LD_LIBRARY_PATH=$b/src:$b/swig${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} |
| 38 |
|
| 39 |
# This is used for SCE check engine (if it is built and enabled) |
| 40 |
export OSCAP_CHECK_ENGINE_PLUGIN_DIR=$b/src/SCE |
| 41 |
|
| 42 |
# Set paths to probes, schemas, transformations and cpes. |
| 43 |
# If those variables are already set, don't change their values. |
| 44 |
if [ -z ${OSCAP_SCHEMA_PATH+x} ] ; then |
| 45 |
export OSCAP_SCHEMA_PATH=$s/schemas |
| 46 |
fi |
| 47 |
if [ -z ${OSCAP_XSLT_PATH+x} ] ; then |
| 48 |
export OSCAP_XSLT_PATH=$s/xsl |
| 49 |
fi |
| 50 |
if [ -z ${OSCAP_CPE_PATH+x} ] ; then |
| 51 |
export OSCAP_CPE_PATH=$s/cpe |
| 52 |
fi |
| 53 |
|
| 54 |
# For SWIG bindings. |
| 55 |
export PERL5LIB=$b/swig/perl:$b/swig/perl${PERL5LIB:+:$PERL5LIB} |
| 56 |
export PYTHONPATH=$s/utils:$s/swig/python3:$b/swig/src:$b/swig/python3:$b/swig/python3${PYTHONPATH:+:$PYTHONPATH} |
| 57 |
export PYTHONDONTWRITEBYTECODE=Y |
| 58 |
|
| 59 |
# This is a cheap way to find some use-after-free and uninitialized |
| 60 |
# read problems when using glibc. |
| 61 |
random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)" |
| 62 |
export MALLOC_PERTURB_=$random_val |
| 63 |
|
| 64 |
# Run the program. |
| 65 |
exec "$@" |