qubes-rpc-multiplexer 794 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. mkfifo /tmp/qrexec-rpc-stderr.$$
  3. logger -t "$1-$2" -f /tmp/qrexec-rpc-stderr.$$ &
  4. exec 2>/tmp/qrexec-rpc-stderr.$$
  5. rm -f /tmp/qrexec-rpc-stderr.$$
  6. QUBES_RPC=/etc/qubes-rpc
  7. # XXX: Backward compatibility
  8. DEPRECATED_QUBES_RPC=/etc/qubes_rpc
  9. if ! [ $# = 2 ] ; then
  10. echo $0: bad argument count >&2
  11. exit 1
  12. fi
  13. export QREXEC_REMOTE_DOMAIN="$2"
  14. CFG_FILE=$QUBES_RPC/"$1"
  15. if [ -s "$CFG_FILE" ] ; then
  16. exec /bin/sh "$CFG_FILE"
  17. echo "$0: failed to execute handler for" "$1" >&2
  18. exit 1
  19. fi
  20. CFG_FILE=$DEPRECATED_QUBES_RPC/"$1"
  21. if [ -s "$CFG_FILE" ] ; then
  22. echo "$0: RPC service '$1' uses deprecated directory, please move to $QUBES_RPC" >&2
  23. exec /bin/sh "$CFG_FILE"
  24. echo "$0: failed to execute handler for" "$1" >&2
  25. exit 1
  26. fi
  27. echo "$0: nonexistent or empty" "$CFG_FILE" file >&2
  28. exit 1