2013-03-20 05:24:17 +00:00
|
|
|
#!/bin/sh
|
2014-05-05 03:27:08 +00:00
|
|
|
|
|
|
|
mkfifo /tmp/qrexec-rpc-stderr.$$
|
2015-03-17 13:46:53 +00:00
|
|
|
logger -t "$1-$2" -f /tmp/qrexec-rpc-stderr.$$ >/dev/null 2>&1 </dev/null &
|
2014-05-05 03:27:08 +00:00
|
|
|
exec 2>/tmp/qrexec-rpc-stderr.$$
|
|
|
|
rm -f /tmp/qrexec-rpc-stderr.$$
|
|
|
|
|
2013-03-20 05:24:17 +00:00
|
|
|
QUBES_RPC=/etc/qubes-rpc
|
2015-02-06 18:47:13 +00:00
|
|
|
LOCAL_QUBES_RPC=/usr/local/etc/qubes-rpc
|
|
|
|
|
2013-03-20 05:24:17 +00:00
|
|
|
if ! [ $# = 2 ] ; then
|
2015-03-17 13:47:29 +00:00
|
|
|
echo $0: bad argument count, usage: $0 SERVICE-NAME REMOTE-DOMAIN-NAME >&2
|
2013-03-20 05:24:17 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
export QREXEC_REMOTE_DOMAIN="$2"
|
2016-03-27 02:30:44 +00:00
|
|
|
export QREXEC_SERVICE_FULL_NAME="$1"
|
|
|
|
SERVICE_WITHOUT_ARGUMENT="${1%%+*}"
|
|
|
|
if [ "${QREXEC_SERVICE_FULL_NAME}" != "${SERVICE_WITHOUT_ARGUMENT}" ]; then
|
|
|
|
export QREXEC_SERVICE_ARGUMENT="${QREXEC_SERVICE_FULL_NAME#*+}"
|
|
|
|
fi
|
2015-03-17 13:47:29 +00:00
|
|
|
|
2016-03-27 02:30:44 +00:00
|
|
|
for CFG_FILE in $LOCAL_QUBES_RPC/"$1" $QUBES_RPC/"$1" \
|
|
|
|
$LOCAL_QUBES_RPC/"${SERVICE_WITHOUT_ARGUMENT}" \
|
|
|
|
$QUBES_RPC/"${SERVICE_WITHOUT_ARGUMENT}"; do
|
2015-02-06 18:47:13 +00:00
|
|
|
if [ -s "$CFG_FILE" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2015-03-17 13:47:29 +00:00
|
|
|
|
|
|
|
if [ -x "$CFG_FILE" ] ; then
|
2016-03-27 02:30:44 +00:00
|
|
|
exec "$CFG_FILE" ${QREXEC_SERVICE_ARGUMENT}
|
2013-03-20 05:24:17 +00:00
|
|
|
echo "$0: failed to execute handler for" "$1" >&2
|
|
|
|
exit 1
|
2015-03-17 13:47:29 +00:00
|
|
|
else
|
2016-03-27 02:30:44 +00:00
|
|
|
exec /bin/sh -- "$CFG_FILE" ${QREXEC_SERVICE_ARGUMENT}
|
2013-03-20 05:24:17 +00:00
|
|
|
echo "$0: failed to execute handler for" "$1" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|