Blame SOURCES/daemon-scl-helper.sh

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