Blame SOURCES/daemon-scl-helper.sh

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