Blame run.in

Packit 517ee8
#!/bin/bash -
Packit 517ee8
# openscap 'run' programs locally script
Packit 517ee8
# Copyright (C) 2011-2013 Red Hat Inc.
Packit 517ee8
#
Packit 517ee8
# This library is free software; you can redistribute it and/or
Packit 517ee8
# modify it under the terms of the GNU Lesser General Public
Packit 517ee8
# License as published by the Free Software Foundation; either
Packit 517ee8
# version 2 of the License, or (at your option) any later version.
Packit 517ee8
#
Packit 517ee8
# This library is distributed in the hope that it will be useful,
Packit 517ee8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 517ee8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 517ee8
# Lesser General Public License for more details.
Packit 517ee8
#
Packit 517ee8
# You should have received a copy of the GNU Lesser General Public
Packit 517ee8
# License along with this library; if not, write to the Free Software
Packit 517ee8
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Packit 517ee8
Packit 517ee8
#----------------------------------------------------------------------
Packit 517ee8
Packit 517ee8
# With this script you can run oscap (or valgrind, gdb, ...) without needing to
Packit 517ee8
# install the utility first.  You just have to do for example:
Packit 517ee8
#
Packit 517ee8
#   ./run program [program args ...]
Packit 517ee8
#
Packit 517ee8
# This works for any C program or test that uses the openscap
Packit 517ee8
# libraries.
Packit 517ee8
Packit 517ee8
#----------------------------------------------------------------------
Packit 517ee8
Packit 517ee8
# Build directory
Packit 517ee8
b=@CMAKE_BINARY_DIR@
Packit 517ee8
# Top source directory
Packit 517ee8
s=@CMAKE_SOURCE_DIR@
Packit 517ee8
Packit 517ee8
# Set library.
Packit 517ee8
export LD_LIBRARY_PATH=$b/src:$b/swig${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
Packit 517ee8
Packit 517ee8
# This is used for SCE check engine (if it is built and enabled)
Packit 517ee8
export OSCAP_CHECK_ENGINE_PLUGIN_DIR=$b/src/SCE
Packit 517ee8
Packit 517ee8
# Set paths to probes, schemas, transformations and cpes.
Packit 517ee8
# If those variables are already set, don't change their values.
Packit 517ee8
if [ -z ${OSCAP_SCHEMA_PATH+x} ] ; then
Packit 517ee8
    export OSCAP_SCHEMA_PATH=$s/schemas
Packit 517ee8
fi
Packit 517ee8
if [ -z ${OSCAP_XSLT_PATH+x} ] ; then
Packit 517ee8
    export OSCAP_XSLT_PATH=$s/xsl
Packit 517ee8
fi
Packit 517ee8
if [ -z ${OSCAP_CPE_PATH+x} ] ; then
Packit 517ee8
    export OSCAP_CPE_PATH=$s/cpe
Packit 517ee8
fi
Packit 517ee8
Packit 517ee8
# For SWIG bindings.
Packit 517ee8
export PERL5LIB=$b/swig/perl:$b/swig/perl${PERL5LIB:+:$PERL5LIB}
Packit 517ee8
export PYTHONPATH=$s/utils:$s/swig/python3:$b/swig/src:$b/swig/python3:$b/swig/python3${PYTHONPATH:+:$PYTHONPATH}
Packit 517ee8
export PYTHONDONTWRITEBYTECODE=Y
Packit 517ee8
Packit 517ee8
# This is a cheap way to find some use-after-free and uninitialized
Packit 517ee8
# read problems when using glibc.
Packit 517ee8
random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
Packit 517ee8
export MALLOC_PERTURB_=$random_val
Packit 517ee8
Packit 517ee8
# Run the program.
Packit 517ee8
exec "$@"