Blame SOURCES/daemon-scl-helper.sh

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