Blame SOURCES/daemon-scl-helper.sh

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