Blame SOURCES/daemon-scl-helper.sh

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