vm: support for magic QUBESRPC command
Previously dom0 had to know full path of qubes_rpc_multiplexer in VM, which can differ between VMs (eg totally different on Windows). This commit enables dom0 to magic keyword instead of full path.
This commit is contained in:
parent
36f6a2c42c
commit
28ca836e14
@ -30,6 +30,9 @@
|
|||||||
#define QREXEC_AGENT_TRIGGER_PATH "/var/run/qubes/qrexec_agent"
|
#define QREXEC_AGENT_TRIGGER_PATH "/var/run/qubes/qrexec_agent"
|
||||||
#define QREXEC_AGENT_FDPASS_PATH "/var/run/qubes/qrexec_agent_fdpass"
|
#define QREXEC_AGENT_FDPASS_PATH "/var/run/qubes/qrexec_agent_fdpass"
|
||||||
#define MEMINFO_WRITER_PIDFILE "/var/run/meminfo-writer.pid"
|
#define MEMINFO_WRITER_PIDFILE "/var/run/meminfo-writer.pid"
|
||||||
|
#define QUBES_RPC_MULTIPLEXER_PATH "/usr/lib/qubes/qubes_rpc_multiplexer"
|
||||||
|
|
||||||
|
#define QUBES_RPC_MAGIC_CMD "QUBESRPC"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
/* messages from qrexec_client to qrexec_daemon (both in dom0) */
|
/* messages from qrexec_client to qrexec_daemon (both in dom0) */
|
||||||
|
@ -115,14 +115,23 @@ void no_colon_in_cmd()
|
|||||||
|
|
||||||
void do_exec(char *cmd)
|
void do_exec(char *cmd)
|
||||||
{
|
{
|
||||||
char *sep = index(cmd, ':');
|
char buf[strlen(QUBES_RPC_MULTIPLEXER_PATH) + strlen(cmd) - strlen(QUBES_RPC_MAGIC_CMD) + 1];
|
||||||
if (!sep)
|
char *realcmd = index(cmd, ':');
|
||||||
|
if (!realcmd)
|
||||||
no_colon_in_cmd();
|
no_colon_in_cmd();
|
||||||
*sep = 0;
|
/* mark end of username and move to command */
|
||||||
|
*realcmd = 0;
|
||||||
|
realcmd++;
|
||||||
|
/* replace magic RPC cmd with RPC multiplexer path */
|
||||||
|
if (strncmp(realcmd, QUBES_RPC_MAGIC_CMD " ", strlen(QUBES_RPC_MAGIC_CMD)+1)==0) {
|
||||||
|
strcpy(buf, QUBES_RPC_MULTIPLEXER_PATH);
|
||||||
|
strcpy(buf + strlen(QUBES_RPC_MULTIPLEXER_PATH), realcmd + strlen(QUBES_RPC_MAGIC_CMD));
|
||||||
|
realcmd = buf;
|
||||||
|
}
|
||||||
signal(SIGCHLD, SIG_DFL);
|
signal(SIGCHLD, SIG_DFL);
|
||||||
signal(SIGPIPE, SIG_DFL);
|
signal(SIGPIPE, SIG_DFL);
|
||||||
|
|
||||||
execl("/bin/su", "su", "-", cmd, "-c", sep + 1, NULL);
|
execl("/bin/su", "su", "-", cmd, "-c", realcmd, NULL);
|
||||||
perror("execl");
|
perror("execl");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user