소스 검색

qrexec: execute RPC service directly (without a shell) if it has executable bit set

This will allow to use some different shell/language for a service (for
example python).
Marek Marczykowski-Górecki 9 년 전
부모
커밋
4b451ef680
1개의 변경된 파일15개의 추가작업 그리고 10개의 파일을 삭제
  1. 15 10
      qrexec/qubes-rpc-multiplexer

+ 15 - 10
qrexec/qubes-rpc-multiplexer

@@ -9,22 +9,27 @@ QUBES_RPC=/etc/qubes-rpc
 # XXX: Backward compatibility
 DEPRECATED_QUBES_RPC=/etc/qubes_rpc
 if ! [ $# = 2 ] ; then
-	echo $0: bad argument count >&2
+	echo $0: bad argument count, usage: $0 SERVICE-NAME REMOTE-DOMAIN-NAME >&2
 	exit 1
 fi
 export QREXEC_REMOTE_DOMAIN="$2"
-CFG_FILE=$QUBES_RPC/"$1"
-if [ -s "$CFG_FILE" ] ; then
-	exec /bin/sh "$CFG_FILE"
+
+if [ -s "$QUBES_RPC/$1" ]; then
+    CFG_FILE=$QUBES_RPC/"$1"
+elif [ -s "$DEPRECATED_QUBES_RPC/$1" ]; then
+    echo "$0: RPC service '$1' uses deprecated directory, please move to $QUBES_RPC" >&2
+    CFG_FILE=$DEPRECATED_QUBES_RPC/"$1"
+else
+    echo "$0: Cannot find service $1 file in $QUBES_RPC" >&2
+    exit 1
+fi
+
+if [ -x "$CFG_FILE" ] ; then
+	exec "$CFG_FILE"
 	echo "$0: failed to execute handler for" "$1" >&2
 	exit 1
-fi
-CFG_FILE=$DEPRECATED_QUBES_RPC/"$1"
-if [ -s "$CFG_FILE" ] ; then
-    echo "$0: RPC service '$1' uses deprecated directory, please move to $QUBES_RPC" >&2
+else
 	exec /bin/sh "$CFG_FILE"
 	echo "$0: failed to execute handler for" "$1" >&2
 	exit 1
 fi
-echo "$0: nonexistent or empty" "$CFG_FILE" file >&2
-exit 1