Blame SOURCES/daemon-scl-helper.sh

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