Blame SOURCES/daemon-scl-helper.sh

dbc8c5
#!/bin/sh
dbc8c5
dbc8c5
# This helper script is necessary for having proper SELinux context of daemon
dbc8c5
# process run in SCL environment via systemd unit file.
dbc8c5
# Without this script the process looses SELinux type because /usr/bin/scl
dbc8c5
# has context bin_t and unit_t -> bin_t results in unconfined process running.
dbc8c5
# If this helper script has the same SELinux context as the original binary,
dbc8c5
# the process will have proper SELinux context.
dbc8c5
#
dbc8c5
# This script was designed to be usable the same as the scl command is used,
dbc8c5
# including the collections given as more arguments, separated from binary
dbc8c5
# itself by -- separator.
dbc8c5
# So it is possible to use the list of collections to be enabled via
dbc8c5
# environment file.
dbc8c5
# Thus, instead of:
dbc8c5
#   /usr/bin/scl enable scl1 scl2 -- /path/to/bin arg1 arg2
dbc8c5
# you can use:
dbc8c5
#   /usr/bin/this-script enable scl1 scl2 -- /path/to/bin arg1 arg2
dbc8c5
#
dbc8c5
# Notice: do not forget to set proper SELinux context for this file.
dbc8c5
# The context should be the same as the binary running has.
dbc8c5
#
dbc8c5
# More information at http://bugzilla.redhat.com/show_bug.cgi?id=1172683
dbc8c5
dbc8c5
action="$1"
dbc8c5
shift
dbc8c5
dbc8c5
while [ -n "$1" ] && [ "$1" != "--" ] ; do
dbc8c5
  source scl_source "$action" "$1"
dbc8c5
  shift
dbc8c5
done
dbc8c5
dbc8c5
if [ $# -le 2 ] ; then
dbc8c5
  echo "Usage `basename $0` enable sclname [sclname ...] -- /path/to/bin [arg ...]" >&2
dbc8c5
  exit 1
dbc8c5
fi
dbc8c5
dbc8c5
shift
dbc8c5
dbc8c5
exec "$@"
dbc8c5
dbc8c5
dbc8c5