core-agent-linux: misc const fixups

(cherry picked from commit 475421b2e2)
Apparently some of this commit got reverted during cleanup before
Qubes 3.0 release.
This commit is contained in:
Vincent Penquerc'h 2013-12-28 06:49:30 -05:00 committed by Marek Marczykowski-Górecki
parent 68d98179f0
commit f49042211b
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -85,11 +85,11 @@ void no_colon_in_cmd()
void do_exec(const char *cmd) void do_exec(const char *cmd)
{ {
char buf[strlen(QUBES_RPC_MULTIPLEXER_PATH) + strlen(cmd) - RPC_REQUEST_COMMAND_LEN + 1]; char buf[strlen(QUBES_RPC_MULTIPLEXER_PATH) + strlen(cmd) - RPC_REQUEST_COMMAND_LEN + 1];
char *realcmd = index(cmd, ':'); char *realcmd = index(cmd, ':'), *user;
if (!realcmd) if (!realcmd)
no_colon_in_cmd(); no_colon_in_cmd();
/* mark end of username and move to command */ /* mark end of username and move to command */
*realcmd = 0; user=strndup(cmd,realcmd-cmd);
realcmd++; realcmd++;
/* ignore "nogui:" prefix in linux agent */ /* ignore "nogui:" prefix in linux agent */
if (strncmp(realcmd, NOGUI_CMD_PREFIX, NOGUI_CMD_PREFIX_LEN) == 0) if (strncmp(realcmd, NOGUI_CMD_PREFIX, NOGUI_CMD_PREFIX_LEN) == 0)
@ -103,7 +103,7 @@ void do_exec(const char *cmd)
signal(SIGCHLD, SIG_DFL); signal(SIGCHLD, SIG_DFL);
signal(SIGPIPE, SIG_DFL); signal(SIGPIPE, SIG_DFL);
execl("/bin/su", "su", "-", cmd, "-c", realcmd, NULL); execl("/bin/su", "su", "-", user, "-c", realcmd, NULL);
perror("execl"); perror("execl");
exit(1); exit(1);
} }