Blame SOURCES/daemon-scl-helper.sh

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