Blame SOURCES/daemon-scl-helper.sh

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