Blame SOURCES/daemon-scl-helper.sh

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