Blame SOURCES/daemon-scl-helper.sh

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