Skip to content

Commit 1c39aa1

Browse files
committed
Strip "QUBESRPC " prefix from service call commands
It carries no information, and various parts of the code must strip it. Just omit it from the command entirely. Whether a command is an RPC command should be determined by the service descriptor being non-NULL. Review with "git diff --ignore-space-change".
1 parent ff0adad commit 1c39aa1

File tree

6 files changed

+172
-175
lines changed

6 files changed

+172
-175
lines changed

agent/qrexec-agent.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ _Noreturn void do_exec(const char *prog, const char *cmd, const char *user)
172172
exit(1);
173173
}
174174
/* call QUBESRPC if requested */
175-
/* no point in creating a login shell for test environments */
176-
exec_qubes_rpc_if_requested2(prog, cmd, environ, false);
175+
if (prog) {
176+
/* no point in creating a login shell for test environments */
177+
exec_qubes_rpc2(prog, cmd, environ, false);
178+
}
177179

178180
/* otherwise exec shell */
179181
execl("/bin/sh", "sh", "-c", cmd, NULL);
@@ -279,10 +281,11 @@ _Noreturn void do_exec(const char *prog, const char *cmd, const char *user)
279281
if (retval == -1)
280282
warn("chdir(%s)", pw->pw_dir);
281283

282-
/* Call QUBESRPC if requested, using a login shell to set up
283-
* environment variables. */
284-
exec_qubes_rpc_if_requested2(prog, cmd, env, true);
285-
284+
/* call QUBESRPC if requested */
285+
if (prog) {
286+
/* Set up environment variables for a login shell. */
287+
exec_qubes_rpc2(prog, cmd, env, true);
288+
}
286289
/* otherwise exec shell */
287290
execle(pw->pw_shell, arg0, "-c", cmd, (char*)NULL, env);
288291
_exit(QREXEC_EXIT_PROBLEM);
@@ -318,10 +321,11 @@ _Noreturn void do_exec(const char *prog, const char *cmd, const char *user)
318321
pam_end(pamh, PAM_ABORT);
319322
exit(1);
320323
#else
321-
/* Call QUBESRPC if requested, using a login shell to set up
322-
* environment variables. */
323-
exec_qubes_rpc_if_requested2(prog, cmd, environ, true);
324-
324+
/* call QUBESRPC if requested */
325+
if (prog) {
326+
/* Set up environment variables for a login session. */
327+
exec_qubes_rpc2(prog, cmd, environ, true);
328+
}
325329
/* otherwise exec shell */
326330
execl("/bin/su", "su", "-", user, "-c", cmd, NULL);
327331
PERROR("execl");

agent/qrexec-fork-server.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ void do_exec(const char *prog, const char *cmd, const char *user __attribute__((
4444
signal(SIGCHLD, SIG_DFL);
4545
signal(SIGPIPE, SIG_DFL);
4646

47-
/* Call QUBESRPC if requested. This code already runs in a login session. */
48-
exec_qubes_rpc_if_requested2(prog, cmd, environ, false);
47+
/* call QUBESRPC if requested */
48+
if (prog != NULL) {
49+
/* Already in login session. */
50+
exec_qubes_rpc2(prog, cmd, environ, false);
51+
}
4952

5053
/* otherwise, pass it to shell */
5154
shell = getenv("SHELL");

daemon/qrexec-client.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ static _Noreturn void do_exec(const char *prog,
6666
const char *cmdline,
6767
const char *username __attribute__((unused)))
6868
{
69-
/* Avoid calling RPC command through shell.
70-
* Qrexec-client is always in a login session. */
71-
exec_qubes_rpc_if_requested2(prog, cmdline, environ, false);
69+
/* avoid calling RPC service through shell */
70+
if (prog) {
71+
/* qrexec-client is always in a login session. */
72+
exec_qubes_rpc2(prog, cmdline, environ, false);
73+
}
7274

73-
/* if above haven't executed RPC command, pass it to shell */
75+
/* if above haven't executed RPC service, pass it to shell */
7476
execl("/bin/bash", "bash", "-c", cmdline, NULL);
7577
PERROR("exec bash");
7678
exit(1);
@@ -326,11 +328,8 @@ int main(int argc, char **argv)
326328
assert(command->username == NULL);
327329
assert(command->command);
328330
/* qrexec-client is always in a login session. */
329-
exec_qubes_rpc_if_requested2(buf.data, command->command, environ, false);
330-
/* not reached, so fall through to crash */
331-
assert(false);
332-
rc = QREXEC_EXIT_PROBLEM;
333-
break;
331+
exec_qubes_rpc2(buf.data, command->command, environ, false);
332+
/* not reached */
334333
default:
335334
assert(false);
336335
rc = QREXEC_EXIT_PROBLEM;

daemon/qrexec-daemon.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,11 @@ static enum policy_response connect_daemon_socket(
11331133
/* called from do_fork_exec */
11341134
static _Noreturn void do_exec(const char *prog, const char *cmd, const char *username __attribute__((unused)))
11351135
{
1136-
/* Avoid calling RPC command through shell.
1137-
* Qrexec-daemon is always in a login session already. */
1138-
exec_qubes_rpc_if_requested2(prog, cmd, environ, true);
1136+
/* avoid calling RPC command through shell */
1137+
if (prog) {
1138+
/* qrexec-daemon is always in a login session already */
1139+
exec_qubes_rpc2(prog, cmd, environ, false);
1140+
}
11391141

11401142
/* if above haven't executed RPC command, pass it to shell */
11411143
execl("/bin/bash", "bash", "-c", cmd, NULL);

0 commit comments

Comments
 (0)