Blame SOURCES/daemon-scl-helper.sh

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