Blame SOURCES/daemon-scl-helper.sh

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