Blame SOURCES/daemon-scl-helper.sh

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