Blame SOURCES/daemon-scl-helper.sh

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