qubes-rpc-multiplexer 707 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. mkfifo /tmp/qrexec-rpc-stderr.$$
  3. logger -t "$1-$2" -f /tmp/qrexec-rpc-stderr.$$ >/dev/null 2>&1 </dev/null &
  4. exec 2>/tmp/qrexec-rpc-stderr.$$
  5. rm -f /tmp/qrexec-rpc-stderr.$$
  6. QUBES_RPC=/etc/qubes-rpc
  7. LOCAL_QUBES_RPC=/usr/local/etc/qubes-rpc
  8. if ! [ $# = 2 ] ; then
  9. echo $0: bad argument count, usage: $0 SERVICE-NAME REMOTE-DOMAIN-NAME >&2
  10. exit 1
  11. fi
  12. export QREXEC_REMOTE_DOMAIN="$2"
  13. for CFG_FILE in $LOCAL_QUBES_RPC/"$1" $QUBES_RPC/"$1"; do
  14. if [ -s "$CFG_FILE" ]; then
  15. break
  16. fi
  17. done
  18. if [ -x "$CFG_FILE" ] ; then
  19. exec "$CFG_FILE"
  20. echo "$0: failed to execute handler for" "$1" >&2
  21. exit 1
  22. else
  23. exec /bin/sh "$CFG_FILE"
  24. echo "$0: failed to execute handler for" "$1" >&2
  25. exit 1
  26. fi