Blame SOURCES/daemon-scl-helper.sh

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